From ae7552a916c91283b829868e37a774855b89e46e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 15 Mar 2015 14:32:59 -0400 Subject: [PATCH 001/424] Draw bar chart negative values down from the 0 point of the scale. If all values are negative, draw down from the top. Updated the sample file to allow for negative bars. --- samples/bar.html | 5 +++-- src/Chart.Bar.js | 34 +++++++++++++++++++++++++++------- src/Chart.Core.js | 9 ++++++++- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index 5bf4b5bae36..1b1166a2206 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -11,7 +11,7 @@ diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 8127d520aaf..385131acc71 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -75,8 +75,6 @@ } }); - this.datasets = []; - //Set up tooltip events on the chart if (this.options.showTooltips){ helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ @@ -100,86 +98,68 @@ ctx : this.chart.ctx }); - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(data.datasets,function(dataset,datasetIndex){ - - var datasetObject = { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - bars : [] - }; - - this.datasets.push(datasetObject); - + //Create a new point for each piece of data + helpers.each(this.data.datasets,function(dataset,datasetIndex){ + dataset.metaData = []; helpers.each(dataset.data,function(dataPoint,index){ - //Add a new point for each piece of data, passing any required data to draw. - datasetObject.bars.push(new this.BarClass({ - value : dataPoint, - label : data.labels[index], - datasetLabel: dataset.label, - strokeColor : dataset.strokeColor, - fillColor : dataset.fillColor, - highlightFill : dataset.highlightFill || dataset.fillColor, - highlightStroke : dataset.highlightStroke || dataset.strokeColor - })); + dataset.metaData.push(new this.BarClass()); },this); - },this); - this.buildScale(data.labels); - - this.BarClass.prototype.base = this.scale.endPoint; this.eachBars(function(bar, index, datasetIndex){ helpers.extend(bar, { - width : this.scale.calculateBarWidth(this.datasets.length), - x: this.scale.calculateBarX(this.datasets.length, datasetIndex, index), - y: this.scale.endPoint + value : this.data.datasets[datasetIndex].data[index], + label : this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + strokeColor : this.data.datasets[datasetIndex].strokeColor, + fillColor : this.data.datasets[datasetIndex].fillColor, + highlightFill : this.data.datasets[datasetIndex].highlightFill || this.data.datasets[datasetIndex].fillColor, + highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor }); bar.save(); }, this); + this.buildScale(data.labels); + this.BarClass.prototype.base = this.scale.endPoint; + + this.update(); + this.render(); }, update : function(){ - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(this.data.datasets,function(dataset,datasetIndex){ - - helpers.extend(this.datasets[datasetIndex], { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - }); + //Create a new point for each piece of data + helpers.each(this.data.datasets,function(dataset,datasetIndex){ + dataset.metaData = dataset.metaData || []; helpers.each(dataset.data,function(dataPoint,index){ - helpers.extend(this.datasets[datasetIndex].bars[index], { - value : dataPoint, - label : this.data.labels[index], - datasetLabel: dataset.label, - strokeColor : dataset.strokeColor, - fillColor : dataset.fillColor, - highlightFill : dataset.highlightFill || dataset.fillColor, - highlightStroke : dataset.highlightStroke || dataset.strokeColor - }); + dataset.metaData[index] = dataset.metaData[index] || new this.BarClass(); },this); - },this); + this.eachBars(function(bar, index, datasetIndex){ + helpers.extend(bar, { + width : this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.endPoint, + value : this.data.datasets[datasetIndex].data[index], + label : this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + strokeColor : this.data.datasets[datasetIndex].strokeColor, + fillColor : this.data.datasets[datasetIndex].fillColor, + highlightFill : this.data.datasets[datasetIndex].highlightFill || this.data.datasets[datasetIndex].fillColor, + highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor + }); + bar.save(); + }, this); + this.scale.update(); - // Reset any highlight colours before updating. - helpers.each(this.activeElements, function(activeElement){ - activeElement.restore(['fillColor', 'strokeColor']); - }); - this.eachBars(function(bar){ - bar.save(); - }); this.render(); }, eachBars : function(callback){ - helpers.each(this.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.bars, callback, this, datasetIndex); + helpers.each(this.data.datasets,function(dataset, datasetIndex){ + helpers.each(dataset.metaData, callback, this, datasetIndex); },this); }, getBarsAtEvent : function(e){ @@ -190,10 +170,10 @@ }, barIndex; - for (var datasetIndex = 0; datasetIndex < this.datasets.length; datasetIndex++) { - for (barIndex = 0; barIndex < this.datasets[datasetIndex].bars.length; barIndex++) { - if (this.datasets[datasetIndex].bars[barIndex].inRange(eventPosition.x,eventPosition.y)){ - helpers.each(this.datasets, datasetIterator); + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (barIndex = 0; barIndex < this.data.datasets[datasetIndex].bars.length; barIndex++) { + if (this.data.datasets[datasetIndex].bars[barIndex].inRange(eventPosition.x,eventPosition.y)){ + helpers.each(this.data.datasets, datasetIterator); return barsArray; } } @@ -263,16 +243,16 @@ //Map the values array for each of the datasets helpers.each(valuesArray,function(value,datasetIndex){ //Add a new point for each piece of data, passing any required data to draw. - this.datasets[datasetIndex].bars.push(new this.BarClass({ + this.data.datasets[datasetIndex].bars.push(new this.BarClass({ value : value, label : label, - datasetLabel: this.datasets[datasetIndex].label, - x: this.scale.calculateBarX(this.datasets.length, datasetIndex, this.scale.valuesCount+1), + datasetLabel: this.data.datasets[datasetIndex].label, + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, this.scale.valuesCount+1), y: this.scale.endPoint, - width : this.scale.calculateBarWidth(this.datasets.length), + width : this.scale.calculateBarWidth(this.data.datasets.length), base : this.scale.endPoint, - strokeColor : this.datasets[datasetIndex].strokeColor, - fillColor : this.datasets[datasetIndex].fillColor + strokeColor : this.data.datasets[datasetIndex].strokeColor, + fillColor : this.data.datasets[datasetIndex].fillColor })); },this); @@ -283,7 +263,7 @@ removeData : function(){ this.scale.removeXLabel(); //Then re-render the chart. - helpers.each(this.datasets,function(dataset){ + helpers.each(this.data.datasets,function(dataset){ dataset.bars.shift(); },this); this.update(); @@ -308,20 +288,18 @@ this.scale.draw(easingDecimal); //Draw all the bars for each dataset - helpers.each(this.datasets,function(dataset,datasetIndex){ - helpers.each(dataset.bars,function(bar,index){ - if (bar.hasValue()){ - bar.base = this.scale.endPoint; - //Transition then draw - bar.transition({ - x : this.scale.calculateBarX(this.datasets.length, datasetIndex, index), - y : this.scale.calculateY(bar.value), - width : this.scale.calculateBarWidth(this.datasets.length) - }, easingDecimal).draw(); - } - },this); - - },this); + this.eachBars(function(bar, index, datasetIndex){ + if (bar.hasValue()){ + bar.base = this.scale.endPoint; + //Transition then draw + bar.transition({ + x : this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y : this.scale.calculateY(bar.value), + width : this.scale.calculateBarWidth(this.data.datasets.length) + }, easingDecimal).draw(); + bar.save(); + } + }, this); } }); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index d0a70336d9c..68f87df9a08 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -466,7 +466,6 @@ numberOfSteps = minSteps; stepValue = graphRange / numberOfSteps; } - return { steps : numberOfSteps, stepValue : stepValue, @@ -1021,12 +1020,12 @@ } if (ChartElements.length > 0){ // If we have multiple datasets, show a MultiTooltip for all of the data points at that index - if (this.datasets && this.datasets.length > 1) { + if (this.data.datasets && this.data.datasets.length > 1) { var dataArray, dataIndex; - for (var i = this.datasets.length - 1; i >= 0; i--) { - dataArray = this.datasets[i].points || this.datasets[i].bars || this.datasets[i].segments; + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + dataArray = this.data.datasets[i].points || this.data.datasets[i].bars || this.data.datasets[i].segments; dataIndex = indexOf(dataArray, ChartElements[0]); if (dataIndex !== -1){ break; @@ -1045,7 +1044,7 @@ yMax, xMin, yMin; - helpers.each(this.datasets, function(dataset){ + helpers.each(this.data.datasets, function(dataset){ dataCollection = dataset.points || dataset.bars || dataset.segments; if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ Elements.push(dataCollection[dataIndex]); @@ -1060,8 +1059,8 @@ //Include any colour information about the element tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element)); tooltipColors.push({ - fill: element._saved.fillColor || element.fillColor, - stroke: element._saved.strokeColor || element.strokeColor + fill: element._vm.fillColor || element.fillColor, + stroke: element._vm.strokeColor || element.strokeColor }); }, this); @@ -1182,29 +1181,29 @@ initialize : function(){}, restore : function(props){ if (!props){ - extend(this,this._saved); + extend(this,this._vm); } else { each(props,function(key){ - this[key] = this._saved[key]; + this[key] = this._vm[key]; },this); } return this; }, save : function(){ - this._saved = clone(this); - delete this._saved._saved; + this._vm = clone(this); + delete this._vm._vm; return this; }, update : function(newProps){ each(newProps,function(value,key){ - this._saved[key] = this[key]; + this._vm[key] = this[key]; this[key] = value; },this); return this; }, transition : function(props,ease){ each(props,function(value,key){ - this[key] = ((value - this._saved[key]) * ease) + this._saved[key]; + this._vm[key] = ((value - this._vm[key]) * ease) + this._vm[key]; },this); return this; }, @@ -1325,16 +1324,19 @@ Chart.Rectangle = Chart.Element.extend({ draw : function(){ + + var vm = this._vm; + var ctx = this.ctx, - halfWidth = this.width/2, - leftX = this.x - halfWidth, - rightX = this.x + halfWidth, - top = this.base - (this.base - this.y), - halfStroke = this.strokeWidth / 2; + halfWidth = vm.width/2, + leftX = vm.x - halfWidth, + rightX = vm.x + halfWidth, + top = this.base - (this.base - vm.y), + halfStroke = vm.strokeWidth / 2; // Canvas doesn't allow us to stroke inside the width so we can // adjust the sizes to fit if we're setting a stroke on the line - if (this.showStroke){ + if (vm.showStroke){ leftX += halfStroke; rightX -= halfStroke; top += halfStroke; @@ -1342,9 +1344,9 @@ ctx.beginPath(); - ctx.fillStyle = this.fillColor; - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.fillStyle = vm.fillColor; + ctx.strokeStyle = vm.strokeColor; + ctx.lineWidth = vm.strokeWidth; // It'd be nice to keep this class totally generic to any rectangle // and simply specify which border to miss out. @@ -1353,15 +1355,15 @@ ctx.lineTo(rightX, top); ctx.lineTo(rightX, this.base); ctx.fill(); - if (this.showStroke){ + if (vm.showStroke){ ctx.stroke(); } }, height : function(){ - return this.base - this.y; + return this.base - vm.y; }, inRange : function(chartX,chartY){ - return (chartX >= this.x - this.width/2 && chartX <= this.x + this.width/2) && (chartY >= this.y && chartY <= this.base); + return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= this.base); } }); From 0e29cfdfdab33f6edd504b007258c03bb24966f6 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 11 May 2015 18:12:44 -0600 Subject: [PATCH 008/424] Bar attempt #5 --- src/Chart.Bar.js | 74 ++++++++++++++++++++------------------------- src/Chart.Core.js | 77 ++++++++++++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 73 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 385131acc71..0bd7b7e6b2c 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -83,6 +83,7 @@ this.eachBars(function(bar){ bar.restore(['fillColor', 'strokeColor']); }); + helpers.each(activeBars, function(activeBar){ activeBar.fillColor = activeBar.highlightFill; activeBar.strokeColor = activeBar.highlightStroke; @@ -91,14 +92,18 @@ }); } + + //Declare the extension of the default point, to cater for the options passed in to the constructor this.BarClass = Chart.Rectangle.extend({ - strokeWidth : this.options.barStrokeWidth, - showStroke : this.options.barShowStroke, - ctx : this.chart.ctx + ctx : this.chart.ctx, + _vm: {} }); - //Create a new point for each piece of data + // Build Scale + this.buildScale(data.labels); + + //Create a new bar for each piece of data helpers.each(this.data.datasets,function(dataset,datasetIndex){ dataset.metaData = []; helpers.each(dataset.data,function(dataPoint,index){ @@ -106,54 +111,39 @@ },this); },this); - + // Set defaults for bars this.eachBars(function(bar, index, datasetIndex){ helpers.extend(bar, { - value : this.data.datasets[datasetIndex].data[index], - label : this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - strokeColor : this.data.datasets[datasetIndex].strokeColor, - fillColor : this.data.datasets[datasetIndex].fillColor, - highlightFill : this.data.datasets[datasetIndex].highlightFill || this.data.datasets[datasetIndex].fillColor, - highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor + width : this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.endPoint, }); + // Copy to view model bar.save(); }, this); - this.buildScale(data.labels); - this.BarClass.prototype.base = this.scale.endPoint; - this.update(); - - this.render(); }, update : function(){ - //Create a new point for each piece of data - helpers.each(this.data.datasets,function(dataset,datasetIndex){ - dataset.metaData = dataset.metaData || []; - helpers.each(dataset.data,function(dataPoint,index){ - dataset.metaData[index] = dataset.metaData[index] || new this.BarClass(); - },this); - },this); + this.scale.update(); this.eachBars(function(bar, index, datasetIndex){ helpers.extend(bar, { width : this.scale.calculateBarWidth(this.data.datasets.length), x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.endPoint, + y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), value : this.data.datasets[datasetIndex].data[index], label : this.data.labels[index], datasetLabel: this.data.datasets[datasetIndex].label, strokeColor : this.data.datasets[datasetIndex].strokeColor, fillColor : this.data.datasets[datasetIndex].fillColor, highlightFill : this.data.datasets[datasetIndex].highlightFill || this.data.datasets[datasetIndex].fillColor, - highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor + highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor, + _start: undefined }); - bar.save(); }, this); - this.scale.update(); this.render(); }, @@ -162,17 +152,22 @@ helpers.each(dataset.metaData, callback, this, datasetIndex); },this); }, + eachValue : function(callback){ + helpers.each(this.data.datasets,function(dataset, datasetIndex){ + helpers.each(dataset.data, callback, this, datasetIndex); + },this); + }, getBarsAtEvent : function(e){ var barsArray = [], eventPosition = helpers.getRelativePosition(e), datasetIterator = function(dataset){ - barsArray.push(dataset.bars[barIndex]); + barsArray.push(dataset.metaData[barIndex]); }, barIndex; for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (barIndex = 0; barIndex < this.data.datasets[datasetIndex].bars.length; barIndex++) { - if (this.data.datasets[datasetIndex].bars[barIndex].inRange(eventPosition.x,eventPosition.y)){ + for (barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; barIndex++) { + if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x,eventPosition.y)){ helpers.each(this.data.datasets, datasetIterator); return barsArray; } @@ -186,8 +181,8 @@ var dataTotal = function(){ var values = []; - self.eachBars(function(bar){ - values.push(bar.value); + self.eachValue(function(value){ + values.push(value); }); return values; }; @@ -280,24 +275,19 @@ this.scale.update(newScaleProps); }, draw : function(ease){ + var easingDecimal = ease || 1; this.clear(); - var ctx = this.chart.ctx; - this.scale.draw(easingDecimal); //Draw all the bars for each dataset this.eachBars(function(bar, index, datasetIndex){ if (bar.hasValue()){ + // Update the bar basepoint bar.base = this.scale.endPoint; - //Transition then draw - bar.transition({ - x : this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y : this.scale.calculateY(bar.value), - width : this.scale.calculateBarWidth(this.data.datasets.length) - }, easingDecimal).draw(); - bar.save(); + //Transition + bar.transition(['x','y','width'], easingDecimal).draw(); } }, this); } diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 68f87df9a08..bb8f3ece975 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1025,7 +1025,7 @@ dataIndex; for (var i = this.data.datasets.length - 1; i >= 0; i--) { - dataArray = this.data.datasets[i].points || this.data.datasets[i].bars || this.data.datasets[i].segments; + dataArray = this.data.datasets[i].metaData; dataIndex = indexOf(dataArray, ChartElements[0]); if (dataIndex !== -1){ break; @@ -1045,7 +1045,7 @@ xMin, yMin; helpers.each(this.data.datasets, function(dataset){ - dataCollection = dataset.points || dataset.bars || dataset.segments; + dataCollection = dataset.metaData; if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ Elements.push(dataCollection[dataIndex]); } @@ -1175,36 +1175,50 @@ Chart.Element = function(configuration){ extend(this,configuration); this.initialize.apply(this,arguments); - this.save(); }; extend(Chart.Element.prototype,{ initialize : function(){}, - restore : function(props){ - if (!props){ - extend(this,this._vm); - } else { - each(props,function(key){ - this[key] = this._vm[key]; - },this); - } - return this; - }, - save : function(){ + save: function(){ this._vm = clone(this); delete this._vm._vm; return this; }, - update : function(newProps){ - each(newProps,function(value,key){ - this._vm[key] = this[key]; - this[key] = value; - },this); - return this; - }, - transition : function(props,ease){ - each(props,function(value,key){ - this._vm[key] = ((value - this._vm[key]) * ease) + this._vm[key]; + transition : function(props, ease){ + if(!this._start){ + this._start = clone(this._vm); + } + each(this,function(value, key){ + + // Only non-vm properties + if(key === '_vm' || !this.hasOwnProperty(key)){ + return; + } + + // Init if doesn't exist + if(!this._vm[key]){ + this._vm[key] = value || null; + return; + } + + // If transition property, do transition with ease (no pun intended) + if(props.indexOf(key) > -1){ + // Color transitions if possible + if(typeof value === 'string'){ + // TODO support color transitions + return; + } + // Everything else, presumably numbers + this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; + return; + } + + // Non-transitionals + this._vm[key] = value; + },this); + if(ease === 1){ + delete this._start; + } return this; }, tooltipPosition : function(){ @@ -1331,7 +1345,7 @@ halfWidth = vm.width/2, leftX = vm.x - halfWidth, rightX = vm.x + halfWidth, - top = this.base - (this.base - vm.y), + top = vm.base - (vm.base - vm.y), halfStroke = vm.strokeWidth / 2; // Canvas doesn't allow us to stroke inside the width so we can @@ -1350,20 +1364,22 @@ // It'd be nice to keep this class totally generic to any rectangle // and simply specify which border to miss out. - ctx.moveTo(leftX, this.base); + ctx.moveTo(leftX, vm.base); ctx.lineTo(leftX, top); ctx.lineTo(rightX, top); - ctx.lineTo(rightX, this.base); + ctx.lineTo(rightX, vm.base); ctx.fill(); if (vm.showStroke){ ctx.stroke(); } }, height : function(){ - return this.base - vm.y; + var vm = this._vm; + return vm.base - vm.y; }, inRange : function(chartX,chartY){ - return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= this.base); + var vm = this._vm; + return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= vm.base); } }); @@ -2111,8 +2127,7 @@ return animationWrapper.chartInstance === chartInstance; }); - if (index) - { + if (index){ this.animations.splice(index, 1); } }, From 0eadc86d2418e425859ff9a3697a765c2abbe0e3 Mon Sep 17 00:00:00 2001 From: Derek Perkins Date: Mon, 11 May 2015 19:00:04 -0600 Subject: [PATCH 009/424] Added 2.0 alpha notes --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c4fa8bf6db..4f6cc5e063e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Chart.js -[![Build Status](https://travis-ci.org/nnnick/Chart.js.svg?branch=master)](https://travis-ci.org/nnnick/Chart.js) [![Code Climate](https://codeclimate.com/github/nnnick/Chart.js/badges/gpa.svg)](https://codeclimate.com/github/nnnick/Chart.js) +[![Build Status](https://travis-ci.org/nnnick/Chart.js.svg?branch=v2.0-dev)](https://travis-ci.org/nnnick/Chart.js) [![Code Climate](https://codeclimate.com/github/nnnick/Chart.js/badges/gpa.svg)](https://codeclimate.com/github/nnnick/Chart.js) +# Version 2.0 is in early alpha. We are changing the internal data model to reduce copying, increase performance and expose a more flexible API. *Simple HTML5 Charts using the canvas element* [chartjs.org](http://www.chartjs.org) From d287a01b44fc14a76252061821601939b53a7c41 Mon Sep 17 00:00:00 2001 From: etimberg Date: Mon, 11 May 2015 21:22:37 -0400 Subject: [PATCH 010/424] Make sure that the _start item is cleaned up during save. --- src/Chart.Core.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index bb8f3ece975..13603c88257 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1181,6 +1181,7 @@ save: function(){ this._vm = clone(this); delete this._vm._vm; + delete this._vm._start; return this; }, transition : function(props, ease){ From df91739b77b29dea65e148ecaa0fbdd762909091 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 11 May 2015 19:43:17 -0600 Subject: [PATCH 011/424] hoverMode, onHover, key fixes --- src/Chart.Bar.js | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 351698823c5..66d9e162561 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -37,6 +37,12 @@ //Number - Spacing between data sets within X values barDatasetSpacing : 1, + //String - Hover mode for events + hoverMode : 'bars', // 'bar', 'dataset' + + //Function - Custom hover handler + onHover : null, + //String - A legend template legendTemplate : "
    -legend\"><% for (var i=0; i
  • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
" @@ -77,18 +83,27 @@ //Set up tooltip events on the chart if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ - var activeBars = (evt.type !== 'mouseout') ? this.getBarsAtEvent(evt) : []; - - this.eachBars(function(bar){ - bar.restore(['fillColor', 'strokeColor']); - }); - - helpers.each(activeBars, function(activeBar){ - activeBar.fillColor = activeBar.highlightFill; - activeBar.strokeColor = activeBar.highlightStroke; - }); - this.showTooltip(activeBars); + helpers.bindEvents(this, this.options.tooltipEvents, function(e){ + var active; + if(e.type == 'mouseout'){ + return false; + } + if(this.options.hoverMode == 'bar'){ + active = this.getBarAtEvent(e); + // TODO: tooltips for single items + } + else if(this.options.hoverMode == 'bars'){ + active = this.getBarsAtEvent(e); + } + else { + // TODO: active = this.getDatasetAtEvent(e); + } + + if(this.options.onHover){ + this.options.onHover.call(this, active); + } + + this.showTooltip(active); }); } @@ -183,10 +198,10 @@ var eventPosition = helpers.getRelativePosition(e); for (var datasetIndex = 0; datasetIndex < this.datasets.length; ++datasetIndex) { - for (var barIndex = 0; barIndex < this.datasets[datasetIndex].bars.length; ++barIndex) { - if (this.datasets[datasetIndex].bars[barIndex].inRange(eventPosition.x, eventPosition.y)) { + for (var barIndex = 0; barIndex < this.datasets[datasetIndex].metaData.length; ++barIndex) { + if (this.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { bar = { - rectangle : this.datasets[datasetIndex].bars[barIndex], + rectangle : this.datasets[datasetIndex].metaData[barIndex], datasetIndex : datasetIndex, barIndex : barIndex, }; From 9e4d90e110cb2791a7e7a3263b785d7602edab98 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 12 May 2015 01:13:16 -0600 Subject: [PATCH 012/424] Color Animation, Color Autopilot --- Chart.js | 812 ++++++++++++++++++++++++++++++++++------------ Chart.min.js | 5 +- gulpfile.js | 1 + package.json | 6 +- samples/bar.html | 105 +++--- src/Chart.Bar.js | 122 ++++--- src/Chart.Core.js | 57 ++-- 7 files changed, 777 insertions(+), 331 deletions(-) diff --git a/Chart.js b/Chart.js index c264262ba73..a927adaba91 100644 --- a/Chart.js +++ b/Chart.js @@ -35,17 +35,17 @@ { return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); } - } + }; - var width = this.width = computeDimension(context.canvas,'Width'); - var height = this.height = computeDimension(context.canvas,'Height'); + var width = this.width = computeDimension(context.canvas,'Width') || context.canvas.width; + var height = this.height = computeDimension(context.canvas,'Height') || context.canvas.height; // Firefox requires this to work correctly context.canvas.width = width; context.canvas.height = height; - var width = this.width = context.canvas.width; - var height = this.height = context.canvas.height; + width = this.width = context.canvas.width; + height = this.height = context.canvas.height; this.aspectRatio = this.width / this.height; //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. helpers.retinaScale(this); @@ -59,7 +59,7 @@ animation: true, // Number - Number of animation steps - animationSteps: 60, + animationDuration: 1000, // String - Animation easing effect animationEasing: "easeOutQuart", @@ -124,7 +124,7 @@ tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], // String - Tooltip background colour - tooltipFillColor: "rgba(0,0,0,0.8)", + tooltipBackgroundColor: "rgba(0,0,0,0.8)", // String - Tooltip label font declaration for the scale label tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", @@ -210,14 +210,18 @@ clone = helpers.clone = function(obj){ var objClone = {}; each(obj,function(value,key){ - if (obj.hasOwnProperty(key)) objClone[key] = value; + if (obj.hasOwnProperty(key)){ + objClone[key] = value; + } }); return objClone; }, extend = helpers.extend = function(base){ each(Array.prototype.slice.call(arguments,1), function(extensionObject) { each(extensionObject,function(value,key){ - if (extensionObject.hasOwnProperty(key)) base[key] = value; + if (extensionObject.hasOwnProperty(key)){ + base[key] = value; + } }); }); return base; @@ -300,9 +304,9 @@ })(), warn = helpers.warn = function(str){ //Method for warning of errors - if (window.console && typeof window.console.warn == "function") console.warn(str); + if (window.console && typeof window.console.warn === "function") console.warn(str); }, - amd = helpers.amd = (typeof define == 'function' && define.amd), + amd = helpers.amd = (typeof define === 'function' && define.amd), //-- Math methods isNumber = helpers.isNumber = function(n){ return !isNaN(parseFloat(n)) && isFinite(n); @@ -328,7 +332,20 @@ }, getDecimalPlaces = helpers.getDecimalPlaces = function(num){ if (num%1!==0 && isNumber(num)){ - return num.toString().split(".")[1].length; + var s = num.toString(); + if(s.indexOf("e-") < 0){ + // no exponent, e.g. 0.01 + return s.split(".")[1].length; + } + else if(s.indexOf(".") < 0) { + // no decimal point, e.g. 1e-9 + return parseInt(s.split("e-")[1]); + } + else { + // exponent and decimal point, e.g. 1.23e-9 + var parts = s.split(".")[1].split("e-"); + return parts[0].length + parseInt(parts[1]); + } } else { return 0; @@ -449,7 +466,6 @@ numberOfSteps = minSteps; stepValue = graphRange / numberOfSteps; } - return { steps : numberOfSteps, stepValue : stepValue, @@ -505,7 +521,7 @@ /* jshint ignore:end */ generateLabels = helpers.generateLabels = function(templateString,numberOfSteps,graphMin,stepValue){ var labelsArray = new Array(numberOfSteps); - if (labelTemplateString){ + if (templateString){ each(labelsArray,function(val,index){ labelsArray[index] = template(templateString,{value: (graphMin + (stepValue*(index+1)))}); }); @@ -526,7 +542,9 @@ return -1 * t * (t - 2); }, easeInOutQuad: function (t) { - if ((t /= 1 / 2) < 1) return 1 / 2 * t * t; + if ((t /= 1 / 2) < 1){ + return 1 / 2 * t * t; + } return -1 / 2 * ((--t) * (t - 2) - 1); }, easeInCubic: function (t) { @@ -536,7 +554,9 @@ return 1 * ((t = t / 1 - 1) * t * t + 1); }, easeInOutCubic: function (t) { - if ((t /= 1 / 2) < 1) return 1 / 2 * t * t * t; + if ((t /= 1 / 2) < 1){ + return 1 / 2 * t * t * t; + } return 1 / 2 * ((t -= 2) * t * t + 2); }, easeInQuart: function (t) { @@ -546,7 +566,9 @@ return -1 * ((t = t / 1 - 1) * t * t * t - 1); }, easeInOutQuart: function (t) { - if ((t /= 1 / 2) < 1) return 1 / 2 * t * t * t * t; + if ((t /= 1 / 2) < 1){ + return 1 / 2 * t * t * t * t; + } return -1 / 2 * ((t -= 2) * t * t * t - 2); }, easeInQuint: function (t) { @@ -556,7 +578,9 @@ return 1 * ((t = t / 1 - 1) * t * t * t * t + 1); }, easeInOutQuint: function (t) { - if ((t /= 1 / 2) < 1) return 1 / 2 * t * t * t * t * t; + if ((t /= 1 / 2) < 1){ + return 1 / 2 * t * t * t * t * t; + } return 1 / 2 * ((t -= 2) * t * t * t * t + 2); }, easeInSine: function (t) { @@ -575,60 +599,95 @@ return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); }, easeInOutExpo: function (t) { - if (t === 0) return 0; - if (t === 1) return 1; - if ((t /= 1 / 2) < 1) return 1 / 2 * Math.pow(2, 10 * (t - 1)); + if (t === 0){ + return 0; + } + if (t === 1){ + return 1; + } + if ((t /= 1 / 2) < 1){ + return 1 / 2 * Math.pow(2, 10 * (t - 1)); + } return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); }, easeInCirc: function (t) { - if (t >= 1) return t; + if (t >= 1){ + return t; + } return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); }, easeOutCirc: function (t) { return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); }, easeInOutCirc: function (t) { - if ((t /= 1 / 2) < 1) return -1 / 2 * (Math.sqrt(1 - t * t) - 1); + if ((t /= 1 / 2) < 1){ + return -1 / 2 * (Math.sqrt(1 - t * t) - 1); + } return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); }, easeInElastic: function (t) { var s = 1.70158; var p = 0; var a = 1; - if (t === 0) return 0; - if ((t /= 1) == 1) return 1; - if (!p) p = 1 * 0.3; + if (t === 0){ + return 0; + } + if ((t /= 1) == 1){ + return 1; + } + if (!p){ + p = 1 * 0.3; + } if (a < Math.abs(1)) { a = 1; s = p / 4; - } else s = p / (2 * Math.PI) * Math.asin(1 / a); + } else{ + s = p / (2 * Math.PI) * Math.asin(1 / a); + } return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); }, easeOutElastic: function (t) { var s = 1.70158; var p = 0; var a = 1; - if (t === 0) return 0; - if ((t /= 1) == 1) return 1; - if (!p) p = 1 * 0.3; + if (t === 0){ + return 0; + } + if ((t /= 1) == 1){ + return 1; + } + if (!p){ + p = 1 * 0.3; + } if (a < Math.abs(1)) { a = 1; s = p / 4; - } else s = p / (2 * Math.PI) * Math.asin(1 / a); + } else{ + s = p / (2 * Math.PI) * Math.asin(1 / a); + } return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; }, easeInOutElastic: function (t) { var s = 1.70158; var p = 0; var a = 1; - if (t === 0) return 0; - if ((t /= 1 / 2) == 2) return 1; - if (!p) p = 1 * (0.3 * 1.5); + if (t === 0){ + return 0; + } + if ((t /= 1 / 2) == 2){ + return 1; + } + if (!p){ + p = 1 * (0.3 * 1.5); + } if (a < Math.abs(1)) { a = 1; s = p / 4; - } else s = p / (2 * Math.PI) * Math.asin(1 / a); - if (t < 1) return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1){ + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));} return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; }, easeInBack: function (t) { @@ -641,7 +700,9 @@ }, easeInOutBack: function (t) { var s = 1.70158; - if ((t /= 1 / 2) < 1) return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); + if ((t /= 1 / 2) < 1){ + return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); + } return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); }, easeInBounce: function (t) { @@ -659,7 +720,9 @@ } }, easeInOutBounce: function (t) { - if (t < 1 / 2) return easingEffects.easeInBounce(t * 2) * 0.5; + if (t < 1 / 2){ + return easingEffects.easeInBounce(t * 2) * 0.5; + } return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; } }, @@ -762,14 +825,21 @@ }); }, getMaximumWidth = helpers.getMaximumWidth = function(domNode){ - var container = domNode.parentNode; + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); // TODO = check cross browser stuff with this. - return container.clientWidth; + return container.clientWidth - padding; }, getMaximumHeight = helpers.getMaximumHeight = function(domNode){ - var container = domNode.parentNode; + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); // TODO = check cross browser stuff with this. - return container.clientHeight; + return container.clientHeight - padding; + }, + getStyle = helpers.getStyle = function (el, property) { + return el.currentStyle ? + el.currentStyle[property] : + document.defaultView.getComputedStyle(el, null).getPropertyValue(property); }, getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support retinaScale = helpers.retinaScale = function(chart){ @@ -844,7 +914,7 @@ }, stop : function(){ // Stops any current animation loop occuring - cancelAnimFrame(this.animationFrame); + Chart.animationService.cancelAnimation(this); return this; }, resize : function(callback){ @@ -864,19 +934,30 @@ return this; }, reflow : noop, - render : function(reflow){ + render : function(reflow, customDuration){ if (reflow){ this.reflow(); } + if (this.options.animation && !reflow){ - helpers.animationLoop( - this.draw, - this.options.animationSteps, - this.options.animationEasing, - this.options.onAnimationProgress, - this.options.onAnimationComplete, - this - ); + var animation = new Chart.Animation(); + animation.numSteps = (customDuration || this.options.animationDuration) / 16.66; //60 fps + animation.easing = this.options.animationEasing; + + // render function + animation.render = function(chartInstance, animationObject) { + var easingFunction = helpers.easingEffects[animationObject.easing]; + var stepDecimal = animationObject.currentStep / animationObject.numSteps; + var easeDecimal = easingFunction(stepDecimal); + + chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); + }; + + // user events + animation.onAnimationProgress = this.options.onAnimationProgress; + animation.onAnimationComplete = this.options.onAnimationComplete; + + Chart.animationService.addAnimation(this, animation); } else{ this.draw(); @@ -939,12 +1020,12 @@ } if (ChartElements.length > 0){ // If we have multiple datasets, show a MultiTooltip for all of the data points at that index - if (this.datasets && this.datasets.length > 1) { + if (this.data.datasets && this.data.datasets.length > 1) { var dataArray, dataIndex; - for (var i = this.datasets.length - 1; i >= 0; i--) { - dataArray = this.datasets[i].points || this.datasets[i].bars || this.datasets[i].segments; + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + dataArray = this.data.datasets[i].metaData; dataIndex = indexOf(dataArray, ChartElements[0]); if (dataIndex !== -1){ break; @@ -963,8 +1044,8 @@ yMax, xMin, yMin; - helpers.each(this.datasets, function(dataset){ - dataCollection = dataset.points || dataset.bars || dataset.segments; + helpers.each(this.data.datasets, function(dataset){ + dataCollection = dataset.metaData; if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ Elements.push(dataCollection[dataIndex]); } @@ -978,8 +1059,8 @@ //Include any colour information about the element tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element)); tooltipColors.push({ - fill: element._saved.fillColor || element.fillColor, - stroke: element._saved.strokeColor || element.strokeColor + fill: element._vm.backgroundColor || element.backgroundColor, + stroke: element._vm.borderColor || element.borderColor }); }, this); @@ -1002,7 +1083,7 @@ xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, xOffset: this.options.tooltipXOffset, - fillColor: this.options.tooltipFillColor, + backgroundColor: this.options.tooltipBackgroundColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1029,7 +1110,7 @@ y: Math.round(tooltipPosition.y), xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, - fillColor: this.options.tooltipFillColor, + backgroundColor: this.options.tooltipBackgroundColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1094,36 +1175,56 @@ Chart.Element = function(configuration){ extend(this,configuration); this.initialize.apply(this,arguments); - this.save(); }; extend(Chart.Element.prototype,{ initialize : function(){}, - restore : function(props){ - if (!props){ - extend(this,this._saved); - } else { - each(props,function(key){ - this[key] = this._saved[key]; - },this); - } - return this; - }, - save : function(){ - this._saved = clone(this); - delete this._saved._saved; - return this; - }, - update : function(newProps){ - each(newProps,function(value,key){ - this._saved[key] = this[key]; - this[key] = value; - },this); + save: function(){ + this._vm = clone(this); + delete this._vm._vm; + delete this._vm._start; return this; }, - transition : function(props,ease){ - each(props,function(value,key){ - this[key] = ((value - this._saved[key]) * ease) + this._saved[key]; + transition : function(props, ease){ + if(!this._start){ + this._start = clone(this._vm); + } + each(this,function(value, key){ + + // Only non-vm properties + if(key === '_vm' || !this.hasOwnProperty(key)){ + return; + } + + // Init if doesn't exist + if(!this._vm[key]){ + this._vm[key] = value || null; + return; + } + + // If transition property, do transition with ease (no pun intended) + if(props.indexOf(key) > -1){ + // Color transitions if possible + if(typeof value === 'string'){ + try{ + var color = Color(this._start[key]).mix(Color(this[key]), ease); + this._vm[key] = color.rgbString(); + } catch(err){ + this._vm[key] = value; + } + return; + } + // Everything else, presumably numbers + this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; + return; + } + + // Non-transitionals + this._vm[key] = value; + },this); + if(ease === 1){ + delete this._start; + } return this; }, tooltipPosition : function(){ @@ -1154,10 +1255,10 @@ ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2); ctx.closePath(); - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.strokeStyle = this.borderColor; + ctx.lineWidth = this.borderWidth; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.stroke(); @@ -1227,15 +1328,15 @@ ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); ctx.closePath(); - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.strokeStyle = this.borderColor; + ctx.lineWidth = this.borderWidth; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.lineJoin = 'bevel'; - if (this.showStroke){ + if (this.showBorder){ ctx.stroke(); } } @@ -1243,16 +1344,19 @@ Chart.Rectangle = Chart.Element.extend({ draw : function(){ + + var vm = this._vm; + var ctx = this.ctx, - halfWidth = this.width/2, - leftX = this.x - halfWidth, - rightX = this.x + halfWidth, - top = this.base - (this.base - this.y), - halfStroke = this.strokeWidth / 2; + halfWidth = vm.width/2, + leftX = vm.x - halfWidth, + rightX = vm.x + halfWidth, + top = vm.base - (vm.base - vm.y), + halfStroke = vm.borderWidth / 2; // Canvas doesn't allow us to stroke inside the width so we can // adjust the sizes to fit if we're setting a stroke on the line - if (this.showStroke){ + if (vm.borderWidth){ leftX += halfStroke; rightX -= halfStroke; top += halfStroke; @@ -1260,29 +1364,41 @@ ctx.beginPath(); - ctx.fillStyle = this.fillColor; - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; // It'd be nice to keep this class totally generic to any rectangle // and simply specify which border to miss out. - ctx.moveTo(leftX, this.base); + ctx.moveTo(leftX, vm.base); ctx.lineTo(leftX, top); ctx.lineTo(rightX, top); - ctx.lineTo(rightX, this.base); + ctx.lineTo(rightX, vm.base); ctx.fill(); - if (this.showStroke){ + if (vm.borderWidth){ ctx.stroke(); } }, height : function(){ - return this.base - this.y; + var vm = this._vm; + return vm.base - vm.y; }, inRange : function(chartX,chartY){ - return (chartX >= this.x - this.width/2 && chartX <= this.x + this.width/2) && (chartY >= this.y && chartY <= this.base); + var vm = this._vm; + return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= vm.base); } }); + Chart.Animation = Chart.Element.extend({ + currentStep: null, // the current animation step + numSteps: 60, // default number of steps + easing: "", // the easing to use for this animation + render: null, // render function used by the animation service + + onAnimationProgress: null, // user specified callback to fire on each step of the animation + onAnimationComplete: null, // user specified callback to fire when the animation finishes + }); + Chart.Tooltip = Chart.Element.extend({ draw : function(){ @@ -1314,7 +1430,7 @@ var tooltipX = this.x - tooltipWidth/2, tooltipY = this.y - tooltipHeight; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; // Custom Tooltips if(this.custom){ @@ -1422,7 +1538,7 @@ else{ drawRoundedRectangle(this.ctx,this.x,this.y - this.height/2,this.width,this.height,this.cornerRadius); var ctx = this.ctx; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.closePath(); @@ -1466,7 +1582,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); @@ -1490,6 +1606,9 @@ this.startPoint += this.padding; this.endPoint -= this.padding; + // Cache the starting endpoint, excluding the space for x labels + var cachedEndPoint = this.endPoint; + // Cache the starting height, so can determine if we need to recalculate the scale yAxis var cachedHeight = this.endPoint - this.startPoint, cachedYLabelWidth; @@ -1521,6 +1640,7 @@ // Only go through the xLabel loop again if the yLabel width has changed if (cachedYLabelWidth < this.yLabelWidth){ + this.endPoint = cachedEndPoint; this.calculateXLabelRotation(); } } @@ -1539,7 +1659,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){ @@ -1558,7 +1678,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; @@ -1984,6 +2104,93 @@ } }); + Chart.animationService = { + frameDuration: 17, + animations: [], + dropFrames: 0, + addAnimation: function(chartInstance, animationObject) { + chartInstance.animating = true; + + for (var index = 0; index < this.animations.length; ++ index){ + if (this.animations[index].chartInstance === chartInstance){ + // replacing an in progress animation + this.animations[index].animationObject = animationObject; + return; + } + } + + this.animations.push({ + chartInstance: chartInstance, + animationObject: animationObject + }); + + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (this.animations.length == 1) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + }, + // Cancel the animation for a given chart instance + cancelAnimation: function(chartInstance) { + var index = helpers.findNextWhere(this.animations, function(animationWrapper) { + return animationWrapper.chartInstance === chartInstance; + }); + + if (index){ + this.animations.splice(index, 1); + chartInstance.animating = false; + } + }, + // calls startDigest with the proper context + digestWrapper: function() { + Chart.animationService.startDigest.call(Chart.animationService); + }, + startDigest: function() { + + var startTime = Date.now(); + var framesToDrop = 0; + + if(this.dropFrames > 1){ + framesToDrop = Math.floor(this.dropFrames); + this.dropFrames -= framesToDrop; + } + + for (var i = 0; i < this.animations.length; i++) { + + if (this.animations[i].animationObject.currentStep === null){ + this.animations[i].animationObject.currentStep = 0; + } + + this.animations[i].animationObject.currentStep += 1 + framesToDrop; + if(this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps){ + this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; + } + + this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); + + if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps){ + // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; + this.animations.splice(i, 1); + // Keep the index in place to offset the splice + i--; + } + } + + var endTime = Date.now(); + var delay = endTime - startTime - this.frameDuration; + var frameDelay = delay / this.frameDuration; + + if(frameDelay > 1){ + this.dropFrames += frameDelay; + } + + // Do we have more stuff to animate? + if (this.animations.length > 0){ + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + } + }; + // Attach global event to resize each chart instance when the browser resizes helpers.addEvent(window, "resize", (function(){ // Basic debounce of resize function so it doesn't hurt performance when resizing browser. @@ -2047,11 +2254,8 @@ //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines: true, - //Boolean - If there is a stroke on each bar - barShowStroke : true, - - //Number - Pixel width of the bar stroke - barStrokeWidth : 2, + //Number - Pixel width of the bar border + barBorderWidth : 2, //Number - Spacing between each of the X value sets barValueSpacing : 5, @@ -2059,8 +2263,17 @@ //Number - Spacing between data sets within X values barDatasetSpacing : 1, + //String - Hover mode for events + hoverMode : 'bars', // 'bar', 'dataset' + + //Function - Custom hover handler + onHover : null, + + //Function - Custom hover handler + hoverDuration : 400, + //String - A legend template - legendTemplate : "
    -legend\"><% for (var i=0; i
  • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
" + legendTemplate : "
    -legend\"><% for (var i=0; i
  • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
" }; @@ -2070,6 +2283,9 @@ defaults : defaultConfig, initialize: function(data){ + // Save data as a source for updating of values & methods + this.data = data; + //Expose options as a scope variable here so we can access it in the ScaleClass var options = this.options; @@ -2094,102 +2310,144 @@ } }); - this.datasets = []; - //Set up tooltip events on the chart if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ - var activeBars = (evt.type !== 'mouseout') ? this.getBarsAtEvent(evt) : []; - - this.eachBars(function(bar){ - bar.restore(['fillColor', 'strokeColor']); - }); - helpers.each(activeBars, function(activeBar){ - activeBar.fillColor = activeBar.highlightFill; - activeBar.strokeColor = activeBar.highlightStroke; - }); - this.showTooltip(activeBars); - }); + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); } + + //Declare the extension of the default point, to cater for the options passed in to the constructor this.BarClass = Chart.Rectangle.extend({ - strokeWidth : this.options.barStrokeWidth, - showStroke : this.options.barShowStroke, - ctx : this.chart.ctx + ctx : this.chart.ctx, + _vm: {} }); - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(data.datasets,function(dataset,datasetIndex){ - - var datasetObject = { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - bars : [] - }; - - this.datasets.push(datasetObject); + // Build Scale + this.buildScale(data.labels); + //Create a new bar for each piece of data + helpers.each(this.data.datasets,function(dataset,datasetIndex){ + dataset.metaData = []; helpers.each(dataset.data,function(dataPoint,index){ - //Add a new point for each piece of data, passing any required data to draw. - datasetObject.bars.push(new this.BarClass({ - value : dataPoint, - label : data.labels[index], - datasetLabel: dataset.label, - strokeColor : dataset.strokeColor, - fillColor : dataset.fillColor, - highlightFill : dataset.highlightFill || dataset.fillColor, - highlightStroke : dataset.highlightStroke || dataset.strokeColor - })); + dataset.metaData.push(new this.BarClass()); },this); - },this); - this.buildScale(data.labels); - - this.BarClass.prototype.base = this.scale.endPoint; - + // Set defaults for bars this.eachBars(function(bar, index, datasetIndex){ helpers.extend(bar, { - width : this.scale.calculateBarWidth(this.datasets.length), - x: this.scale.calculateBarX(this.datasets.length, datasetIndex, index), - y: this.scale.endPoint + width : this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.endPoint, }); + // Copy to view model bar.save(); }, this); - this.render(); + this.update(); + }, + onHover: function(e){ + + var active; + if(e.type == 'mouseout'){ + return false; + } + if(this.options.hoverMode == 'bar'){ + active = this.getBarAtEvent(e); + } + else if(this.options.hoverMode == 'bars'){} + + + // Remove styling for last active + if(this.lastActive){ + if(this.options.hoverMode == 'bar'){ + this.lastActive.rectangle.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; + this.lastActive.rectangle.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; + this.lastActive.rectangle.borderWidth = 0; + } + else if(this.options.hoverMode == 'bars'){} + } + + // Custom Hover actions + if(this.options.onHover){ + this.options.onHover.call(this, active); + } + else if(active){ + // or default hover action + if(this.options.hoverMode == 'bar'){ + active.rectangle.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || Color(active.rectangle.backgroundColor).saturate(0.5).darken(0.25).rgbString(); + active.rectangle.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || Color(active.rectangle.borderColor).saturate(0.5).darken(0.25).rgbString(); + } + else if(this.options.hoverMode == 'bars'){} + + } + + if(!this.animating){ + // If entering + if(!this.lastActive && active){ + this.render(false, this.options.hoverDuration); + } + + // If different bar + if(this.lastActive && active && this.lastActive.rectangle !== active.rectangle){ + this.render(false, this.options.hoverDuration); + } + + // if Leaving + if (this.lastActive && !active){ + this.render(false, this.options.hoverDuration); + } + } + + this.lastActive = active; + + //this.showTooltip(active); }, update : function(){ + this.scale.update(); - // Reset any highlight colours before updating. - helpers.each(this.activeElements, function(activeElement){ - activeElement.restore(['fillColor', 'strokeColor']); - }); - this.eachBars(function(bar){ - bar.save(); - }); + this.eachBars(function(bar, index, datasetIndex){ + helpers.extend(bar, { + width : this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), + value : this.data.datasets[datasetIndex].data[index], + label : this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + borderColor : this.data.datasets[datasetIndex].borderColor, + borderWidth : this.data.datasets[datasetIndex].borderWidth, + backgroundColor : this.data.datasets[datasetIndex].backgroundColor, + _start: undefined + }); + }, this); + + this.render(); }, eachBars : function(callback){ - helpers.each(this.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.bars, callback, this, datasetIndex); + helpers.each(this.data.datasets,function(dataset, datasetIndex){ + helpers.each(dataset.metaData, callback, this, datasetIndex); + },this); + }, + eachValue : function(callback){ + helpers.each(this.data.datasets,function(dataset, datasetIndex){ + helpers.each(dataset.data, callback, this, datasetIndex); },this); }, getBarsAtEvent : function(e){ var barsArray = [], eventPosition = helpers.getRelativePosition(e), datasetIterator = function(dataset){ - barsArray.push(dataset.bars[barIndex]); + barsArray.push(dataset.metaData[barIndex]); }, barIndex; - for (var datasetIndex = 0; datasetIndex < this.datasets.length; datasetIndex++) { - for (barIndex = 0; barIndex < this.datasets[datasetIndex].bars.length; barIndex++) { - if (this.datasets[datasetIndex].bars[barIndex].inRange(eventPosition.x,eventPosition.y)){ - helpers.each(this.datasets, datasetIterator); + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; barIndex++) { + if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x,eventPosition.y)){ + helpers.each(this.data.datasets, datasetIterator); return barsArray; } } @@ -2197,13 +2455,34 @@ return barsArray; }, + // Get the single bar that was clicked on + // @return : An object containing the dataset index and bar index of the matching bar. Also contains the rectangle that was drawn + getBarAtEvent : function(e) { + var bar; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; ++barIndex) { + if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { + bar = { + rectangle : this.data.datasets[datasetIndex].metaData[barIndex], + datasetIndex : datasetIndex, + barIndex : barIndex, + }; + return bar; + } + } + } + + return bar; + }, buildScale : function(labels){ var self = this; var dataTotal = function(){ var values = []; - self.eachBars(function(bar){ - values.push(bar.value); + self.eachValue(function(value){ + values.push(value); }); return values; }; @@ -2238,7 +2517,7 @@ showVerticalLines : this.options.scaleShowVerticalLines, 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, + padding : (this.options.showScale) ? 0 : this.options.borderWidth, showLabels : this.options.scaleShowLabels, display : this.options.showScale }; @@ -2259,15 +2538,16 @@ //Map the values array for each of the datasets helpers.each(valuesArray,function(value,datasetIndex){ //Add a new point for each piece of data, passing any required data to draw. - this.datasets[datasetIndex].bars.push(new this.BarClass({ + this.data.datasets[datasetIndex].bars.push(new this.BarClass({ value : value, label : label, - x: this.scale.calculateBarX(this.datasets.length, datasetIndex, this.scale.valuesCount+1), + datasetLabel: this.data.datasets[datasetIndex].label, + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, this.scale.valuesCount+1), y: this.scale.endPoint, - width : this.scale.calculateBarWidth(this.datasets.length), + width : this.scale.calculateBarWidth(this.data.datasets.length), base : this.scale.endPoint, - strokeColor : this.datasets[datasetIndex].strokeColor, - fillColor : this.datasets[datasetIndex].fillColor + borderColor : this.data.datasets[datasetIndex].borderColor, + backgroundColor : this.data.datasets[datasetIndex].backgroundColor })); },this); @@ -2278,7 +2558,7 @@ removeData : function(){ this.scale.removeXLabel(); //Then re-render the chart. - helpers.each(this.datasets,function(dataset){ + helpers.each(this.data.datasets,function(dataset){ dataset.bars.shift(); },this); this.update(); @@ -2295,28 +2575,28 @@ this.scale.update(newScaleProps); }, draw : function(ease){ + var easingDecimal = ease || 1; this.clear(); - var ctx = this.chart.ctx; - this.scale.draw(easingDecimal); //Draw all the bars for each dataset - helpers.each(this.datasets,function(dataset,datasetIndex){ - helpers.each(dataset.bars,function(bar,index){ - if (bar.hasValue()){ - bar.base = this.scale.endPoint; - //Transition then draw - bar.transition({ - x : this.scale.calculateBarX(this.datasets.length, datasetIndex, index), - y : this.scale.calculateY(bar.value), - width : this.scale.calculateBarWidth(this.datasets.length) - }, easingDecimal).draw(); - } - },this); - - },this); + this.eachBars(function(bar, index, datasetIndex){ + if (bar.hasValue()){ + // Update the bar basepoint + bar.base = this.scale.endPoint; + //Transition + bar.transition([ + 'x', + 'y', + 'width', + 'backgroundColor', + 'borderColor', + 'borderWidth' + ], easingDecimal).draw(); + } + }, this); } }); @@ -2361,7 +2641,6 @@ }; - Chart.Type.extend({ //Passing in a name registers this chart in the Chart namespace name: "Doughnut", @@ -2371,6 +2650,9 @@ //Config is automatically merged by the core of Chart.js, and is available at this.options initialize: function(data){ + // Save data as a source for updating of values & methods + this.data = data; + //Declare segments as a static property to prevent inheriting across the Chart type prototype this.segments = []; this.outerRadius = (helpers.min([this.chart.width,this.chart.height]) - this.options.segmentStrokeWidth/2)/2; @@ -2398,6 +2680,9 @@ this.calculateTotal(data); helpers.each(data,function(datapoint, index){ + if (!datapoint.color) { + datapoint.color = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; + } this.addData(datapoint, index, true); },this); @@ -2433,8 +2718,12 @@ this.update(); } }, - calculateCircumference : function(value){ - return (Math.PI*2)*(Math.abs(value) / this.total); + calculateCircumference : function(value) { + if ( this.total > 0 ) { + return (Math.PI*2)*(value / this.total); + } else { + return 0; + } }, calculateTotal : function(data){ this.total = 0; @@ -2443,6 +2732,25 @@ },this); }, update : function(){ + + // Map new data to data points + if(this.data.length == this.segments.length){ + helpers.each(this.data, function(segment, i){ + helpers.extend(this.segments[i], { + value : segment.value, + fillColor : segment.color, + highlightColor : segment.highlight || segment.color, + showStroke : this.options.segmentShowStroke, + strokeWidth : this.options.segmentStrokeWidth, + strokeColor : this.options.segmentStrokeColor, + label : segment.label + }); + }, this); + } else{ + // Data size changed without properly inserting, just redraw the chart + this.initialize(this.data); + } + this.calculateTotal(this.segments); // Reset any highlight colours before updating. @@ -2507,6 +2815,7 @@ }); }).call(this); + (function(){ "use strict"; @@ -2559,7 +2868,10 @@ datasetFill : true, //String - A legend template - legendTemplate : "
    -legend\"><% for (var i=0; i
  • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
" + legendTemplate : "
    -legend\"><% for (var i=0; i
  • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
", + + //Boolean - Whether to horizontally center the label and point dot inside the grid + offsetGridLines : false }; @@ -2568,8 +2880,12 @@ name: "Line", defaults : defaultConfig, initialize: function(data){ + // Save data as a source for updating of values & methods + this.data = data; + //Declare the extension of the default point, to cater for the options passed in to the constructor this.PointClass = Chart.Point.extend({ + offsetGridLines : this.options.offsetGridLines, strokeWidth : this.options.pointDotStrokeWidth, radius : this.options.pointDotRadius, display: this.options.pointDot, @@ -2642,6 +2958,31 @@ this.render(); }, update : function(){ + //Iterate through each of the datasets, and build this into a property of the chart + helpers.each(this.data.datasets,function(dataset,datasetIndex){ + + helpers.extend(this.datasets[datasetIndex], { + label : dataset.label || null, + fillColor : dataset.fillColor, + strokeColor : dataset.strokeColor, + pointColor : dataset.pointColor, + pointStrokeColor : dataset.pointStrokeColor, + }); + + helpers.each(dataset.data,function(dataPoint,index){ + helpers.extend(this.datasets[datasetIndex].points[index], { + value : dataPoint, + label : this.data.labels[index], + datasetLabel: dataset.label, + strokeColor : dataset.pointStrokeColor, + fillColor : dataset.pointColor, + highlightFill : dataset.pointHighlightFill || dataset.pointColor, + highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor + }); + },this); + + },this); + this.scale.update(); // Reset any highlight colours before updating. helpers.each(this.activeElements, function(activeElement){ @@ -2685,6 +3026,7 @@ width : this.chart.width, ctx : this.chart.ctx, textColor : this.options.scaleFontColor, + offsetGridLines : this.options.offsetGridLines, fontSize : this.options.scaleFontSize, fontStyle : this.options.scaleFontStyle, fontFamily : this.options.scaleFontFamily, @@ -2735,6 +3077,7 @@ this.datasets[datasetIndex].points.push(new this.PointClass({ value : value, label : label, + datasetLabel: this.datasets[datasetIndex].label, x: this.scale.calculateX(this.scale.valuesCount+1), y: this.scale.endPoint, strokeColor : this.datasets[datasetIndex].pointStrokeColor, @@ -2912,7 +3255,7 @@ //Boolean - Stroke a line around each segment in the chart segmentShowStroke : true, - //String - The colour of the stroke on each segement. + //String - The colour of the stroke on each segment. segmentStrokeColor : "#fff", //Number - The width of the stroke value in pixels @@ -2943,6 +3286,9 @@ //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){ + // Save data as a source for updating of values & methods + this.data = data; + this.segments = []; //Declare segment class as a chart instance specific class, so it can share props for this instance this.SegmentArc = Chart.Arc.extend({ @@ -3074,6 +3420,22 @@ }, update : function(){ + + // Map new data to data points + if(this.data.length == this.segments.length){ + helpers.each(this.data, function(segment, i){ + helpers.extend(this.segments[i], { + fillColor: segment.color, + highlightColor: segment.highlight || segment.color, + label: segment.label, + value: segment.value, + }); + },this); + } else{ + // Data size changed without properly inserting, just redraw the chart + this.initialize(this.data); + } + this.calculateTotal(this.segments); helpers.each(this.segments,function(segment){ @@ -3132,6 +3494,7 @@ }); }).call(this); + (function(){ "use strict"; @@ -3201,6 +3564,9 @@ }, initialize: function(data){ + // Save data as a source for updating of values & methods + this.data = data; + this.PointClass = Chart.Point.extend({ strokeWidth : this.options.pointDotStrokeWidth, radius : this.options.pointDotRadius, @@ -3379,6 +3745,7 @@ this.datasets[datasetIndex].points.push(new this.PointClass({ value : value, label : label, + datasetLabel: this.datasets[datasetIndex].label, x: pointPosition.x, y: pointPosition.y, strokeColor : this.datasets[datasetIndex].pointStrokeColor, @@ -3402,6 +3769,31 @@ this.update(); }, update : function(){ + //Iterate through each of the datasets, and build this into a property of the chart + helpers.each(this.data.datasets,function(dataset,datasetIndex){ + + helpers.extend(this.datasets[datasetIndex], { + label : dataset.label || null, + fillColor : dataset.fillColor, + strokeColor : dataset.strokeColor, + pointColor : dataset.pointColor, + pointStrokeColor : dataset.pointStrokeColor, + }); + + helpers.each(dataset.data,function(dataPoint,index){ + helpers.extend(this.datasets[datasetIndex].points[index], { + value : dataPoint, + label : this.data.labels[index], + datasetLabel: dataset.label, + strokeColor : dataset.pointStrokeColor, + fillColor : dataset.pointColor, + highlightFill : dataset.pointHighlightFill || dataset.pointColor, + highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor + }); + },this); + + },this); + this.eachPoints(function(point){ point.save(); }); @@ -3474,4 +3866,6 @@ -}).call(this); \ No newline at end of file +}).call(this); + +!function e(r,t,n){function a(i,u){if(!t[i]){if(!r[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(s)return s(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var o=t[i]={exports:{}};r[i][0].call(o.exports,function(e){var t=r[i][1][e];return a(t?t:e)},o,o.exports,e,r,t,n)}return t[i].exports}for(var s="function"==typeof require&&require,i=0;i=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*r[0]+.7152*r[1]+.0722*r[2]},contrast:function(e){var r=this.luminosity(),t=e.luminosity();return r>t?(r+.05)/(t+.05):(t+.05)/(r+.05)},level:function(e){var r=this.contrast(e);return r>=7.1?"AAA":r>=4.5?"AA":""},dark:function(){var e=this.values.rgb,r=(299*e[0]+587*e[1]+114*e[2])/1e3;return 128>r},light:function(){return!this.dark()},negate:function(){for(var e=[],r=0;3>r;r++)e[r]=255-this.values.rgb[r];return this.setValues("rgb",e),this},lighten:function(e){return this.values.hsl[2]+=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},darken:function(e){return this.values.hsl[2]-=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},saturate:function(e){return this.values.hsl[1]+=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},desaturate:function(e){return this.values.hsl[1]-=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},whiten:function(e){return this.values.hwb[1]+=this.values.hwb[1]*e,this.setValues("hwb",this.values.hwb),this},blacken:function(e){return this.values.hwb[2]+=this.values.hwb[2]*e,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var e=this.values.rgb,r=.3*e[0]+.59*e[1]+.11*e[2];return this.setValues("rgb",[r,r,r]),this},clearer:function(e){return this.setValues("alpha",this.values.alpha-this.values.alpha*e),this},opaquer:function(e){return this.setValues("alpha",this.values.alpha+this.values.alpha*e),this},rotate:function(e){var r=this.values.hsl[0];return r=(r+e)%360,r=0>r?360+r:r,this.values.hsl[0]=r,this.setValues("hsl",this.values.hsl),this},mix:function(e,r){r=1-(null==r?.5:r);for(var t=2*r-1,n=this.alpha()-e.alpha(),a=((t*n==-1?t:(t+n)/(1+t*n))+1)/2,s=1-a,i=this.rgbArray(),u=e.rgbArray(),l=0;lr&&(r+=360),n=(u+l)/2,t=l==u?0:.5>=n?h/(l+u):h/(2-l-u),[r,100*t,100*n]}function s(e){var r,t,n,a=e[0],s=e[1],i=e[2],u=Math.min(a,s,i),l=Math.max(a,s,i),h=l-u;return t=0==l?0:h/l*1e3/10,l==u?r=0:a==l?r=(s-i)/h:s==l?r=2+(i-a)/h:i==l&&(r=4+(a-s)/h),r=Math.min(60*r,360),0>r&&(r+=360),n=l/255*1e3/10,[r,t,n]}function i(e){var r=e[0],t=e[1],n=e[2],s=a(e)[0],i=1/255*Math.min(r,Math.min(t,n)),n=1-1/255*Math.max(r,Math.max(t,n));return[s,100*i,100*n]}function u(e){var r,t,n,a,s=e[0]/255,i=e[1]/255,u=e[2]/255;return a=Math.min(1-s,1-i,1-u),r=(1-s-a)/(1-a)||0,t=(1-i-a)/(1-a)||0,n=(1-u-a)/(1-a)||0,[100*r,100*t,100*n,100*a]}function l(e){return X[JSON.stringify(e)]}function h(e){var r=e[0]/255,t=e[1]/255,n=e[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*r+.3576*t+.1805*n,s=.2126*r+.7152*t+.0722*n,i=.0193*r+.1192*t+.9505*n;return[100*a,100*s,100*i]}function o(e){var r,t,n,a=h(e),s=a[0],i=a[1],u=a[2];return s/=95.047,i/=100,u/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,r=116*i-16,t=500*(s-i),n=200*(i-u),[r,t,n]}function c(e){return J(o(e))}function v(e){var r,t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100;if(0==u)return s=255*l,[s,s,s];t=.5>l?l*(1+u):l+u-l*u,r=2*l-t,a=[0,0,0];for(var h=0;3>h;h++)n=i+1/3*-(h-1),0>n&&n++,n>1&&n--,s=1>6*n?r+6*(t-r)*n:1>2*n?t:2>3*n?r+(t-r)*(2/3-n)*6:r,a[h]=255*s;return a}function f(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return s*=2,a*=1>=s?s:2-s,t=(s+a)/2,r=2*a/(s+a),[n,100*r,100*t]}function d(e){return i(v(e))}function p(e){return u(v(e))}function m(e){return l(v(e))}function y(e){var r=e[0]/60,t=e[1]/100,n=e[2]/100,a=Math.floor(r)%6,s=r-Math.floor(r),i=255*n*(1-t),u=255*n*(1-t*s),l=255*n*(1-t*(1-s)),n=255*n;switch(a){case 0:return[n,l,i];case 1:return[u,n,i];case 2:return[i,n,l];case 3:return[i,u,n];case 4:return[l,i,n];case 5:return[n,i,u]}}function w(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return t=(2-a)*s,r=a*s,r/=1>=t?t:2-t,r=r||0,t/=2,[n,100*r,100*t]}function k(e){return i(y(e))}function M(e){return u(y(e))}function S(e){return l(y(e))}function x(e){var t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100,h=u+l;switch(h>1&&(u/=h,l/=h),t=Math.floor(6*i),n=1-l,a=6*i-t,0!=(1&t)&&(a=1-a),s=u+a*(n-u),t){default:case 6:case 0:r=n,g=s,b=u;break;case 1:r=s,g=n,b=u;break;case 2:r=u,g=n,b=s;break;case 3:r=u,g=s,b=n;break;case 4:r=s,g=u,b=n;break;case 5:r=n,g=u,b=s}return[255*r,255*g,255*b]}function V(e){return a(x(e))}function q(e){return s(x(e))}function A(e){return u(x(e))}function C(e){return l(x(e))}function F(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100,u=e[3]/100;return r=1-Math.min(1,a*(1-u)+u),t=1-Math.min(1,s*(1-u)+u),n=1-Math.min(1,i*(1-u)+u),[255*r,255*t,255*n]}function N(e){return a(F(e))}function z(e){return s(F(e))}function I(e){return i(F(e))}function O(e){return l(F(e))}function E(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100;return r=3.2406*a+-1.5372*s+i*-.4986,t=a*-.9689+1.8758*s+.0415*i,n=.0557*a+s*-.204+1.057*i,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=12.92*r,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:t=12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,r=Math.min(Math.max(0,r),1),t=Math.min(Math.max(0,t),1),n=Math.min(Math.max(0,n),1),[255*r,255*t,255*n]}function H(e){var r,t,n,a=e[0],s=e[1],i=e[2];return a/=95.047,s/=100,i/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,r=116*s-16,t=500*(a-s),n=200*(s-i),[r,t,n]}function U(e){return J(H(e))}function j(e){var r,t,n,a,s=e[0],i=e[1],u=e[2];return 8>=s?(t=100*s/903.3,a=7.787*(t/100)+16/116):(t=100*Math.pow((s+16)/116,3),a=Math.pow(t/100,1/3)),r=.008856>=r/95.047?r=95.047*(i/500+a-16/116)/7.787:95.047*Math.pow(i/500+a,3),n=.008859>=n/108.883?n=108.883*(a-u/200-16/116)/7.787:108.883*Math.pow(a-u/200,3),[r,t,n]}function J(e){var r,t,n,a=e[0],s=e[1],i=e[2];return r=Math.atan2(i,s),t=360*r/2/Math.PI,0>t&&(t+=360),n=Math.sqrt(s*s+i*i),[a,n,t]}function R(e){return E(j(e))}function $(e){var r,t,n,a=e[0],s=e[1],i=e[2];return n=i/360*2*Math.PI,r=s*Math.cos(n),t=s*Math.sin(n),[a,r,t]}function D(e){return j($(e))}function P(e){return R($(e))}function _(e){return W[e]}function L(e){return a(_(e))}function T(e){return s(_(e))}function B(e){return i(_(e))}function G(e){return u(_(e))}function K(e){return o(_(e))}function Q(e){return h(_(e))}t.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:i,rgb2cmyk:u,rgb2keyword:l,rgb2xyz:h,rgb2lab:o,rgb2lch:c,hsl2rgb:v,hsl2hsv:f,hsl2hwb:d,hsl2cmyk:p,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:k,hsv2cmyk:M,hsv2keyword:S,hwb2rgb:x,hwb2hsl:V,hwb2hsv:q,hwb2cmyk:A,hwb2keyword:C,cmyk2rgb:F,cmyk2hsl:N,cmyk2hsv:z,cmyk2hwb:I,cmyk2keyword:O,keyword2rgb:_,keyword2hsl:L,keyword2hsv:T,keyword2hwb:B,keyword2cmyk:G,keyword2lab:K,keyword2xyz:Q,xyz2rgb:E,xyz2lab:H,xyz2lch:U,lab2xyz:j,lab2rgb:R,lab2lch:J,lch2lab:$,lch2xyz:D,lch2rgb:P};var W={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},X={};for(var Y in W)X[JSON.stringify(W[Y])]=Y},{}],3:[function(e,r,t){var n=e("./conversions"),a=function(){return new h};for(var s in n){a[s+"Raw"]=function(e){return function(r){return"number"==typeof r&&(r=Array.prototype.slice.call(arguments)),n[e](r)}}(s);var i=/(\w+)2(\w+)/.exec(s),u=i[1],l=i[2];a[u]=a[u]||{},a[u][l]=a[s]=function(e){return function(r){"number"==typeof r&&(r=Array.prototype.slice.call(arguments));var t=n[e](r);if("string"==typeof t||void 0===t)return t;for(var a=0;ar||e[3]&&e[3]<1?c(e,r):"rgb("+e[0]+", "+e[1]+", "+e[2]+")"}function c(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+r+")"}function g(e,r){if(1>r||e[3]&&e[3]<1)return v(e,r);var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgb("+t+"%, "+n+"%, "+a+"%)"}function v(e,r){var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgba("+t+"%, "+n+"%, "+a+"%, "+(r||e[3]||1)+")"}function f(e,r){return 1>r||e[3]&&e[3]<1?d(e,r):"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)"}function d(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+r+")"}function b(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+(void 0!==r&&1!==r?", "+r:"")+")"}function p(e){return k[e.slice(0,3)]}function m(e,r,t){return Math.min(Math.max(r,e),t)}function y(e){var r=e.toString(16).toUpperCase();return r.length<2?"0"+r:r}var w=e("color-name");r.exports={getRgba:n,getHsla:a,getRgb:i,getHsl:u,getHwb:s,getAlpha:l,hexString:h,rgbString:o,rgbaString:c,percentString:g,percentaString:v,hslString:f,hslaString:d,hwbString:b,keyword:p};var k={};for(var M in w)k[w[M]]=M},{"color-name":5}],5:[function(e,r,t){r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/Chart.min.js b/Chart.min.js index 3a0a2c87345..c04f23bdf69 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,5 +7,6 @@ * 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;var i=function(t,i){return t["offset"+i]?t["offset"+i]:document.defaultView.getComputedStyle(t).getPropertyValue(i)},e=this.width=i(t.canvas,"Width"),n=this.height=i(t.canvas,"Height");t.canvas.width=e,t.canvas.height=n;var e=this.width=t.canvas.width,n=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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,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=0;s--){var n=t[s];if(i(n))return n}},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 define&&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}),y=(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)}),C=(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=y(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}if(t instanceof Function)return t(i);var s={};return e(t,i)}),w=(s.generateLabels=function(t,i,e,s){var o=new Array(i);return labelTemplateString&&n(o,function(i,n){o[n]=C(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),st?-.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-w.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*w.easeInBounce(2*t):.5*w.easeOutBounce(2*t-1)+.5}}),b=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)}}(),L=(s.animationLoop=function(t,i,e,s,n,o){var a=0,h=w[e]||w.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=b(l):n.apply(o)};b(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}),k=s.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=c},F=(s.bindEvents=function(t,i,e){t.events||(t.events={}),n(i,function(i){t.events[i]=function(){e.apply(t,arguments)},L(t.chart.canvas,i,t.events[i])})},s.unbindEvents=function(t,i){n(i,function(i,e){k(t.chart.canvas,e,i)})}),R=s.getMaximumWidth=function(t){var i=t.parentNode;return i.clientWidth},T=s.getMaximumHeight=function(t){var i=t.parentNode;return i.clientHeight},A=(s.getMaximumSize=s.getMaximumWidth,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))}),M=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,i,e){return i+" "+t+"px "+e},z=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},B=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 M(this.chart),this},stop:function(){return P(this.animationFrame),this},resize:function(t){this.stop();var i=this.chart.canvas,e=R(this.chart.canvas),s=this.options.maintainAspectRatio?e/this.chart.aspectRatio:T(this.chart.canvas);return i.width=this.chart.width=e,i.height=this.chart.height=s,A(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 C(this.options.legendTemplate,this)},destroy:function(){this.clear(),F(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),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(),this.options.customTooltips&&this.options.customTooltips(!1),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,t[h]&&t[h].hasValue()&&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,custom:this.options.customTooltips}).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:C(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).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}},hasValue:function(){return f(this.value)}}),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)=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=W(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var i=this.caretPadding=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;if(t.fillStyle=this.fillColor,this.custom)this.custom(this);else{switch(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)}B(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=W(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=W(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=z(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(){if(this.custom)this.custom(this);else{B(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(C(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?z(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(),tthis.yLabelWidth+10?e/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,o=z(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/Math.max(this.valuesCount-(this.offsetGridLines?0:1),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),l=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,e-10,a),0!==o||l||(l=!0),l&&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),l&&(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,a=this.showVerticalLines;0!==e||a||(a=!0),a&&t.beginPath(),e>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),a&&(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(C(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=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),i=0;ip&&(p=t.x+s,n=i),t.x-sp&&(p=t.x+e,n=i):i>this.valuesCount/2&&t.x-e0){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=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=W(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,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'
    <% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
'};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(e,n){s.bars.push(new this.BarClass({value:e,label:t.labels[n],datasetLabel:i.label,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<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};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*(Math.abs(t)/this.total)},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=Math.abs(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<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'};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)0&&ithis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(h[h.length-1].x,this.scale.endPoint),s.lineTo(h[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),e.each(h,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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};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.reflow(),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<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},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(e,n){var o;this.scale.animation||(o=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(e))),s.points.push(new this.PointClass({value:e,label:t.labels[n],datasetLabel:i.label,x:this.options.animation?this.scale.xCenter:o.x,y:this.options.animation?this.scale.yCenter:o.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,e){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[e].points.push(new this.PointClass({value:t,label:i,x:s.x,y:s.y,strokeColor:this.datasets[e].pointStrokeColor,fillColor:this.datasets[e].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.reflow(),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.hasValue()&&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.hasValue()&&t.draw()})},this)}})}.call(this); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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(){}}},i.types={};var s=i.helpers={},n=s.each=function(t,e,i){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(e(n))return n}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},s=function(){this.constructor=i};return s.prototype=e.prototype,i.prototype=new s,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),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 define&&define.amd,g=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=s.max=function(t){return Math.max.apply(Math,t)},v=s.min=function(t){return Math.min.apply(Math,t)},m=(s.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=s.radians=function(t){return t*(Math.PI/180)},y=(s.getAngleFromPoint=function(t,e){var i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s),a=2*Math.PI+Math.atan2(s,i);return 0>i&&0>s&&(a+=2*Math.PI),{angle:a,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),w=(s.splineCurve=function(t,e,i,s){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=s*n/(n+a),r=s*a/(n+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(s.calculateScaleRange=function(t,e,i,s,n){var a=2,o=Math.floor(e/(1.5*i)),r=a>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!s?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=a,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},s.template=function(t,e){function i(t,e){var i=/\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 e?i(e):i}if(t instanceof Function)return t(e);var s={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,s){var a=new Array(e);return t&&n(a,function(e,n){a[n]=S(t,{value:i+s*(n+1)})}),a},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 e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),st?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(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,e,i,s,n,a){var o=0,r=x[i]||x.linear,h=function(){o++;var i=o/e,l=r(i);t.call(a,l,i,o),s.call(a,l,i),e>o?a.animationFrame=C(h):n.apply(a)};C(h)},s.getRelativePosition=function(t){var e,i,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,a=n.getBoundingClientRect();return s.touches?(e=s.touches[0].clientX-a.left,i=s.touches[0].clientY-a.top):(e=s.clientX-a.left,i=s.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(s.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),M=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-left"))+parseInt(F(e,"padding-right"));return e.clientWidth-i},A=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-bottom"))+parseInt(F(e,"padding-top"));return e.clientHeight-i},F=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=s+"px",e.canvas.height=s*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),T=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},z=s.longestText=function(t,e,i){t.font=e;var s=0;return n(i,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},O=s.drawRoundedRectangle=function(t,e,i,s,n,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+s-a,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+n-a),t.quadraticCurveTo(e+s,i+n,e+s-a,i+n),t.lineTo(e+a,i+n),t.quadraticCurveTo(e,i+n,e,i+n-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};i.instances={},i.Type=function(t,e,s){this.options=e,this.chart=s,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return T(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=M(this.chart.canvas),s=this.options.maintainAspectRatio?i/this.chart.aspectRatio:A(this.chart.canvas);return e.width=this.chart.width=i,e.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,e){if(t&&this.reflow(),this.options.animation&&!t){var n=new i.Animation;n.numSteps=(e||this.options.animationDuration)/16.66,n.easing=this.options.animationEasing,n.render=function(t,e){var i=s.easingEffects[e.easing],n=e.currentStep/e.numSteps,a=i(n);t.draw(a,n,e.currentStep)},n.onAnimationProgress=this.options.onAnimationProgress,n.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,n)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},showTooltip:function(t,e){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var a=function(t){var e=!1;return t.length!==this.activeElements.length?e=!0:(n(t,function(t,i){t!==this.activeElements[i]&&(e=!0)},this),e)}.call(this,t);if(a||e){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.data.datasets&&this.data.datasets.length>1){for(var o,r,l=this.data.datasets.length-1;l>=0&&(o=this.data.datasets[l].metaData,r=h(o,t[0]),-1===r);l--);var c=[],u=[],d=function(t){var e,i,n,a,o,h=[],l=[],d=[];return s.each(this.data.datasets,function(t){e=t.metaData,e[r]&&e[r].hasValue()&&h.push(e[r])}),s.each(h,function(t){l.push(t.x),d.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._vm.backgroundColor||t.backgroundColor,stroke:t._vm.borderColor||t.borderColor})},this),o=v(d),n=f(d),a=v(l),i=f(l),{x:a>this.chart.width/2?a:i,y:(o+n)/2}}.call(this,r);new i.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,backgroundColor:this.options.tooltipBackgroundColor,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,custom:this.options.customTooltips}).draw()}else n(t,function(t){var e=t.tooltipPosition();new i.Tooltip({x:Math.round(e.x),y:Math.round(e.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,backgroundColor:this.options.tooltipBackgroundColor,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:S(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,s=function(){return e.apply(this,arguments)};if(s.prototype=a(e.prototype),o(s.prototype,t),s.extend=i.Type.extend,t.name||e.prototype.name){var n=t.name||e.prototype.name,h=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[n]=o(h,t.defaults),i.types[n]=s,i.prototype[n]=function(t,e){var a=r(i.defaults.global,i.defaults[n],e||{});return new s(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},transition:function(t,e){return this._start||(this._start=a(this._vm)),n(this,function(i,s){if("_vm"!==s&&this.hasOwnProperty(s)){if(!this._vm[s])return void(this._vm[s]=i||null);if(t.indexOf(s)>-1){if("string"==typeof i){try{var n=Color(this._start[s]).mix(Color(this[s]),e);this._vm[s]=n.rgbString()}catch(a){this._vm[s]=i}return}return void(this._vm[s]=(this[s]-this._start[s])*e+this._start[s])}this._vm[s]=i}},this),1===e&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return g(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.borderColor,e.lineWidth=this.borderWidth,e.fillStyle=this.backgroundColor,e.fill(),e.lineJoin="bevel",this.showBorder&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,s=t.x-i,n=t.x+i,a=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(s+=o,n-=o,a+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(s,t.base),e.lineTo(s,a),e.lineTo(n,a),e.lineTo(n,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base}}),i.Animation=i.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),i.Tooltip=i.Element.extend({draw:function(){var t=this.chart.ctx;t.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var e=this.caretPadding=2,i=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+e;this.x+i/2>this.chart.width?this.xAlign="left":this.x-i/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var a=this.x-i/2,o=this.y-n;if(t.fillStyle=this.backgroundColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-e),t.lineTo(this.x+this.caretHeight,this.y-(e+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(e+this.caretHeight)),t.closePath(),t.fill();break;case"below":o=this.y+e+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+e),t.lineTo(this.x+this.caretHeight,this.y+e+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+e+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":a=this.x-i+(this.cornerRadius+this.caretHeight);break;case"right":a=this.x-(this.cornerRadius+this.caretHeight)}O(t,a,o,i,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,a+i/2,o+s/2)}}}),i.MultiTooltip=i.Element.extend({initialize:function(){this.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=W(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,e=z(this.ctx,this.font,this.labels)+this.fontSize+3,i=f([e,t]);this.width=i+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 e=this.y-this.height/2+this.yPadding,i=t-1;return 0===t?e+this.titleFontSize/2:e+(1.5*this.fontSize*i+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{O(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.backgroundColor,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(e,i){t.fillStyle=this.textColor,t.fillText(e,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(i+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[i].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?z(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,a=z(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*s,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=i/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,a){var o=this.endPoint-e*a,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==a||h||(h=!0),h&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=s.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var s=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,s,n,a,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+s,n=e),t.x-sp&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var s,n=i*(this.drawingArea/this.steps),a=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e){t.animating=!0;for(var i=0;i1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var n=Date.now(),a=n-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"bars",onHover:null,hoverDuration:400,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:s,initialize:function(t){this.data=t;var s=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return a+o*e+e*s.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return e/t}}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx,_vm:{}}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.endPoint}),t.save()},this),this.update()},onHover:function(t){var e;return"mouseout"==t.type?!1:("bar"==this.options.hoverMode?e=this.getBarAtEvent(t):"bars"==this.options.hoverMode,this.lastActive&&("bar"==this.options.hoverMode?(this.lastActive.rectangle.backgroundColor=this.data.datasets[this.lastActive.datasetIndex].backgroundColor,this.lastActive.rectangle.borderColor=this.data.datasets[this.lastActive.datasetIndex].borderColor, +this.lastActive.rectangle.borderWidth=0):"bars"==this.options.hoverMode),this.options.onHover?this.options.onHover.call(this,e):e&&("bar"==this.options.hoverMode?(e.rectangle.backgroundColor=this.data.datasets[e.datasetIndex].hoverBackgroundColor||Color(e.rectangle.backgroundColor).saturate(.5).darken(.25).rgbString(),e.rectangle.borderColor=this.data.datasets[e.datasetIndex].hoverBorderColor||Color(e.rectangle.borderColor).saturate(.5).darken(.25).rgbString()):"bars"==this.options.hoverMode),this.animating||(!this.lastActive&&e&&this.render(!1,this.options.hoverDuration),this.lastActive&&e&&this.lastActive.rectangle!==e.rectangle&&this.render(!1,this.options.hoverDuration),this.lastActive&&!e&&this.render(!1,this.options.hoverDuration)),void(this.lastActive=e))},update:function(){this.scale.update(),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.calculateY(this.data.datasets[s].data[e]),value:this.data.datasets[s].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[s].label,borderColor:this.data.datasets[s].borderColor,borderWidth:this.data.datasets[s].borderWidth,backgroundColor:this.data.datasets[s].backgroundColor,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,s){i.each(e.metaData,t,this,s)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,s){i.each(e.data,t,this,s)},this)},getBarsAtEvent:function(t){for(var e,s=[],n=i.getRelativePosition(t),a=function(t){s.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:s,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(r[r.length-1].x,this.scale.endPoint),s.lineTo(r[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),i.each(r,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var s={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(s),i.each(e.data,function(i,n){var a;this.scale.animation||(a=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),s.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),s=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,a=Math.round((s.angle-1.5*Math.PI)/n),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),s.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:s.x,y:s.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(s,n){i.extend(this.datasets[e].points[n],{value:s,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),i.each(t.points,function(t,e){0===e?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,s){function n(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,s)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=s?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,s=this.alpha()-t.alpha(),n=((i*s==-1?i:(i+s)/(1+i*s))+1)/2,a=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),s=(r+h)/2,i=h==r?0:.5>=s?l/(h+r):l/(2-h-r),[e,100*i,100*s]}function n(t){var e,i,s,n=t[0],a=t[1],o=t[2],r=Math.min(n,a,o),h=Math.max(n,a,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(a-o)/l:a==h?e=2+(o-n)/l:o==h&&(e=4+(n-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=h/255*1e3/10,[e,i,s]}function a(t){var e=t[0],i=t[1],n=t[2],a=s(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[a,100*o,100*n]}function o(t){var e,i,s,n,a=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-a,1-o,1-r),e=(1-a-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,s=(1-r-n)/(1-n)||0,[100*e,100*i,100*s,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,s=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var n=.4124*e+.3576*i+.1805*s,a=.2126*e+.7152*i+.0722*s,o=.0193*e+.1192*i+.9505*s;return[100*n,100*a,100*o]}function c(t){var e,i,s,n=l(t),a=n[0],o=n[1],r=n[2];return a/=95.047,o/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(a-o),s=200*(o-r),[e,i,s]}function u(t){return V(c(t))}function d(t){var e,i,s,n,a,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)s=o+1/3*-(l-1),0>s&&s++,s>1&&s--,a=1>6*s?e+6*(i-e)*s:1>2*s?i:2>3*s?e+(i-e)*(2/3-s)*6:e,n[l]=255*a;return n}function p(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return a*=2,n*=1>=a?a:2-a,i=(a+n)/2,e=2*n/(a+n),[s,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,a=e-Math.floor(e),o=255*s*(1-i),r=255*s*(1-i*a),h=255*s*(1-i*(1-a)),s=255*s;switch(n){case 0:return[s,h,o];case 1:return[r,s,o];case 2:return[o,s,h];case 3:return[o,r,s];case 4:return[h,o,s];case 5:return[s,o,r]}}function w(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return i=(2-n)*a,e=n*a,e/=1>=i?i:2-i,e=e||0,i/=2,[s,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,s,n,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,s=6*a-e,0!=(1&e)&&(s=1-s),n=o+s*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return s(k(t))}function L(t){return n(k(t))}function M(t){return o(k(t))}function A(t){return h(k(t))}function F(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),s=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*s]}function R(t){return s(F(t))}function T(t){return n(F(t))}function W(t){return a(F(t))}function z(t){return h(F(t))}function O(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*a+o*-.4986,i=n*-.9689+1.8758*a+.0415*o,s=.0557*n+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=12.92*s,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*e,255*i,255*s]}function I(t){var e,i,s,n=t[0],a=t[1],o=t[2];return n/=95.047,a/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(n-a),s=200*(a-o),[e,i,s]}function B(t){return V(I(t))}function E(t){var e,i,s,n,a=t[0],o=t[1],r=t[2];return 8>=a?(i=100*a/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),s=.008859>=s/108.883?s=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,s]}function V(t){var e,i,s,n=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),s=Math.sqrt(a*a+o*o),[n,s,i]}function D(t){return O(E(t))}function H(t){var e,i,s,n=t[0],a=t[1],o=t[2];return s=o/360*2*Math.PI,e=a*Math.cos(s),i=a*Math.sin(s),[n,e,i]}function q(t){return E(H(t))}function X(t){return D(H(t))}function _(t){return U[t]}function Y(t){return s(_(t))}function N(t){return n(_(t))}function j(t){return a(_(t))}function G(t){return o(_(t))}function Z(t){return c(_(t))}function Q(t){return l(_(t))}e.exports={rgb2hsl:s,rgb2hsv:n,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:M,hwb2keyword:A,cmyk2rgb:F,cmyk2hsl:R,cmyk2hsv:T,cmyk2hwb:W,cmyk2keyword:z,keyword2rgb:_,keyword2hsl:Y,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:O,xyz2lab:I,xyz2lch:B,lab2xyz:E,lab2rgb:D,lab2lch:V,lch2lab:H,lch2xyz:q,lch2rgb:X};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var s=t("./conversions"),n=function(){return new l};for(var a in s){n[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),s[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=s[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+s+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+s+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:s,getHsla:n,getRgb:o,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 29fa13bf08b..f1e71472cb1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -35,6 +35,7 @@ gulp.task('build', function(){ // So we can use this to sort out dependency order - aka include Core first! srcFiles.push(srcDir+'*'); } + srcFiles.push('./node_modules/color/dist/color.min.js'); return gulp.src(srcFiles) .pipe(concat('Chart.js')) diff --git a/package.json b/package.json index 9ac4a0e71b7..37f1d7f772b 100644 --- a/package.json +++ b/package.json @@ -10,19 +10,21 @@ }, "dependences": {}, "devDependencies": { + "color": "file:../../../../var/folders/rv/vd7mrb5j0hnbrr_2f3q2p6m00000gn/T/npm-53789-2bfe35a6/git-cache-40335d988a8e/54fd04acedef6ccdc54a9929be298945a8093496", "gulp": "3.5.x", "gulp-concat": "~2.1.x", "gulp-connect": "~2.0.5", + "gulp-html-validator": "^0.0.2", "gulp-jshint": "~1.5.1", "gulp-replace": "^0.4.0", "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", + "onecolor": "^2.5.0", "semver": "^3.0.1" }, "spm": { "main": "Chart.js" } -} \ No newline at end of file +} diff --git a/samples/bar.html b/samples/bar.html index 5146660b818..493bd99655a 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -1,59 +1,56 @@ - - Bar Chart - - - - -
    - -
    - - - + + + + +
    + +
    + + + - - diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 66d9e162561..1a6ec688fbc 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -25,11 +25,8 @@ //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines: true, - //Boolean - If there is a stroke on each bar - barShowStroke : true, - - //Number - Pixel width of the bar stroke - barStrokeWidth : 2, + //Number - Pixel width of the bar border + barBorderWidth : 2, //Number - Spacing between each of the X value sets barValueSpacing : 5, @@ -43,8 +40,11 @@ //Function - Custom hover handler onHover : null, + //Function - Custom hover handler + hoverDuration : 400, + //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " }; @@ -83,28 +83,7 @@ //Set up tooltip events on the chart if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(e){ - var active; - if(e.type == 'mouseout'){ - return false; - } - if(this.options.hoverMode == 'bar'){ - active = this.getBarAtEvent(e); - // TODO: tooltips for single items - } - else if(this.options.hoverMode == 'bars'){ - active = this.getBarsAtEvent(e); - } - else { - // TODO: active = this.getDatasetAtEvent(e); - } - - if(this.options.onHover){ - this.options.onHover.call(this, active); - } - - this.showTooltip(active); - }); + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); } @@ -139,6 +118,63 @@ this.update(); }, + onHover: function(e){ + + var active; + if(e.type == 'mouseout'){ + return false; + } + if(this.options.hoverMode == 'bar'){ + active = this.getBarAtEvent(e); + } + else if(this.options.hoverMode == 'bars'){} + + + // Remove styling for last active + if(this.lastActive){ + if(this.options.hoverMode == 'bar'){ + this.lastActive.rectangle.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; + this.lastActive.rectangle.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; + this.lastActive.rectangle.borderWidth = 0; + } + else if(this.options.hoverMode == 'bars'){} + } + + // Custom Hover actions + if(this.options.onHover){ + this.options.onHover.call(this, active); + } + else if(active){ + // or default hover action + if(this.options.hoverMode == 'bar'){ + active.rectangle.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || Color(active.rectangle.backgroundColor).saturate(0.5).darken(0.25).rgbString(); + active.rectangle.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || Color(active.rectangle.borderColor).saturate(0.5).darken(0.25).rgbString(); + } + else if(this.options.hoverMode == 'bars'){} + + } + + if(!this.animating){ + // If entering + if(!this.lastActive && active){ + this.render(false, this.options.hoverDuration); + } + + // If different bar + if(this.lastActive && active && this.lastActive.rectangle !== active.rectangle){ + this.render(false, this.options.hoverDuration); + } + + // if Leaving + if (this.lastActive && !active){ + this.render(false, this.options.hoverDuration); + } + } + + this.lastActive = active; + + //this.showTooltip(active); + }, update : function(){ this.scale.update(); @@ -151,10 +187,9 @@ value : this.data.datasets[datasetIndex].data[index], label : this.data.labels[index], datasetLabel: this.data.datasets[datasetIndex].label, - strokeColor : this.data.datasets[datasetIndex].strokeColor, - fillColor : this.data.datasets[datasetIndex].fillColor, - highlightFill : this.data.datasets[datasetIndex].highlightFill || this.data.datasets[datasetIndex].fillColor, - highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor, + borderColor : this.data.datasets[datasetIndex].borderColor, + borderWidth : this.data.datasets[datasetIndex].borderWidth, + backgroundColor : this.data.datasets[datasetIndex].backgroundColor, _start: undefined }); }, this); @@ -197,11 +232,11 @@ var bar; var eventPosition = helpers.getRelativePosition(e); - for (var datasetIndex = 0; datasetIndex < this.datasets.length; ++datasetIndex) { - for (var barIndex = 0; barIndex < this.datasets[datasetIndex].metaData.length; ++barIndex) { - if (this.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; ++barIndex) { + if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { bar = { - rectangle : this.datasets[datasetIndex].metaData[barIndex], + rectangle : this.data.datasets[datasetIndex].metaData[barIndex], datasetIndex : datasetIndex, barIndex : barIndex, }; @@ -253,7 +288,7 @@ showVerticalLines : this.options.scaleShowVerticalLines, 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, + padding : (this.options.showScale) ? 0 : this.options.borderWidth, showLabels : this.options.scaleShowLabels, display : this.options.showScale }; @@ -282,8 +317,8 @@ y: this.scale.endPoint, width : this.scale.calculateBarWidth(this.data.datasets.length), base : this.scale.endPoint, - strokeColor : this.data.datasets[datasetIndex].strokeColor, - fillColor : this.data.datasets[datasetIndex].fillColor + borderColor : this.data.datasets[datasetIndex].borderColor, + backgroundColor : this.data.datasets[datasetIndex].backgroundColor })); },this); @@ -323,7 +358,14 @@ // Update the bar basepoint bar.base = this.scale.endPoint; //Transition - bar.transition(['x','y','width'], easingDecimal).draw(); + bar.transition([ + 'x', + 'y', + 'width', + 'backgroundColor', + 'borderColor', + 'borderWidth' + ], easingDecimal).draw(); } }, this); } diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 13603c88257..7c051683d9b 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -59,7 +59,7 @@ animation: true, // Number - Number of animation steps - animationSteps: 60, + animationDuration: 1000, // String - Animation easing effect animationEasing: "easeOutQuart", @@ -124,7 +124,7 @@ tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], // String - Tooltip background colour - tooltipFillColor: "rgba(0,0,0,0.8)", + tooltipBackgroundColor: "rgba(0,0,0,0.8)", // String - Tooltip label font declaration for the scale label tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", @@ -934,14 +934,14 @@ return this; }, reflow : noop, - render : function(reflow){ + render : function(reflow, customDuration){ if (reflow){ this.reflow(); } if (this.options.animation && !reflow){ var animation = new Chart.Animation(); - animation.numSteps = this.options.animationSteps; + animation.numSteps = (customDuration || this.options.animationDuration) / 16.66; //60 fps animation.easing = this.options.animationEasing; // render function @@ -1059,8 +1059,8 @@ //Include any colour information about the element tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element)); tooltipColors.push({ - fill: element._vm.fillColor || element.fillColor, - stroke: element._vm.strokeColor || element.strokeColor + fill: element._vm.backgroundColor || element.backgroundColor, + stroke: element._vm.borderColor || element.borderColor }); }, this); @@ -1083,7 +1083,7 @@ xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, xOffset: this.options.tooltipXOffset, - fillColor: this.options.tooltipFillColor, + backgroundColor: this.options.tooltipBackgroundColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1110,7 +1110,7 @@ y: Math.round(tooltipPosition.y), xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, - fillColor: this.options.tooltipFillColor, + backgroundColor: this.options.tooltipBackgroundColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1205,7 +1205,12 @@ if(props.indexOf(key) > -1){ // Color transitions if possible if(typeof value === 'string'){ - // TODO support color transitions + try{ + var color = Color(this._start[key]).mix(Color(this[key]), ease); + this._vm[key] = color.rgbString(); + } catch(err){ + this._vm[key] = value; + } return; } // Everything else, presumably numbers @@ -1250,10 +1255,10 @@ ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2); ctx.closePath(); - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.strokeStyle = this.borderColor; + ctx.lineWidth = this.borderWidth; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.stroke(); @@ -1323,15 +1328,15 @@ ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); ctx.closePath(); - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.strokeStyle = this.borderColor; + ctx.lineWidth = this.borderWidth; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.lineJoin = 'bevel'; - if (this.showStroke){ + if (this.showBorder){ ctx.stroke(); } } @@ -1347,11 +1352,11 @@ leftX = vm.x - halfWidth, rightX = vm.x + halfWidth, top = vm.base - (vm.base - vm.y), - halfStroke = vm.strokeWidth / 2; + halfStroke = vm.borderWidth / 2; // Canvas doesn't allow us to stroke inside the width so we can // adjust the sizes to fit if we're setting a stroke on the line - if (vm.showStroke){ + if (vm.borderWidth){ leftX += halfStroke; rightX -= halfStroke; top += halfStroke; @@ -1359,9 +1364,9 @@ ctx.beginPath(); - ctx.fillStyle = vm.fillColor; - ctx.strokeStyle = vm.strokeColor; - ctx.lineWidth = vm.strokeWidth; + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; // It'd be nice to keep this class totally generic to any rectangle // and simply specify which border to miss out. @@ -1370,7 +1375,7 @@ ctx.lineTo(rightX, top); ctx.lineTo(rightX, vm.base); ctx.fill(); - if (vm.showStroke){ + if (vm.borderWidth){ ctx.stroke(); } }, @@ -1425,7 +1430,7 @@ var tooltipX = this.x - tooltipWidth/2, tooltipY = this.y - tooltipHeight; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; // Custom Tooltips if(this.custom){ @@ -1533,7 +1538,7 @@ else{ drawRoundedRectangle(this.ctx,this.x,this.y - this.height/2,this.width,this.height,this.cornerRadius); var ctx = this.ctx; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.closePath(); @@ -2104,6 +2109,8 @@ animations: [], dropFrames: 0, addAnimation: function(chartInstance, animationObject) { + chartInstance.animating = true; + for (var index = 0; index < this.animations.length; ++ index){ if (this.animations[index].chartInstance === chartInstance){ // replacing an in progress animation @@ -2130,6 +2137,7 @@ if (index){ this.animations.splice(index, 1); + chartInstance.animating = false; } }, // calls startDigest with the proper context @@ -2161,6 +2169,7 @@ if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps){ // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; this.animations.splice(i, 1); // Keep the index in place to offset the splice i--; From 132272d1400291cf47b5bf624c0909b1c0de6bd5 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 12 May 2015 01:18:37 -0600 Subject: [PATCH 013/424] Revert build files This reverts built files --- Chart.js | 179 ++++++++++++++++++--------------------------------- Chart.min.js | 6 +- 2 files changed, 67 insertions(+), 118 deletions(-) diff --git a/Chart.js b/Chart.js index a927adaba91..4388f852154 100644 --- a/Chart.js +++ b/Chart.js @@ -59,7 +59,7 @@ animation: true, // Number - Number of animation steps - animationDuration: 1000, + animationSteps: 60, // String - Animation easing effect animationEasing: "easeOutQuart", @@ -124,7 +124,7 @@ tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], // String - Tooltip background colour - tooltipBackgroundColor: "rgba(0,0,0,0.8)", + tooltipFillColor: "rgba(0,0,0,0.8)", // String - Tooltip label font declaration for the scale label tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", @@ -934,14 +934,14 @@ return this; }, reflow : noop, - render : function(reflow, customDuration){ + render : function(reflow){ if (reflow){ this.reflow(); } if (this.options.animation && !reflow){ var animation = new Chart.Animation(); - animation.numSteps = (customDuration || this.options.animationDuration) / 16.66; //60 fps + animation.numSteps = this.options.animationSteps; animation.easing = this.options.animationEasing; // render function @@ -1059,8 +1059,8 @@ //Include any colour information about the element tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element)); tooltipColors.push({ - fill: element._vm.backgroundColor || element.backgroundColor, - stroke: element._vm.borderColor || element.borderColor + fill: element._vm.fillColor || element.fillColor, + stroke: element._vm.strokeColor || element.strokeColor }); }, this); @@ -1083,7 +1083,7 @@ xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, xOffset: this.options.tooltipXOffset, - backgroundColor: this.options.tooltipBackgroundColor, + fillColor: this.options.tooltipFillColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1110,7 +1110,7 @@ y: Math.round(tooltipPosition.y), xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, - backgroundColor: this.options.tooltipBackgroundColor, + fillColor: this.options.tooltipFillColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1205,12 +1205,7 @@ if(props.indexOf(key) > -1){ // Color transitions if possible if(typeof value === 'string'){ - try{ - var color = Color(this._start[key]).mix(Color(this[key]), ease); - this._vm[key] = color.rgbString(); - } catch(err){ - this._vm[key] = value; - } + // TODO support color transitions return; } // Everything else, presumably numbers @@ -1255,10 +1250,10 @@ ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2); ctx.closePath(); - ctx.strokeStyle = this.borderColor; - ctx.lineWidth = this.borderWidth; + ctx.strokeStyle = this.strokeColor; + ctx.lineWidth = this.strokeWidth; - ctx.fillStyle = this.backgroundColor; + ctx.fillStyle = this.fillColor; ctx.fill(); ctx.stroke(); @@ -1328,15 +1323,15 @@ ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); ctx.closePath(); - ctx.strokeStyle = this.borderColor; - ctx.lineWidth = this.borderWidth; + ctx.strokeStyle = this.strokeColor; + ctx.lineWidth = this.strokeWidth; - ctx.fillStyle = this.backgroundColor; + ctx.fillStyle = this.fillColor; ctx.fill(); ctx.lineJoin = 'bevel'; - if (this.showBorder){ + if (this.showStroke){ ctx.stroke(); } } @@ -1352,11 +1347,11 @@ leftX = vm.x - halfWidth, rightX = vm.x + halfWidth, top = vm.base - (vm.base - vm.y), - halfStroke = vm.borderWidth / 2; + halfStroke = vm.strokeWidth / 2; // Canvas doesn't allow us to stroke inside the width so we can // adjust the sizes to fit if we're setting a stroke on the line - if (vm.borderWidth){ + if (vm.showStroke){ leftX += halfStroke; rightX -= halfStroke; top += halfStroke; @@ -1364,9 +1359,9 @@ ctx.beginPath(); - ctx.fillStyle = vm.backgroundColor; - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; + ctx.fillStyle = vm.fillColor; + ctx.strokeStyle = vm.strokeColor; + ctx.lineWidth = vm.strokeWidth; // It'd be nice to keep this class totally generic to any rectangle // and simply specify which border to miss out. @@ -1375,7 +1370,7 @@ ctx.lineTo(rightX, top); ctx.lineTo(rightX, vm.base); ctx.fill(); - if (vm.borderWidth){ + if (vm.showStroke){ ctx.stroke(); } }, @@ -1430,7 +1425,7 @@ var tooltipX = this.x - tooltipWidth/2, tooltipY = this.y - tooltipHeight; - ctx.fillStyle = this.backgroundColor; + ctx.fillStyle = this.fillColor; // Custom Tooltips if(this.custom){ @@ -1538,7 +1533,7 @@ else{ drawRoundedRectangle(this.ctx,this.x,this.y - this.height/2,this.width,this.height,this.cornerRadius); var ctx = this.ctx; - ctx.fillStyle = this.backgroundColor; + ctx.fillStyle = this.fillColor; ctx.fill(); ctx.closePath(); @@ -2109,8 +2104,6 @@ animations: [], dropFrames: 0, addAnimation: function(chartInstance, animationObject) { - chartInstance.animating = true; - for (var index = 0; index < this.animations.length; ++ index){ if (this.animations[index].chartInstance === chartInstance){ // replacing an in progress animation @@ -2137,7 +2130,6 @@ if (index){ this.animations.splice(index, 1); - chartInstance.animating = false; } }, // calls startDigest with the proper context @@ -2169,7 +2161,6 @@ if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps){ // executed the last frame. Remove the animation. - this.animations[i].chartInstance.animating = false; this.animations.splice(i, 1); // Keep the index in place to offset the splice i--; @@ -2254,8 +2245,11 @@ //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines: true, - //Number - Pixel width of the bar border - barBorderWidth : 2, + //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, @@ -2269,11 +2263,8 @@ //Function - Custom hover handler onHover : null, - //Function - Custom hover handler - hoverDuration : 400, - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " }; @@ -2312,7 +2303,28 @@ //Set up tooltip events on the chart if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + helpers.bindEvents(this, this.options.tooltipEvents, function(e){ + var active; + if(e.type == 'mouseout'){ + return false; + } + if(this.options.hoverMode == 'bar'){ + active = this.getBarAtEvent(e); + // TODO: tooltips for single items + } + else if(this.options.hoverMode == 'bars'){ + active = this.getBarsAtEvent(e); + } + else { + // TODO: active = this.getDatasetAtEvent(e); + } + + if(this.options.onHover){ + this.options.onHover.call(this, active); + } + + this.showTooltip(active); + }); } @@ -2347,63 +2359,6 @@ this.update(); }, - onHover: function(e){ - - var active; - if(e.type == 'mouseout'){ - return false; - } - if(this.options.hoverMode == 'bar'){ - active = this.getBarAtEvent(e); - } - else if(this.options.hoverMode == 'bars'){} - - - // Remove styling for last active - if(this.lastActive){ - if(this.options.hoverMode == 'bar'){ - this.lastActive.rectangle.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; - this.lastActive.rectangle.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; - this.lastActive.rectangle.borderWidth = 0; - } - else if(this.options.hoverMode == 'bars'){} - } - - // Custom Hover actions - if(this.options.onHover){ - this.options.onHover.call(this, active); - } - else if(active){ - // or default hover action - if(this.options.hoverMode == 'bar'){ - active.rectangle.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || Color(active.rectangle.backgroundColor).saturate(0.5).darken(0.25).rgbString(); - active.rectangle.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || Color(active.rectangle.borderColor).saturate(0.5).darken(0.25).rgbString(); - } - else if(this.options.hoverMode == 'bars'){} - - } - - if(!this.animating){ - // If entering - if(!this.lastActive && active){ - this.render(false, this.options.hoverDuration); - } - - // If different bar - if(this.lastActive && active && this.lastActive.rectangle !== active.rectangle){ - this.render(false, this.options.hoverDuration); - } - - // if Leaving - if (this.lastActive && !active){ - this.render(false, this.options.hoverDuration); - } - } - - this.lastActive = active; - - //this.showTooltip(active); - }, update : function(){ this.scale.update(); @@ -2416,9 +2371,10 @@ value : this.data.datasets[datasetIndex].data[index], label : this.data.labels[index], datasetLabel: this.data.datasets[datasetIndex].label, - borderColor : this.data.datasets[datasetIndex].borderColor, - borderWidth : this.data.datasets[datasetIndex].borderWidth, - backgroundColor : this.data.datasets[datasetIndex].backgroundColor, + strokeColor : this.data.datasets[datasetIndex].strokeColor, + fillColor : this.data.datasets[datasetIndex].fillColor, + highlightFill : this.data.datasets[datasetIndex].highlightFill || this.data.datasets[datasetIndex].fillColor, + highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor, _start: undefined }); }, this); @@ -2461,11 +2417,11 @@ var bar; var eventPosition = helpers.getRelativePosition(e); - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; ++barIndex) { - if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { + for (var datasetIndex = 0; datasetIndex < this.datasets.length; ++datasetIndex) { + for (var barIndex = 0; barIndex < this.datasets[datasetIndex].metaData.length; ++barIndex) { + if (this.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { bar = { - rectangle : this.data.datasets[datasetIndex].metaData[barIndex], + rectangle : this.datasets[datasetIndex].metaData[barIndex], datasetIndex : datasetIndex, barIndex : barIndex, }; @@ -2517,7 +2473,7 @@ showVerticalLines : this.options.scaleShowVerticalLines, 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.borderWidth, + padding : (this.options.showScale) ? 0 : (this.options.barShowStroke) ? this.options.barStrokeWidth : 0, showLabels : this.options.scaleShowLabels, display : this.options.showScale }; @@ -2546,8 +2502,8 @@ y: this.scale.endPoint, width : this.scale.calculateBarWidth(this.data.datasets.length), base : this.scale.endPoint, - borderColor : this.data.datasets[datasetIndex].borderColor, - backgroundColor : this.data.datasets[datasetIndex].backgroundColor + strokeColor : this.data.datasets[datasetIndex].strokeColor, + fillColor : this.data.datasets[datasetIndex].fillColor })); },this); @@ -2587,14 +2543,7 @@ // Update the bar basepoint bar.base = this.scale.endPoint; //Transition - bar.transition([ - 'x', - 'y', - 'width', - 'backgroundColor', - 'borderColor', - 'borderWidth' - ], easingDecimal).draw(); + bar.transition(['x','y','width'], easingDecimal).draw(); } }, this); } diff --git a/Chart.min.js b/Chart.min.js index c04f23bdf69..345a0a11322 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,6 +7,6 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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(){}}},i.types={};var s=i.helpers={},n=s.each=function(t,e,i){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(e(n))return n}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},s=function(){this.constructor=i};return s.prototype=e.prototype,i.prototype=new s,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),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 define&&define.amd,g=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=s.max=function(t){return Math.max.apply(Math,t)},v=s.min=function(t){return Math.min.apply(Math,t)},m=(s.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=s.radians=function(t){return t*(Math.PI/180)},y=(s.getAngleFromPoint=function(t,e){var i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s),a=2*Math.PI+Math.atan2(s,i);return 0>i&&0>s&&(a+=2*Math.PI),{angle:a,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),w=(s.splineCurve=function(t,e,i,s){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=s*n/(n+a),r=s*a/(n+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(s.calculateScaleRange=function(t,e,i,s,n){var a=2,o=Math.floor(e/(1.5*i)),r=a>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!s?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=a,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},s.template=function(t,e){function i(t,e){var i=/\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 e?i(e):i}if(t instanceof Function)return t(e);var s={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,s){var a=new Array(e);return t&&n(a,function(e,n){a[n]=S(t,{value:i+s*(n+1)})}),a},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 e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),st?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(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,e,i,s,n,a){var o=0,r=x[i]||x.linear,h=function(){o++;var i=o/e,l=r(i);t.call(a,l,i,o),s.call(a,l,i),e>o?a.animationFrame=C(h):n.apply(a)};C(h)},s.getRelativePosition=function(t){var e,i,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,a=n.getBoundingClientRect();return s.touches?(e=s.touches[0].clientX-a.left,i=s.touches[0].clientY-a.top):(e=s.clientX-a.left,i=s.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(s.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),M=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-left"))+parseInt(F(e,"padding-right"));return e.clientWidth-i},A=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-bottom"))+parseInt(F(e,"padding-top"));return e.clientHeight-i},F=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=s+"px",e.canvas.height=s*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),T=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},z=s.longestText=function(t,e,i){t.font=e;var s=0;return n(i,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},O=s.drawRoundedRectangle=function(t,e,i,s,n,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+s-a,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+n-a),t.quadraticCurveTo(e+s,i+n,e+s-a,i+n),t.lineTo(e+a,i+n),t.quadraticCurveTo(e,i+n,e,i+n-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};i.instances={},i.Type=function(t,e,s){this.options=e,this.chart=s,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return T(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=M(this.chart.canvas),s=this.options.maintainAspectRatio?i/this.chart.aspectRatio:A(this.chart.canvas);return e.width=this.chart.width=i,e.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,e){if(t&&this.reflow(),this.options.animation&&!t){var n=new i.Animation;n.numSteps=(e||this.options.animationDuration)/16.66,n.easing=this.options.animationEasing,n.render=function(t,e){var i=s.easingEffects[e.easing],n=e.currentStep/e.numSteps,a=i(n);t.draw(a,n,e.currentStep)},n.onAnimationProgress=this.options.onAnimationProgress,n.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,n)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},showTooltip:function(t,e){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var a=function(t){var e=!1;return t.length!==this.activeElements.length?e=!0:(n(t,function(t,i){t!==this.activeElements[i]&&(e=!0)},this),e)}.call(this,t);if(a||e){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.data.datasets&&this.data.datasets.length>1){for(var o,r,l=this.data.datasets.length-1;l>=0&&(o=this.data.datasets[l].metaData,r=h(o,t[0]),-1===r);l--);var c=[],u=[],d=function(t){var e,i,n,a,o,h=[],l=[],d=[];return s.each(this.data.datasets,function(t){e=t.metaData,e[r]&&e[r].hasValue()&&h.push(e[r])}),s.each(h,function(t){l.push(t.x),d.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._vm.backgroundColor||t.backgroundColor,stroke:t._vm.borderColor||t.borderColor})},this),o=v(d),n=f(d),a=v(l),i=f(l),{x:a>this.chart.width/2?a:i,y:(o+n)/2}}.call(this,r);new i.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,backgroundColor:this.options.tooltipBackgroundColor,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,custom:this.options.customTooltips}).draw()}else n(t,function(t){var e=t.tooltipPosition();new i.Tooltip({x:Math.round(e.x),y:Math.round(e.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,backgroundColor:this.options.tooltipBackgroundColor,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:S(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,s=function(){return e.apply(this,arguments)};if(s.prototype=a(e.prototype),o(s.prototype,t),s.extend=i.Type.extend,t.name||e.prototype.name){var n=t.name||e.prototype.name,h=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[n]=o(h,t.defaults),i.types[n]=s,i.prototype[n]=function(t,e){var a=r(i.defaults.global,i.defaults[n],e||{});return new s(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},transition:function(t,e){return this._start||(this._start=a(this._vm)),n(this,function(i,s){if("_vm"!==s&&this.hasOwnProperty(s)){if(!this._vm[s])return void(this._vm[s]=i||null);if(t.indexOf(s)>-1){if("string"==typeof i){try{var n=Color(this._start[s]).mix(Color(this[s]),e);this._vm[s]=n.rgbString()}catch(a){this._vm[s]=i}return}return void(this._vm[s]=(this[s]-this._start[s])*e+this._start[s])}this._vm[s]=i}},this),1===e&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return g(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.borderColor,e.lineWidth=this.borderWidth,e.fillStyle=this.backgroundColor,e.fill(),e.lineJoin="bevel",this.showBorder&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,s=t.x-i,n=t.x+i,a=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(s+=o,n-=o,a+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(s,t.base),e.lineTo(s,a),e.lineTo(n,a),e.lineTo(n,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base}}),i.Animation=i.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),i.Tooltip=i.Element.extend({draw:function(){var t=this.chart.ctx;t.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var e=this.caretPadding=2,i=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+e;this.x+i/2>this.chart.width?this.xAlign="left":this.x-i/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var a=this.x-i/2,o=this.y-n;if(t.fillStyle=this.backgroundColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-e),t.lineTo(this.x+this.caretHeight,this.y-(e+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(e+this.caretHeight)),t.closePath(),t.fill();break;case"below":o=this.y+e+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+e),t.lineTo(this.x+this.caretHeight,this.y+e+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+e+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":a=this.x-i+(this.cornerRadius+this.caretHeight);break;case"right":a=this.x-(this.cornerRadius+this.caretHeight)}O(t,a,o,i,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,a+i/2,o+s/2)}}}),i.MultiTooltip=i.Element.extend({initialize:function(){this.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=W(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,e=z(this.ctx,this.font,this.labels)+this.fontSize+3,i=f([e,t]);this.width=i+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 e=this.y-this.height/2+this.yPadding,i=t-1;return 0===t?e+this.titleFontSize/2:e+(1.5*this.fontSize*i+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{O(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.backgroundColor,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(e,i){t.fillStyle=this.textColor,t.fillText(e,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(i+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[i].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?z(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,a=z(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*s,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=i/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,a){var o=this.endPoint-e*a,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==a||h||(h=!0),h&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=s.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var s=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,s,n,a,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+s,n=e),t.x-sp&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var s,n=i*(this.drawingArea/this.steps),a=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e){t.animating=!0;for(var i=0;i1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var n=Date.now(),a=n-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"bars",onHover:null,hoverDuration:400,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:s,initialize:function(t){this.data=t;var s=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return a+o*e+e*s.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return e/t}}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx,_vm:{}}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.endPoint}),t.save()},this),this.update()},onHover:function(t){var e;return"mouseout"==t.type?!1:("bar"==this.options.hoverMode?e=this.getBarAtEvent(t):"bars"==this.options.hoverMode,this.lastActive&&("bar"==this.options.hoverMode?(this.lastActive.rectangle.backgroundColor=this.data.datasets[this.lastActive.datasetIndex].backgroundColor,this.lastActive.rectangle.borderColor=this.data.datasets[this.lastActive.datasetIndex].borderColor, -this.lastActive.rectangle.borderWidth=0):"bars"==this.options.hoverMode),this.options.onHover?this.options.onHover.call(this,e):e&&("bar"==this.options.hoverMode?(e.rectangle.backgroundColor=this.data.datasets[e.datasetIndex].hoverBackgroundColor||Color(e.rectangle.backgroundColor).saturate(.5).darken(.25).rgbString(),e.rectangle.borderColor=this.data.datasets[e.datasetIndex].hoverBorderColor||Color(e.rectangle.borderColor).saturate(.5).darken(.25).rgbString()):"bars"==this.options.hoverMode),this.animating||(!this.lastActive&&e&&this.render(!1,this.options.hoverDuration),this.lastActive&&e&&this.lastActive.rectangle!==e.rectangle&&this.render(!1,this.options.hoverDuration),this.lastActive&&!e&&this.render(!1,this.options.hoverDuration)),void(this.lastActive=e))},update:function(){this.scale.update(),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.calculateY(this.data.datasets[s].data[e]),value:this.data.datasets[s].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[s].label,borderColor:this.data.datasets[s].borderColor,borderWidth:this.data.datasets[s].borderWidth,backgroundColor:this.data.datasets[s].backgroundColor,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,s){i.each(e.metaData,t,this,s)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,s){i.each(e.data,t,this,s)},this)},getBarsAtEvent:function(t){for(var e,s=[],n=i.getRelativePosition(t),a=function(t){s.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:s,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(r[r.length-1].x,this.scale.endPoint),s.lineTo(r[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),i.each(r,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var s={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(s),i.each(e.data,function(i,n){var a;this.scale.animation||(a=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),s.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),s=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,a=Math.round((s.angle-1.5*Math.PI)/n),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),s.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:s.x,y:s.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(s,n){i.extend(this.datasets[e].points[n],{value:s,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),i.each(t.points,function(t,e){0===e?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,s){function n(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,s)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=s?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,s=this.alpha()-t.alpha(),n=((i*s==-1?i:(i+s)/(1+i*s))+1)/2,a=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),s=(r+h)/2,i=h==r?0:.5>=s?l/(h+r):l/(2-h-r),[e,100*i,100*s]}function n(t){var e,i,s,n=t[0],a=t[1],o=t[2],r=Math.min(n,a,o),h=Math.max(n,a,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(a-o)/l:a==h?e=2+(o-n)/l:o==h&&(e=4+(n-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=h/255*1e3/10,[e,i,s]}function a(t){var e=t[0],i=t[1],n=t[2],a=s(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[a,100*o,100*n]}function o(t){var e,i,s,n,a=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-a,1-o,1-r),e=(1-a-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,s=(1-r-n)/(1-n)||0,[100*e,100*i,100*s,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,s=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var n=.4124*e+.3576*i+.1805*s,a=.2126*e+.7152*i+.0722*s,o=.0193*e+.1192*i+.9505*s;return[100*n,100*a,100*o]}function c(t){var e,i,s,n=l(t),a=n[0],o=n[1],r=n[2];return a/=95.047,o/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(a-o),s=200*(o-r),[e,i,s]}function u(t){return V(c(t))}function d(t){var e,i,s,n,a,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)s=o+1/3*-(l-1),0>s&&s++,s>1&&s--,a=1>6*s?e+6*(i-e)*s:1>2*s?i:2>3*s?e+(i-e)*(2/3-s)*6:e,n[l]=255*a;return n}function p(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return a*=2,n*=1>=a?a:2-a,i=(a+n)/2,e=2*n/(a+n),[s,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,a=e-Math.floor(e),o=255*s*(1-i),r=255*s*(1-i*a),h=255*s*(1-i*(1-a)),s=255*s;switch(n){case 0:return[s,h,o];case 1:return[r,s,o];case 2:return[o,s,h];case 3:return[o,r,s];case 4:return[h,o,s];case 5:return[s,o,r]}}function w(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return i=(2-n)*a,e=n*a,e/=1>=i?i:2-i,e=e||0,i/=2,[s,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,s,n,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,s=6*a-e,0!=(1&e)&&(s=1-s),n=o+s*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return s(k(t))}function L(t){return n(k(t))}function M(t){return o(k(t))}function A(t){return h(k(t))}function F(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),s=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*s]}function R(t){return s(F(t))}function T(t){return n(F(t))}function W(t){return a(F(t))}function z(t){return h(F(t))}function O(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*a+o*-.4986,i=n*-.9689+1.8758*a+.0415*o,s=.0557*n+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=12.92*s,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*e,255*i,255*s]}function I(t){var e,i,s,n=t[0],a=t[1],o=t[2];return n/=95.047,a/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(n-a),s=200*(a-o),[e,i,s]}function B(t){return V(I(t))}function E(t){var e,i,s,n,a=t[0],o=t[1],r=t[2];return 8>=a?(i=100*a/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),s=.008859>=s/108.883?s=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,s]}function V(t){var e,i,s,n=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),s=Math.sqrt(a*a+o*o),[n,s,i]}function D(t){return O(E(t))}function H(t){var e,i,s,n=t[0],a=t[1],o=t[2];return s=o/360*2*Math.PI,e=a*Math.cos(s),i=a*Math.sin(s),[n,e,i]}function q(t){return E(H(t))}function X(t){return D(H(t))}function _(t){return U[t]}function Y(t){return s(_(t))}function N(t){return n(_(t))}function j(t){return a(_(t))}function G(t){return o(_(t))}function Z(t){return c(_(t))}function Q(t){return l(_(t))}e.exports={rgb2hsl:s,rgb2hsv:n,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:M,hwb2keyword:A,cmyk2rgb:F,cmyk2hsl:R,cmyk2hsv:T,cmyk2hwb:W,cmyk2keyword:z,keyword2rgb:_,keyword2hsl:Y,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:O,xyz2lab:I,xyz2lch:B,lab2xyz:E,lab2rgb:D,lab2lch:V,lch2lab:H,lch2xyz:q,lch2rgb:X};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var s=t("./conversions"),n=function(){return new l};for(var a in s){n[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),s[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=s[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+s+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+s+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:s,getHsla:n,getRgb:o,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this};i.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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,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(){}}},i.types={};var s=i.helpers={},n=s.each=function(t,e,i){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(e(n))return n}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},s=function(){this.constructor=i};return s.prototype=e.prototype,i.prototype=new s,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),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 define&&define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},v=s.min=function(t){return Math.min.apply(Math,t)},m=(s.cap=function(t,e,i){if(f(e)){if(t>e)return e}else if(f(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&f(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=s.radians=function(t){return t*(Math.PI/180)},y=(s.getAngleFromPoint=function(t,e){var i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s),a=2*Math.PI+Math.atan2(s,i);return 0>i&&0>s&&(a+=2*Math.PI),{angle:a,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),w=(s.splineCurve=function(t,e,i,s){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=s*n/(n+a),h=s*a/(n+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+h*(i.x-t.x),y:e.y+h*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(s.calculateScaleRange=function(t,e,i,s,n){var a=2,o=Math.floor(e/(1.5*i)),h=a>=o,r=g(t),l=v(t);r===l&&(r+=.5,l>=.5&&!s?l-=.5:r+=.5);for(var c=Math.abs(r-l),u=w(c),d=Math.ceil(r/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,m=Math.pow(10,u),b=Math.round(f/m);(b>o||o>2*b)&&!h;)if(b>o)m*=2,b=Math.round(f/m),b%1!==0&&(h=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(f/m)}else m/=2,b=Math.round(f/m);return h&&(b=a,m=f/b),{steps:b,stepValue:m,min:p,max:p+b*m}},s.template=function(t,e){function i(t,e){var i=/\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 e?i(e):i}if(t instanceof Function)return t(e);var s={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,s){var a=new Array(e);return t&&n(a,function(e,n){a[n]=S(t,{value:i+s*(n+1)})}),a},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 e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),st?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(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,e,i,s,n,a){var o=0,h=x[i]||x.linear,r=function(){o++;var i=o/e,l=h(i);t.call(a,l,i,o),s.call(a,l,i),e>o?a.animationFrame=C(r):n.apply(a)};C(r)},s.getRelativePosition=function(t){var e,i,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,a=n.getBoundingClientRect();return s.touches?(e=s.touches[0].clientX-a.left,i=s.touches[0].clientY-a.top):(e=s.clientX-a.left,i=s.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(s.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),M=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(A(e,"padding-left"))+parseInt(A(e,"padding-right"));return e.clientWidth-i},F=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(A(e,"padding-bottom"))+parseInt(A(e,"padding-top"));return e.clientHeight-i},A=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=s+"px",e.canvas.height=s*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),T=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},z=s.fontString=function(t,e,i){return e+" "+t+"px "+i},W=s.longestText=function(t,e,i){t.font=e;var s=0;return n(i,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},O=s.drawRoundedRectangle=function(t,e,i,s,n,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+s-a,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+n-a),t.quadraticCurveTo(e+s,i+n,e+s-a,i+n),t.lineTo(e+a,i+n),t.quadraticCurveTo(e,i+n,e,i+n-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};i.instances={},i.Type=function(t,e,s){this.options=e,this.chart=s,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return T(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=M(this.chart.canvas),s=this.options.maintainAspectRatio?i/this.chart.aspectRatio:F(this.chart.canvas);return e.width=this.chart.width=i,e.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){if(t&&this.reflow(),this.options.animation&&!t){var e=new i.Animation;e.numSteps=this.options.animationSteps,e.easing=this.options.animationEasing,e.render=function(t,e){var i=s.easingEffects[e.easing],n=e.currentStep/e.numSteps,a=i(n);t.draw(a,n,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},showTooltip:function(t,e){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var a=function(t){var e=!1;return t.length!==this.activeElements.length?e=!0:(n(t,function(t,i){t!==this.activeElements[i]&&(e=!0)},this),e)}.call(this,t);if(a||e){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.data.datasets&&this.data.datasets.length>1){for(var o,h,l=this.data.datasets.length-1;l>=0&&(o=this.data.datasets[l].metaData,h=r(o,t[0]),-1===h);l--);var c=[],u=[],d=function(t){var e,i,n,a,o,r=[],l=[],d=[];return s.each(this.data.datasets,function(t){e=t.metaData,e[h]&&e[h].hasValue()&&r.push(e[h])}),s.each(r,function(t){l.push(t.x),d.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._vm.fillColor||t.fillColor,stroke:t._vm.strokeColor||t.strokeColor})},this),o=v(d),n=g(d),a=v(l),i=g(l),{x:a>this.chart.width/2?a:i,y:(o+n)/2}}.call(this,h);new i.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,custom:this.options.customTooltips}).draw()}else n(t,function(t){var e=t.tooltipPosition();new i.Tooltip({x:Math.round(e.x),y:Math.round(e.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:S(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,s=function(){return e.apply(this,arguments)};if(s.prototype=a(e.prototype),o(s.prototype,t),s.extend=i.Type.extend,t.name||e.prototype.name){var n=t.name||e.prototype.name,r=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[n]=o(r,t.defaults),i.types[n]=s,i.prototype[n]=function(t,e){var a=h(i.defaults.global,i.defaults[n],e||{});return new s(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},transition:function(t,e){return this._start||(this._start=a(this._vm)),n(this,function(i,s){if("_vm"!==s&&this.hasOwnProperty(s)){if(!this._vm[s])return void(this._vm[s]=i||null);if(t.indexOf(s)>-1){if("string"==typeof i)return;return void(this._vm[s]=(this[s]-this._start[s])*e+this._start[s])}this._vm[s]=i}},this),1===e&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return f(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.strokeColor,e.lineWidth=this.strokeWidth,e.fillStyle=this.fillColor,e.fill(),e.lineJoin="bevel",this.showStroke&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,s=t.x-i,n=t.x+i,a=t.base-(t.base-t.y),o=t.strokeWidth/2;t.showStroke&&(s+=o,n-=o,a+=o),e.beginPath(),e.fillStyle=t.fillColor,e.strokeStyle=t.strokeColor,e.lineWidth=t.strokeWidth,e.moveTo(s,t.base),e.lineTo(s,a),e.lineTo(n,a),e.lineTo(n,t.base),e.fill(),t.showStroke&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base}}),i.Animation=i.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),i.Tooltip=i.Element.extend({draw:function(){var t=this.chart.ctx;t.font=z(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var e=this.caretPadding=2,i=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+e;this.x+i/2>this.chart.width?this.xAlign="left":this.x-i/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var a=this.x-i/2,o=this.y-n;if(t.fillStyle=this.fillColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-e),t.lineTo(this.x+this.caretHeight,this.y-(e+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(e+this.caretHeight)),t.closePath(),t.fill();break;case"below":o=this.y+e+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+e),t.lineTo(this.x+this.caretHeight,this.y+e+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+e+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":a=this.x-i+(this.cornerRadius+this.caretHeight);break;case"right":a=this.x-(this.cornerRadius+this.caretHeight)}O(t,a,o,i,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,a+i/2,o+s/2)}}}),i.MultiTooltip=i.Element.extend({initialize:function(){this.font=z(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=z(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,e=W(this.ctx,this.font,this.labels)+this.fontSize+3,i=g([e,t]);this.width=i+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 e=this.y-this.height/2+this.yPadding,i=t-1;return 0===t?e+this.titleFontSize/2:e+(1.5*this.fontSize*i+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{O(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(e,i){t.fillStyle=this.textColor,t.fillText(e,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(i+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[i].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?W(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,a=W(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*s,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=i/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,a){var o=this.endPoint-e*a,h=Math.round(o),r=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==a||r||(r=!0),r&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),r&&(t.moveTo(i,h),t.lineTo(this.width,h),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,h),t.lineTo(i,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var s=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,s,n,a,o,h,r,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+s,n=e),t.x-sp&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var s,n=i*(this.drawingArea/this.steps),a=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,h=o/2,r=h>e||e>a-h,l=e===h||e===a-h;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":r?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e){for(var i=0;i1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations.splice(i,1),i--);var n=Date.now(),a=n-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"bars",onHover:null,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:s,initialize:function(t){this.data=t;var s=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return a+o*e+e*s.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return e/t}}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e;return"mouseout"==t.type?!1:("bar"==this.options.hoverMode?e=this.getBarAtEvent(t):"bars"==this.options.hoverMode&&(e=this.getBarsAtEvent(t)),this.options.onHover&&this.options.onHover.call(this,e),void this.showTooltip(e))}),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx,_vm:{}}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.endPoint}),t.save()},this),this.update()},update:function(){this.scale.update(),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.calculateY(this.data.datasets[s].data[e]),value:this.data.datasets[s].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[s].label,strokeColor:this.data.datasets[s].strokeColor, +fillColor:this.data.datasets[s].fillColor,highlightFill:this.data.datasets[s].highlightFill||this.data.datasets[s].fillColor,highlightStroke:this.data.datasets[s].highlightStroke||this.data.datasets[s].strokeColor,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,s){i.each(e.metaData,t,this,s)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,s){i.each(e.data,t,this,s)},this)},getBarsAtEvent:function(t){for(var e,s=[],n=i.getRelativePosition(t),a=function(t){s.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:s,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(h[h.length-1].x,this.scale.endPoint),s.lineTo(h[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),i.each(h,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var s={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(s),i.each(e.data,function(i,n){var a;this.scale.animation||(a=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),s.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),s=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,a=Math.round((s.angle-1.5*Math.PI)/n),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),s.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:s.x,y:s.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(s,n){i.extend(this.datasets[e].points[n],{value:s,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),i.each(t.points,function(t,e){0===e?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,s){function n(o,h){if(!i[o]){if(!e[o]){var r="function"==typeof require&&require;if(!h&&r)return r(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,s)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=s?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,s=this.alpha()-t.alpha(),n=((i*s==-1?i:(i+s)/(1+i*s))+1)/2,a=1-n,o=this.rgbArray(),h=t.rgbArray(),r=0;re&&(e+=360),s=(h+r)/2,i=r==h?0:.5>=s?l/(r+h):l/(2-r-h), +[e,100*i,100*s]}function n(t){var e,i,s,n=t[0],a=t[1],o=t[2],h=Math.min(n,a,o),r=Math.max(n,a,o),l=r-h;return i=0==r?0:l/r*1e3/10,r==h?e=0:n==r?e=(a-o)/l:a==r?e=2+(o-n)/l:o==r&&(e=4+(n-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=r/255*1e3/10,[e,i,s]}function a(t){var e=t[0],i=t[1],n=t[2],a=s(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[a,100*o,100*n]}function o(t){var e,i,s,n,a=t[0]/255,o=t[1]/255,h=t[2]/255;return n=Math.min(1-a,1-o,1-h),e=(1-a-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,s=(1-h-n)/(1-n)||0,[100*e,100*i,100*s,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,s=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var n=.4124*e+.3576*i+.1805*s,a=.2126*e+.7152*i+.0722*s,o=.0193*e+.1192*i+.9505*s;return[100*n,100*a,100*o]}function c(t){var e,i,s,n=l(t),a=n[0],o=n[1],h=n[2];return a/=95.047,o/=100,h/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,e=116*o-16,i=500*(a-o),s=200*(o-h),[e,i,s]}function u(t){return V(c(t))}function d(t){var e,i,s,n,a,o=t[0]/360,h=t[1]/100,r=t[2]/100;if(0==h)return a=255*r,[a,a,a];i=.5>r?r*(1+h):r+h-r*h,e=2*r-i,n=[0,0,0];for(var l=0;3>l;l++)s=o+1/3*-(l-1),0>s&&s++,s>1&&s--,a=1>6*s?e+6*(i-e)*s:1>2*s?i:2>3*s?e+(i-e)*(2/3-s)*6:e,n[l]=255*a;return n}function p(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return a*=2,n*=1>=a?a:2-a,i=(a+n)/2,e=2*n/(a+n),[s,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,a=e-Math.floor(e),o=255*s*(1-i),h=255*s*(1-i*a),r=255*s*(1-i*(1-a)),s=255*s;switch(n){case 0:return[s,r,o];case 1:return[h,s,o];case 2:return[o,s,r];case 3:return[o,h,s];case 4:return[r,o,s];case 5:return[s,o,h]}}function w(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return i=(2-n)*a,e=n*a,e/=1>=i?i:2-i,e=e||0,i/=2,[s,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,s,n,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,s=6*a-e,0!=(1&e)&&(s=1-s),n=o+s*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return s(k(t))}function L(t){return n(k(t))}function M(t){return o(k(t))}function F(t){return h(k(t))}function A(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100,h=t[3]/100;return e=1-Math.min(1,n*(1-h)+h),i=1-Math.min(1,a*(1-h)+h),s=1-Math.min(1,o*(1-h)+h),[255*e,255*i,255*s]}function R(t){return s(A(t))}function T(t){return n(A(t))}function z(t){return a(A(t))}function W(t){return h(A(t))}function O(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*a+o*-.4986,i=n*-.9689+1.8758*a+.0415*o,s=.0557*n+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=12.92*s,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*e,255*i,255*s]}function I(t){var e,i,s,n=t[0],a=t[1],o=t[2];return n/=95.047,a/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(n-a),s=200*(a-o),[e,i,s]}function B(t){return V(I(t))}function E(t){var e,i,s,n,a=t[0],o=t[1],h=t[2];return 8>=a?(i=100*a/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),s=.008859>=s/108.883?s=108.883*(n-h/200-16/116)/7.787:108.883*Math.pow(n-h/200,3),[e,i,s]}function V(t){var e,i,s,n=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),s=Math.sqrt(a*a+o*o),[n,s,i]}function D(t){return O(E(t))}function H(t){var e,i,s,n=t[0],a=t[1],o=t[2];return s=o/360*2*Math.PI,e=a*Math.cos(s),i=a*Math.sin(s),[n,e,i]}function q(t){return E(H(t))}function X(t){return D(H(t))}function Y(t){return U[t]}function _(t){return s(Y(t))}function N(t){return n(Y(t))}function j(t){return a(Y(t))}function G(t){return o(Y(t))}function Z(t){return c(Y(t))}function Q(t){return l(Y(t))}e.exports={rgb2hsl:s,rgb2hsv:n,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:M,hwb2keyword:F,cmyk2rgb:A,cmyk2hsl:R,cmyk2hsv:T,cmyk2hwb:z,cmyk2keyword:W,keyword2rgb:Y,keyword2hsl:_,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:O,xyz2lab:I,xyz2lch:B,lab2xyz:E,lab2rgb:D,lab2lch:V,lch2lab:H,lch2xyz:q,lch2rgb:X};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var s=t("./conversions"),n=function(){return new l};for(var a in s){n[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),s[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),h=o[1],r=o[2];n[h]=n[h]||{},n[h][r]=n[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=s[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+s+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+s+"%, "+n+"%, "+(e||t[3]||1)+")"}function f(t,e){return 1>e||t[3]&&t[3]<1?g(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:s,getHsla:n,getRgb:o,getHsl:h,getHwb:a,getAlpha:r,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:f,hslaString:g,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From afb22d15ae41575b7aff75cec348930e645646f4 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 12 May 2015 10:34:47 -0600 Subject: [PATCH 014/424] Better events --- Chart.js | 187 ++++++++++++++++++++++++++++++----------------- Chart.min.js | 6 +- src/Chart.Bar.js | 12 ++- 3 files changed, 126 insertions(+), 79 deletions(-) diff --git a/Chart.js b/Chart.js index 4388f852154..4a26d8b9eb3 100644 --- a/Chart.js +++ b/Chart.js @@ -59,7 +59,7 @@ animation: true, // Number - Number of animation steps - animationSteps: 60, + animationDuration: 1000, // String - Animation easing effect animationEasing: "easeOutQuart", @@ -124,7 +124,7 @@ tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], // String - Tooltip background colour - tooltipFillColor: "rgba(0,0,0,0.8)", + tooltipBackgroundColor: "rgba(0,0,0,0.8)", // String - Tooltip label font declaration for the scale label tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", @@ -934,14 +934,14 @@ return this; }, reflow : noop, - render : function(reflow){ + render : function(reflow, customDuration){ if (reflow){ this.reflow(); } if (this.options.animation && !reflow){ var animation = new Chart.Animation(); - animation.numSteps = this.options.animationSteps; + animation.numSteps = (customDuration || this.options.animationDuration) / 16.66; //60 fps animation.easing = this.options.animationEasing; // render function @@ -1059,8 +1059,8 @@ //Include any colour information about the element tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element)); tooltipColors.push({ - fill: element._vm.fillColor || element.fillColor, - stroke: element._vm.strokeColor || element.strokeColor + fill: element._vm.backgroundColor || element.backgroundColor, + stroke: element._vm.borderColor || element.borderColor }); }, this); @@ -1083,7 +1083,7 @@ xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, xOffset: this.options.tooltipXOffset, - fillColor: this.options.tooltipFillColor, + backgroundColor: this.options.tooltipBackgroundColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1110,7 +1110,7 @@ y: Math.round(tooltipPosition.y), xPadding: this.options.tooltipXPadding, yPadding: this.options.tooltipYPadding, - fillColor: this.options.tooltipFillColor, + backgroundColor: this.options.tooltipBackgroundColor, textColor: this.options.tooltipFontColor, fontFamily: this.options.tooltipFontFamily, fontStyle: this.options.tooltipFontStyle, @@ -1205,7 +1205,12 @@ if(props.indexOf(key) > -1){ // Color transitions if possible if(typeof value === 'string'){ - // TODO support color transitions + try{ + var color = Color(this._start[key]).mix(Color(this[key]), ease); + this._vm[key] = color.rgbString(); + } catch(err){ + this._vm[key] = value; + } return; } // Everything else, presumably numbers @@ -1250,10 +1255,10 @@ ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2); ctx.closePath(); - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.strokeStyle = this.borderColor; + ctx.lineWidth = this.borderWidth; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.stroke(); @@ -1323,15 +1328,15 @@ ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); ctx.closePath(); - ctx.strokeStyle = this.strokeColor; - ctx.lineWidth = this.strokeWidth; + ctx.strokeStyle = this.borderColor; + ctx.lineWidth = this.borderWidth; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.lineJoin = 'bevel'; - if (this.showStroke){ + if (this.showBorder){ ctx.stroke(); } } @@ -1347,11 +1352,11 @@ leftX = vm.x - halfWidth, rightX = vm.x + halfWidth, top = vm.base - (vm.base - vm.y), - halfStroke = vm.strokeWidth / 2; + halfStroke = vm.borderWidth / 2; // Canvas doesn't allow us to stroke inside the width so we can // adjust the sizes to fit if we're setting a stroke on the line - if (vm.showStroke){ + if (vm.borderWidth){ leftX += halfStroke; rightX -= halfStroke; top += halfStroke; @@ -1359,9 +1364,9 @@ ctx.beginPath(); - ctx.fillStyle = vm.fillColor; - ctx.strokeStyle = vm.strokeColor; - ctx.lineWidth = vm.strokeWidth; + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; // It'd be nice to keep this class totally generic to any rectangle // and simply specify which border to miss out. @@ -1370,7 +1375,7 @@ ctx.lineTo(rightX, top); ctx.lineTo(rightX, vm.base); ctx.fill(); - if (vm.showStroke){ + if (vm.borderWidth){ ctx.stroke(); } }, @@ -1425,7 +1430,7 @@ var tooltipX = this.x - tooltipWidth/2, tooltipY = this.y - tooltipHeight; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; // Custom Tooltips if(this.custom){ @@ -1533,7 +1538,7 @@ else{ drawRoundedRectangle(this.ctx,this.x,this.y - this.height/2,this.width,this.height,this.cornerRadius); var ctx = this.ctx; - ctx.fillStyle = this.fillColor; + ctx.fillStyle = this.backgroundColor; ctx.fill(); ctx.closePath(); @@ -2104,6 +2109,8 @@ animations: [], dropFrames: 0, addAnimation: function(chartInstance, animationObject) { + chartInstance.animating = true; + for (var index = 0; index < this.animations.length; ++ index){ if (this.animations[index].chartInstance === chartInstance){ // replacing an in progress animation @@ -2130,6 +2137,7 @@ if (index){ this.animations.splice(index, 1); + chartInstance.animating = false; } }, // calls startDigest with the proper context @@ -2161,6 +2169,7 @@ if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps){ // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; this.animations.splice(i, 1); // Keep the index in place to offset the splice i--; @@ -2245,11 +2254,8 @@ //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines: true, - //Boolean - If there is a stroke on each bar - barShowStroke : true, - - //Number - Pixel width of the bar stroke - barStrokeWidth : 2, + //Number - Pixel width of the bar border + barBorderWidth : 2, //Number - Spacing between each of the X value sets barValueSpacing : 5, @@ -2263,8 +2269,11 @@ //Function - Custom hover handler onHover : null, + //Function - Custom hover handler + hoverDuration : 400, + //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " }; @@ -2301,33 +2310,8 @@ } }); - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(e){ - var active; - if(e.type == 'mouseout'){ - return false; - } - if(this.options.hoverMode == 'bar'){ - active = this.getBarAtEvent(e); - // TODO: tooltips for single items - } - else if(this.options.hoverMode == 'bars'){ - active = this.getBarsAtEvent(e); - } - else { - // TODO: active = this.getDatasetAtEvent(e); - } - - if(this.options.onHover){ - this.options.onHover.call(this, active); - } - - this.showTooltip(active); - }); - } - - + // Events + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); //Declare the extension of the default point, to cater for the options passed in to the constructor this.BarClass = Chart.Rectangle.extend({ @@ -2359,6 +2343,65 @@ this.update(); }, + onHover: function(e){ + + var active; + if(e.type == 'mouseout'){ + return false; + } + if(this.options.hoverMode == 'bar'){ + active = this.getBarAtEvent(e); + } + else if(this.options.hoverMode == 'bars'){} + + + // Remove styling for last active + if(this.lastActive){ + if(this.options.hoverMode == 'bar'){ + this.lastActive.rectangle.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; + this.lastActive.rectangle.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; + this.lastActive.rectangle.borderWidth = 0; + } + else if(this.options.hoverMode == 'bars'){} + } + + // Custom Hover actions + if(this.options.onHover){ + this.options.onHover.call(this, active); + } + else if(active){ + // or default hover action + if(this.options.hoverMode == 'bar'){ + active.rectangle.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || Color(active.rectangle.backgroundColor).saturate(0.5).darken(0.25).rgbString(); + active.rectangle.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || Color(active.rectangle.borderColor).saturate(0.5).darken(0.25).rgbString(); + } + else if(this.options.hoverMode == 'bars'){} + + } + + if(!this.animating){ + // If entering + if(!this.lastActive && active){ + this.render(false, this.options.hoverDuration); + } + + // If different bar + if(this.lastActive && active && this.lastActive.rectangle !== active.rectangle){ + this.render(false, this.options.hoverDuration); + } + + // if Leaving + if (this.lastActive && !active){ + this.render(false, this.options.hoverDuration); + } + } + + this.lastActive = active; + + if (this.options.showTooltips){ + this.showTooltip(active); + } + }, update : function(){ this.scale.update(); @@ -2371,10 +2414,9 @@ value : this.data.datasets[datasetIndex].data[index], label : this.data.labels[index], datasetLabel: this.data.datasets[datasetIndex].label, - strokeColor : this.data.datasets[datasetIndex].strokeColor, - fillColor : this.data.datasets[datasetIndex].fillColor, - highlightFill : this.data.datasets[datasetIndex].highlightFill || this.data.datasets[datasetIndex].fillColor, - highlightStroke : this.data.datasets[datasetIndex].highlightStroke || this.data.datasets[datasetIndex].strokeColor, + borderColor : this.data.datasets[datasetIndex].borderColor, + borderWidth : this.data.datasets[datasetIndex].borderWidth, + backgroundColor : this.data.datasets[datasetIndex].backgroundColor, _start: undefined }); }, this); @@ -2417,11 +2459,11 @@ var bar; var eventPosition = helpers.getRelativePosition(e); - for (var datasetIndex = 0; datasetIndex < this.datasets.length; ++datasetIndex) { - for (var barIndex = 0; barIndex < this.datasets[datasetIndex].metaData.length; ++barIndex) { - if (this.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; ++barIndex) { + if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { bar = { - rectangle : this.datasets[datasetIndex].metaData[barIndex], + rectangle : this.data.datasets[datasetIndex].metaData[barIndex], datasetIndex : datasetIndex, barIndex : barIndex, }; @@ -2473,7 +2515,7 @@ showVerticalLines : this.options.scaleShowVerticalLines, 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, + padding : (this.options.showScale) ? 0 : this.options.borderWidth, showLabels : this.options.scaleShowLabels, display : this.options.showScale }; @@ -2502,8 +2544,8 @@ y: this.scale.endPoint, width : this.scale.calculateBarWidth(this.data.datasets.length), base : this.scale.endPoint, - strokeColor : this.data.datasets[datasetIndex].strokeColor, - fillColor : this.data.datasets[datasetIndex].fillColor + borderColor : this.data.datasets[datasetIndex].borderColor, + backgroundColor : this.data.datasets[datasetIndex].backgroundColor })); },this); @@ -2543,7 +2585,14 @@ // Update the bar basepoint bar.base = this.scale.endPoint; //Transition - bar.transition(['x','y','width'], easingDecimal).draw(); + bar.transition([ + 'x', + 'y', + 'width', + 'backgroundColor', + 'borderColor', + 'borderWidth' + ], easingDecimal).draw(); } }, this); } diff --git a/Chart.min.js b/Chart.min.js index 345a0a11322..77e12387a4b 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,6 +7,6 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this};i.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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,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(){}}},i.types={};var s=i.helpers={},n=s.each=function(t,e,i){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(e(n))return n}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},s=function(){this.constructor=i};return s.prototype=e.prototype,i.prototype=new s,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),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 define&&define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},v=s.min=function(t){return Math.min.apply(Math,t)},m=(s.cap=function(t,e,i){if(f(e)){if(t>e)return e}else if(f(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&f(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=s.radians=function(t){return t*(Math.PI/180)},y=(s.getAngleFromPoint=function(t,e){var i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s),a=2*Math.PI+Math.atan2(s,i);return 0>i&&0>s&&(a+=2*Math.PI),{angle:a,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),w=(s.splineCurve=function(t,e,i,s){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=s*n/(n+a),h=s*a/(n+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+h*(i.x-t.x),y:e.y+h*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(s.calculateScaleRange=function(t,e,i,s,n){var a=2,o=Math.floor(e/(1.5*i)),h=a>=o,r=g(t),l=v(t);r===l&&(r+=.5,l>=.5&&!s?l-=.5:r+=.5);for(var c=Math.abs(r-l),u=w(c),d=Math.ceil(r/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,m=Math.pow(10,u),b=Math.round(f/m);(b>o||o>2*b)&&!h;)if(b>o)m*=2,b=Math.round(f/m),b%1!==0&&(h=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(f/m)}else m/=2,b=Math.round(f/m);return h&&(b=a,m=f/b),{steps:b,stepValue:m,min:p,max:p+b*m}},s.template=function(t,e){function i(t,e){var i=/\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 e?i(e):i}if(t instanceof Function)return t(e);var s={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,s){var a=new Array(e);return t&&n(a,function(e,n){a[n]=S(t,{value:i+s*(n+1)})}),a},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 e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),st?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(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,e,i,s,n,a){var o=0,h=x[i]||x.linear,r=function(){o++;var i=o/e,l=h(i);t.call(a,l,i,o),s.call(a,l,i),e>o?a.animationFrame=C(r):n.apply(a)};C(r)},s.getRelativePosition=function(t){var e,i,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,a=n.getBoundingClientRect();return s.touches?(e=s.touches[0].clientX-a.left,i=s.touches[0].clientY-a.top):(e=s.clientX-a.left,i=s.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(s.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),M=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(A(e,"padding-left"))+parseInt(A(e,"padding-right"));return e.clientWidth-i},F=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(A(e,"padding-bottom"))+parseInt(A(e,"padding-top"));return e.clientHeight-i},A=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=s+"px",e.canvas.height=s*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),T=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},z=s.fontString=function(t,e,i){return e+" "+t+"px "+i},W=s.longestText=function(t,e,i){t.font=e;var s=0;return n(i,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},O=s.drawRoundedRectangle=function(t,e,i,s,n,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+s-a,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+n-a),t.quadraticCurveTo(e+s,i+n,e+s-a,i+n),t.lineTo(e+a,i+n),t.quadraticCurveTo(e,i+n,e,i+n-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};i.instances={},i.Type=function(t,e,s){this.options=e,this.chart=s,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return T(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=M(this.chart.canvas),s=this.options.maintainAspectRatio?i/this.chart.aspectRatio:F(this.chart.canvas);return e.width=this.chart.width=i,e.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){if(t&&this.reflow(),this.options.animation&&!t){var e=new i.Animation;e.numSteps=this.options.animationSteps,e.easing=this.options.animationEasing,e.render=function(t,e){var i=s.easingEffects[e.easing],n=e.currentStep/e.numSteps,a=i(n);t.draw(a,n,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},showTooltip:function(t,e){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var a=function(t){var e=!1;return t.length!==this.activeElements.length?e=!0:(n(t,function(t,i){t!==this.activeElements[i]&&(e=!0)},this),e)}.call(this,t);if(a||e){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.data.datasets&&this.data.datasets.length>1){for(var o,h,l=this.data.datasets.length-1;l>=0&&(o=this.data.datasets[l].metaData,h=r(o,t[0]),-1===h);l--);var c=[],u=[],d=function(t){var e,i,n,a,o,r=[],l=[],d=[];return s.each(this.data.datasets,function(t){e=t.metaData,e[h]&&e[h].hasValue()&&r.push(e[h])}),s.each(r,function(t){l.push(t.x),d.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._vm.fillColor||t.fillColor,stroke:t._vm.strokeColor||t.strokeColor})},this),o=v(d),n=g(d),a=v(l),i=g(l),{x:a>this.chart.width/2?a:i,y:(o+n)/2}}.call(this,h);new i.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,custom:this.options.customTooltips}).draw()}else n(t,function(t){var e=t.tooltipPosition();new i.Tooltip({x:Math.round(e.x),y:Math.round(e.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:S(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,s=function(){return e.apply(this,arguments)};if(s.prototype=a(e.prototype),o(s.prototype,t),s.extend=i.Type.extend,t.name||e.prototype.name){var n=t.name||e.prototype.name,r=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[n]=o(r,t.defaults),i.types[n]=s,i.prototype[n]=function(t,e){var a=h(i.defaults.global,i.defaults[n],e||{});return new s(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},transition:function(t,e){return this._start||(this._start=a(this._vm)),n(this,function(i,s){if("_vm"!==s&&this.hasOwnProperty(s)){if(!this._vm[s])return void(this._vm[s]=i||null);if(t.indexOf(s)>-1){if("string"==typeof i)return;return void(this._vm[s]=(this[s]-this._start[s])*e+this._start[s])}this._vm[s]=i}},this),1===e&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return f(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.strokeColor,e.lineWidth=this.strokeWidth,e.fillStyle=this.fillColor,e.fill(),e.lineJoin="bevel",this.showStroke&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,s=t.x-i,n=t.x+i,a=t.base-(t.base-t.y),o=t.strokeWidth/2;t.showStroke&&(s+=o,n-=o,a+=o),e.beginPath(),e.fillStyle=t.fillColor,e.strokeStyle=t.strokeColor,e.lineWidth=t.strokeWidth,e.moveTo(s,t.base),e.lineTo(s,a),e.lineTo(n,a),e.lineTo(n,t.base),e.fill(),t.showStroke&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base}}),i.Animation=i.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),i.Tooltip=i.Element.extend({draw:function(){var t=this.chart.ctx;t.font=z(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var e=this.caretPadding=2,i=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+e;this.x+i/2>this.chart.width?this.xAlign="left":this.x-i/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var a=this.x-i/2,o=this.y-n;if(t.fillStyle=this.fillColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-e),t.lineTo(this.x+this.caretHeight,this.y-(e+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(e+this.caretHeight)),t.closePath(),t.fill();break;case"below":o=this.y+e+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+e),t.lineTo(this.x+this.caretHeight,this.y+e+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+e+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":a=this.x-i+(this.cornerRadius+this.caretHeight);break;case"right":a=this.x-(this.cornerRadius+this.caretHeight)}O(t,a,o,i,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,a+i/2,o+s/2)}}}),i.MultiTooltip=i.Element.extend({initialize:function(){this.font=z(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=z(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,e=W(this.ctx,this.font,this.labels)+this.fontSize+3,i=g([e,t]);this.width=i+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 e=this.y-this.height/2+this.yPadding,i=t-1;return 0===t?e+this.titleFontSize/2:e+(1.5*this.fontSize*i+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{O(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(e,i){t.fillStyle=this.textColor,t.fillText(e,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(i+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[i].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?W(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,a=W(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*s,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=i/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,a){var o=this.endPoint-e*a,h=Math.round(o),r=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==a||r||(r=!0),r&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),r&&(t.moveTo(i,h),t.lineTo(this.width,h),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,h),t.lineTo(i,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var s=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,s,n,a,o,h,r,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+s,n=e),t.x-sp&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var s,n=i*(this.drawingArea/this.steps),a=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,h=o/2,r=h>e||e>a-h,l=e===h||e===a-h;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":r?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e){for(var i=0;i1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations.splice(i,1),i--);var n=Date.now(),a=n-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"bars",onHover:null,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:s,initialize:function(t){this.data=t;var s=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return a+o*e+e*s.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return e/t}}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e;return"mouseout"==t.type?!1:("bar"==this.options.hoverMode?e=this.getBarAtEvent(t):"bars"==this.options.hoverMode&&(e=this.getBarsAtEvent(t)),this.options.onHover&&this.options.onHover.call(this,e),void this.showTooltip(e))}),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx,_vm:{}}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.endPoint}),t.save()},this),this.update()},update:function(){this.scale.update(),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.calculateY(this.data.datasets[s].data[e]),value:this.data.datasets[s].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[s].label,strokeColor:this.data.datasets[s].strokeColor, -fillColor:this.data.datasets[s].fillColor,highlightFill:this.data.datasets[s].highlightFill||this.data.datasets[s].fillColor,highlightStroke:this.data.datasets[s].highlightStroke||this.data.datasets[s].strokeColor,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,s){i.each(e.metaData,t,this,s)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,s){i.each(e.data,t,this,s)},this)},getBarsAtEvent:function(t){for(var e,s=[],n=i.getRelativePosition(t),a=function(t){s.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:s,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(h[h.length-1].x,this.scale.endPoint),s.lineTo(h[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),i.each(h,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var s={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(s),i.each(e.data,function(i,n){var a;this.scale.animation||(a=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),s.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),s=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,a=Math.round((s.angle-1.5*Math.PI)/n),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),s.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:s.x,y:s.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(s,n){i.extend(this.datasets[e].points[n],{value:s,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),i.each(t.points,function(t,e){0===e?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,s){function n(o,h){if(!i[o]){if(!e[o]){var r="function"==typeof require&&require;if(!h&&r)return r(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,s)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=s?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,s=this.alpha()-t.alpha(),n=((i*s==-1?i:(i+s)/(1+i*s))+1)/2,a=1-n,o=this.rgbArray(),h=t.rgbArray(),r=0;re&&(e+=360),s=(h+r)/2,i=r==h?0:.5>=s?l/(r+h):l/(2-r-h), -[e,100*i,100*s]}function n(t){var e,i,s,n=t[0],a=t[1],o=t[2],h=Math.min(n,a,o),r=Math.max(n,a,o),l=r-h;return i=0==r?0:l/r*1e3/10,r==h?e=0:n==r?e=(a-o)/l:a==r?e=2+(o-n)/l:o==r&&(e=4+(n-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=r/255*1e3/10,[e,i,s]}function a(t){var e=t[0],i=t[1],n=t[2],a=s(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[a,100*o,100*n]}function o(t){var e,i,s,n,a=t[0]/255,o=t[1]/255,h=t[2]/255;return n=Math.min(1-a,1-o,1-h),e=(1-a-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,s=(1-h-n)/(1-n)||0,[100*e,100*i,100*s,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,s=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var n=.4124*e+.3576*i+.1805*s,a=.2126*e+.7152*i+.0722*s,o=.0193*e+.1192*i+.9505*s;return[100*n,100*a,100*o]}function c(t){var e,i,s,n=l(t),a=n[0],o=n[1],h=n[2];return a/=95.047,o/=100,h/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,e=116*o-16,i=500*(a-o),s=200*(o-h),[e,i,s]}function u(t){return V(c(t))}function d(t){var e,i,s,n,a,o=t[0]/360,h=t[1]/100,r=t[2]/100;if(0==h)return a=255*r,[a,a,a];i=.5>r?r*(1+h):r+h-r*h,e=2*r-i,n=[0,0,0];for(var l=0;3>l;l++)s=o+1/3*-(l-1),0>s&&s++,s>1&&s--,a=1>6*s?e+6*(i-e)*s:1>2*s?i:2>3*s?e+(i-e)*(2/3-s)*6:e,n[l]=255*a;return n}function p(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return a*=2,n*=1>=a?a:2-a,i=(a+n)/2,e=2*n/(a+n),[s,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,a=e-Math.floor(e),o=255*s*(1-i),h=255*s*(1-i*a),r=255*s*(1-i*(1-a)),s=255*s;switch(n){case 0:return[s,r,o];case 1:return[h,s,o];case 2:return[o,s,r];case 3:return[o,h,s];case 4:return[r,o,s];case 5:return[s,o,h]}}function w(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return i=(2-n)*a,e=n*a,e/=1>=i?i:2-i,e=e||0,i/=2,[s,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,s,n,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,s=6*a-e,0!=(1&e)&&(s=1-s),n=o+s*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return s(k(t))}function L(t){return n(k(t))}function M(t){return o(k(t))}function F(t){return h(k(t))}function A(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100,h=t[3]/100;return e=1-Math.min(1,n*(1-h)+h),i=1-Math.min(1,a*(1-h)+h),s=1-Math.min(1,o*(1-h)+h),[255*e,255*i,255*s]}function R(t){return s(A(t))}function T(t){return n(A(t))}function z(t){return a(A(t))}function W(t){return h(A(t))}function O(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*a+o*-.4986,i=n*-.9689+1.8758*a+.0415*o,s=.0557*n+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=12.92*s,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*e,255*i,255*s]}function I(t){var e,i,s,n=t[0],a=t[1],o=t[2];return n/=95.047,a/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(n-a),s=200*(a-o),[e,i,s]}function B(t){return V(I(t))}function E(t){var e,i,s,n,a=t[0],o=t[1],h=t[2];return 8>=a?(i=100*a/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),s=.008859>=s/108.883?s=108.883*(n-h/200-16/116)/7.787:108.883*Math.pow(n-h/200,3),[e,i,s]}function V(t){var e,i,s,n=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),s=Math.sqrt(a*a+o*o),[n,s,i]}function D(t){return O(E(t))}function H(t){var e,i,s,n=t[0],a=t[1],o=t[2];return s=o/360*2*Math.PI,e=a*Math.cos(s),i=a*Math.sin(s),[n,e,i]}function q(t){return E(H(t))}function X(t){return D(H(t))}function Y(t){return U[t]}function _(t){return s(Y(t))}function N(t){return n(Y(t))}function j(t){return a(Y(t))}function G(t){return o(Y(t))}function Z(t){return c(Y(t))}function Q(t){return l(Y(t))}e.exports={rgb2hsl:s,rgb2hsv:n,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:M,hwb2keyword:F,cmyk2rgb:A,cmyk2hsl:R,cmyk2hsv:T,cmyk2hwb:z,cmyk2keyword:W,keyword2rgb:Y,keyword2hsl:_,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:O,xyz2lab:I,xyz2lch:B,lab2xyz:E,lab2rgb:D,lab2lch:V,lch2lab:H,lch2xyz:q,lch2rgb:X};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var s=t("./conversions"),n=function(){return new l};for(var a in s){n[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),s[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),h=o[1],r=o[2];n[h]=n[h]||{},n[h][r]=n[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=s[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+s+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+s+"%, "+n+"%, "+(e||t[3]||1)+")"}function f(t,e){return 1>e||t[3]&&t[3]<1?g(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:s,getHsla:n,getRgb:o,getHsl:h,getHwb:a,getAlpha:r,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:f,hslaString:g,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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(){}}},i.types={};var s=i.helpers={},n=s.each=function(t,e,i){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(e(n))return n}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},s=function(){this.constructor=i};return s.prototype=e.prototype,i.prototype=new s,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),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 define&&define.amd,g=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=s.max=function(t){return Math.max.apply(Math,t)},v=s.min=function(t){return Math.min.apply(Math,t)},m=(s.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=s.radians=function(t){return t*(Math.PI/180)},y=(s.getAngleFromPoint=function(t,e){var i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s),a=2*Math.PI+Math.atan2(s,i);return 0>i&&0>s&&(a+=2*Math.PI),{angle:a,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),w=(s.splineCurve=function(t,e,i,s){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=s*n/(n+a),r=s*a/(n+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(s.calculateScaleRange=function(t,e,i,s,n){var a=2,o=Math.floor(e/(1.5*i)),r=a>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!s?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=a,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},s.template=function(t,e){function i(t,e){var i=/\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 e?i(e):i}if(t instanceof Function)return t(e);var s={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,s){var a=new Array(e);return t&&n(a,function(e,n){a[n]=S(t,{value:i+s*(n+1)})}),a},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 e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),st?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(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,e,i,s,n,a){var o=0,r=x[i]||x.linear,h=function(){o++;var i=o/e,l=r(i);t.call(a,l,i,o),s.call(a,l,i),e>o?a.animationFrame=C(h):n.apply(a)};C(h)},s.getRelativePosition=function(t){var e,i,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,a=n.getBoundingClientRect();return s.touches?(e=s.touches[0].clientX-a.left,i=s.touches[0].clientY-a.top):(e=s.clientX-a.left,i=s.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(s.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),M=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-left"))+parseInt(F(e,"padding-right"));return e.clientWidth-i},A=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-bottom"))+parseInt(F(e,"padding-top"));return e.clientHeight-i},F=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=s+"px",e.canvas.height=s*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),T=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},z=s.longestText=function(t,e,i){t.font=e;var s=0;return n(i,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},O=s.drawRoundedRectangle=function(t,e,i,s,n,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+s-a,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+n-a),t.quadraticCurveTo(e+s,i+n,e+s-a,i+n),t.lineTo(e+a,i+n),t.quadraticCurveTo(e,i+n,e,i+n-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};i.instances={},i.Type=function(t,e,s){this.options=e,this.chart=s,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return T(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=M(this.chart.canvas),s=this.options.maintainAspectRatio?i/this.chart.aspectRatio:A(this.chart.canvas);return e.width=this.chart.width=i,e.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,e){if(t&&this.reflow(),this.options.animation&&!t){var n=new i.Animation;n.numSteps=(e||this.options.animationDuration)/16.66,n.easing=this.options.animationEasing,n.render=function(t,e){var i=s.easingEffects[e.easing],n=e.currentStep/e.numSteps,a=i(n);t.draw(a,n,e.currentStep)},n.onAnimationProgress=this.options.onAnimationProgress,n.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,n)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},showTooltip:function(t,e){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var a=function(t){var e=!1;return t.length!==this.activeElements.length?e=!0:(n(t,function(t,i){t!==this.activeElements[i]&&(e=!0)},this),e)}.call(this,t);if(a||e){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.data.datasets&&this.data.datasets.length>1){for(var o,r,l=this.data.datasets.length-1;l>=0&&(o=this.data.datasets[l].metaData,r=h(o,t[0]),-1===r);l--);var c=[],u=[],d=function(t){var e,i,n,a,o,h=[],l=[],d=[];return s.each(this.data.datasets,function(t){e=t.metaData,e[r]&&e[r].hasValue()&&h.push(e[r])}),s.each(h,function(t){l.push(t.x),d.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._vm.backgroundColor||t.backgroundColor,stroke:t._vm.borderColor||t.borderColor})},this),o=v(d),n=f(d),a=v(l),i=f(l),{x:a>this.chart.width/2?a:i,y:(o+n)/2}}.call(this,r);new i.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,backgroundColor:this.options.tooltipBackgroundColor,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,custom:this.options.customTooltips}).draw()}else n(t,function(t){var e=t.tooltipPosition();new i.Tooltip({x:Math.round(e.x),y:Math.round(e.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,backgroundColor:this.options.tooltipBackgroundColor,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:S(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,s=function(){return e.apply(this,arguments)};if(s.prototype=a(e.prototype),o(s.prototype,t),s.extend=i.Type.extend,t.name||e.prototype.name){var n=t.name||e.prototype.name,h=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[n]=o(h,t.defaults),i.types[n]=s,i.prototype[n]=function(t,e){var a=r(i.defaults.global,i.defaults[n],e||{});return new s(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},transition:function(t,e){return this._start||(this._start=a(this._vm)),n(this,function(i,s){if("_vm"!==s&&this.hasOwnProperty(s)){if(!this._vm[s])return void(this._vm[s]=i||null);if(t.indexOf(s)>-1){if("string"==typeof i){try{var n=Color(this._start[s]).mix(Color(this[s]),e);this._vm[s]=n.rgbString()}catch(a){this._vm[s]=i}return}return void(this._vm[s]=(this[s]-this._start[s])*e+this._start[s])}this._vm[s]=i}},this),1===e&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return g(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.borderColor,e.lineWidth=this.borderWidth,e.fillStyle=this.backgroundColor,e.fill(),e.lineJoin="bevel",this.showBorder&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,s=t.x-i,n=t.x+i,a=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(s+=o,n-=o,a+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(s,t.base),e.lineTo(s,a),e.lineTo(n,a),e.lineTo(n,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base}}),i.Animation=i.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),i.Tooltip=i.Element.extend({draw:function(){var t=this.chart.ctx;t.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var e=this.caretPadding=2,i=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+e;this.x+i/2>this.chart.width?this.xAlign="left":this.x-i/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var a=this.x-i/2,o=this.y-n;if(t.fillStyle=this.backgroundColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-e),t.lineTo(this.x+this.caretHeight,this.y-(e+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(e+this.caretHeight)),t.closePath(),t.fill();break;case"below":o=this.y+e+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+e),t.lineTo(this.x+this.caretHeight,this.y+e+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+e+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":a=this.x-i+(this.cornerRadius+this.caretHeight);break;case"right":a=this.x-(this.cornerRadius+this.caretHeight)}O(t,a,o,i,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,a+i/2,o+s/2)}}}),i.MultiTooltip=i.Element.extend({initialize:function(){this.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=W(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,e=z(this.ctx,this.font,this.labels)+this.fontSize+3,i=f([e,t]);this.width=i+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 e=this.y-this.height/2+this.yPadding,i=t-1;return 0===t?e+this.titleFontSize/2:e+(1.5*this.fontSize*i+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{O(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.backgroundColor,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(e,i){t.fillStyle=this.textColor,t.fillText(e,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(i+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[i].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?z(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,a=z(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*s,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=i/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,a){var o=this.endPoint-e*a,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==a||h||(h=!0),h&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=s.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var s=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,s,n,a,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+s,n=e),t.x-sp&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var s,n=i*(this.drawingArea/this.steps),a=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e){t.animating=!0;for(var i=0;i1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var n=Date.now(),a=n-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"bars",onHover:null,hoverDuration:400,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:s,initialize:function(t){this.data=t;var s=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return a+o*e+e*s.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return e/t}}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx,_vm:{}}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.endPoint}),t.save()},this),this.update()},onHover:function(t){var e;return"mouseout"==t.type?!1:("bar"==this.options.hoverMode?e=this.getBarAtEvent(t):"bars"==this.options.hoverMode,this.lastActive&&("bar"==this.options.hoverMode?(this.lastActive.rectangle.backgroundColor=this.data.datasets[this.lastActive.datasetIndex].backgroundColor,this.lastActive.rectangle.borderColor=this.data.datasets[this.lastActive.datasetIndex].borderColor, +this.lastActive.rectangle.borderWidth=0):"bars"==this.options.hoverMode),this.options.onHover?this.options.onHover.call(this,e):e&&("bar"==this.options.hoverMode?(e.rectangle.backgroundColor=this.data.datasets[e.datasetIndex].hoverBackgroundColor||Color(e.rectangle.backgroundColor).saturate(.5).darken(.25).rgbString(),e.rectangle.borderColor=this.data.datasets[e.datasetIndex].hoverBorderColor||Color(e.rectangle.borderColor).saturate(.5).darken(.25).rgbString()):"bars"==this.options.hoverMode),this.animating||(!this.lastActive&&e&&this.render(!1,this.options.hoverDuration),this.lastActive&&e&&this.lastActive.rectangle!==e.rectangle&&this.render(!1,this.options.hoverDuration),this.lastActive&&!e&&this.render(!1,this.options.hoverDuration)),this.lastActive=e,void(this.options.showTooltips&&this.showTooltip(e)))},update:function(){this.scale.update(),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.calculateY(this.data.datasets[s].data[e]),value:this.data.datasets[s].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[s].label,borderColor:this.data.datasets[s].borderColor,borderWidth:this.data.datasets[s].borderWidth,backgroundColor:this.data.datasets[s].backgroundColor,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,s){i.each(e.metaData,t,this,s)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,s){i.each(e.data,t,this,s)},this)},getBarsAtEvent:function(t){for(var e,s=[],n=i.getRelativePosition(t),a=function(t){s.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:s,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(r[r.length-1].x,this.scale.endPoint),s.lineTo(r[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),i.each(r,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var s={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(s),i.each(e.data,function(i,n){var a;this.scale.animation||(a=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),s.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),s=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,a=Math.round((s.angle-1.5*Math.PI)/n),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),s.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:s.x,y:s.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(s,n){i.extend(this.datasets[e].points[n],{value:s,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),i.each(t.points,function(t,e){0===e?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,s){function n(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,s)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=s?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,s=this.alpha()-t.alpha(),n=((i*s==-1?i:(i+s)/(1+i*s))+1)/2,a=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),s=(r+h)/2,i=h==r?0:.5>=s?l/(h+r):l/(2-h-r),[e,100*i,100*s]}function n(t){var e,i,s,n=t[0],a=t[1],o=t[2],r=Math.min(n,a,o),h=Math.max(n,a,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(a-o)/l:a==h?e=2+(o-n)/l:o==h&&(e=4+(n-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=h/255*1e3/10,[e,i,s]}function a(t){var e=t[0],i=t[1],n=t[2],a=s(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[a,100*o,100*n]}function o(t){var e,i,s,n,a=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-a,1-o,1-r),e=(1-a-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,s=(1-r-n)/(1-n)||0,[100*e,100*i,100*s,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,s=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var n=.4124*e+.3576*i+.1805*s,a=.2126*e+.7152*i+.0722*s,o=.0193*e+.1192*i+.9505*s;return[100*n,100*a,100*o]}function c(t){var e,i,s,n=l(t),a=n[0],o=n[1],r=n[2];return a/=95.047,o/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(a-o),s=200*(o-r),[e,i,s]}function u(t){return V(c(t))}function d(t){var e,i,s,n,a,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)s=o+1/3*-(l-1),0>s&&s++,s>1&&s--,a=1>6*s?e+6*(i-e)*s:1>2*s?i:2>3*s?e+(i-e)*(2/3-s)*6:e,n[l]=255*a;return n}function p(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return a*=2,n*=1>=a?a:2-a,i=(a+n)/2,e=2*n/(a+n),[s,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,a=e-Math.floor(e),o=255*s*(1-i),r=255*s*(1-i*a),h=255*s*(1-i*(1-a)),s=255*s;switch(n){case 0:return[s,h,o];case 1:return[r,s,o];case 2:return[o,s,h];case 3:return[o,r,s];case 4:return[h,o,s];case 5:return[s,o,r]}}function w(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return i=(2-n)*a,e=n*a,e/=1>=i?i:2-i,e=e||0,i/=2,[s,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,s,n,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,s=6*a-e,0!=(1&e)&&(s=1-s),n=o+s*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return s(k(t))}function L(t){return n(k(t))}function M(t){return o(k(t))}function A(t){return h(k(t))}function F(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),s=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*s]}function R(t){return s(F(t))}function T(t){return n(F(t))}function W(t){return a(F(t))}function z(t){return h(F(t))}function O(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*a+o*-.4986,i=n*-.9689+1.8758*a+.0415*o,s=.0557*n+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=12.92*s,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*e,255*i,255*s]}function I(t){var e,i,s,n=t[0],a=t[1],o=t[2];return n/=95.047,a/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(n-a),s=200*(a-o),[e,i,s]}function B(t){return V(I(t))}function E(t){var e,i,s,n,a=t[0],o=t[1],r=t[2];return 8>=a?(i=100*a/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),s=.008859>=s/108.883?s=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,s]}function V(t){var e,i,s,n=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),s=Math.sqrt(a*a+o*o),[n,s,i]}function D(t){return O(E(t))}function H(t){var e,i,s,n=t[0],a=t[1],o=t[2];return s=o/360*2*Math.PI,e=a*Math.cos(s),i=a*Math.sin(s),[n,e,i]}function q(t){return E(H(t))}function X(t){return D(H(t))}function _(t){return U[t]}function Y(t){return s(_(t))}function N(t){return n(_(t))}function j(t){return a(_(t))}function G(t){return o(_(t))}function Z(t){return c(_(t))}function Q(t){return l(_(t))}e.exports={rgb2hsl:s,rgb2hsv:n,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:M,hwb2keyword:A,cmyk2rgb:F,cmyk2hsl:R,cmyk2hsv:T,cmyk2hwb:W,cmyk2keyword:z,keyword2rgb:_,keyword2hsl:Y,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:O,xyz2lab:I,xyz2lch:B,lab2xyz:E,lab2rgb:D,lab2lch:V,lch2lab:H,lch2xyz:q,lch2rgb:X};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var s=t("./conversions"),n=function(){return new l};for(var a in s){n[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),s[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=s[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+s+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+s+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:s,getHsla:n,getRgb:o,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index a65331f30ab..a681bdfa212 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -81,12 +81,8 @@ } }); - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); - } - - + // Events + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); //Declare the extension of the default point, to cater for the options passed in to the constructor this.BarClass = Chart.Rectangle.extend({ @@ -173,7 +169,9 @@ this.lastActive = active; - //this.showTooltip(active); + if (this.options.showTooltips){ + this.showTooltip(active); + } }, // Calculate the base point for the bar. // If the scale has a 0 point, use that as the base From 15f724f1460f8e86f8c0e8b88f62b3342762aa33 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 12 May 2015 12:55:48 -0600 Subject: [PATCH 015/424] Rough Tooltips for 'single' hoverMode --- samples/bar.html | 4 +- src/Chart.Bar.js | 102 +++++++++++++++++++++++--------------- src/Chart.Core.js | 122 +++++++++++++++++++++++++--------------------- 3 files changed, 133 insertions(+), 95 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index d1bf880c67a..0ddfd27408e 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -22,9 +22,11 @@ var barChartData = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ + label: 'Dataset 1', backgroundColor: "rgba(220,220,220,0.5)", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }, { + label: 'Dataset 2', backgroundColor: "rgba(151,187,205,0.5)", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }] @@ -34,7 +36,7 @@ var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx).Bar(barChartData, { responsive: true, - hoverMode: 'bar', + hoverMode: 'single', scaleBeginAtZero: false, }); } diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index a681bdfa212..01872dde7b7 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -34,14 +34,14 @@ //Number - Spacing between data sets within X values barDatasetSpacing : 1, - //String - Hover mode for events - hoverMode : 'bars', // 'bar', 'dataset' + //String / Boolean - Hover mode for events. + hoverMode : 'single', // 'label', 'dataset', 'false' //Function - Custom hover handler onHover : null, //Function - Custom hover handler - hoverDuration : 400, + hoverAnimationDuration : 400, //String - A legend template legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " @@ -62,10 +62,10 @@ this.ScaleClass = Chart.Scale.extend({ offsetGridLines : true, - calculateBarX : function(datasetCount, datasetIndex, barIndex){ + calculateBarX : function(datasetCount, datasetIndex, elementIndex){ //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar var xWidth = this.calculateBaseWidth(), - xAbsolute = this.calculateX(barIndex) - (xWidth/2), + xAbsolute = this.calculateX(elementIndex) - (xWidth/2), barWidth = this.calculateBarWidth(datasetCount); return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth/2; @@ -116,61 +116,87 @@ }, onHover: function(e){ - var active; + + // If exiting chart if(e.type == 'mouseout'){ return false; } - if(this.options.hoverMode == 'bar'){ - active = this.getBarAtEvent(e); - } - else if(this.options.hoverMode == 'bars'){} + + var active = function(){ + switch(this.options.hoverMode){ + case 'single': + return this.getBarAtEvent(e); + case 'label': + return this.getBarsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); - // Remove styling for last active + // Remove styling for last active (even if it may still be active) if(this.lastActive){ - if(this.options.hoverMode == 'bar'){ - this.lastActive.rectangle.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; - this.lastActive.rectangle.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; - this.lastActive.rectangle.borderWidth = 0; + switch(this.options.hoverMode){ + case 'single': + this.lastActive.element.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; + this.lastActive.element.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; + this.lastActive.element.borderWidth = 0; + break; + case 'label': + break; + case 'dataset': + break; + default: + // do nothing } - else if(this.options.hoverMode == 'bars'){} } - // Custom Hover actions + // On Hover hook if(this.options.onHover){ this.options.onHover.call(this, active); } - else if(active){ - // or default hover action - if(this.options.hoverMode == 'bar'){ - active.rectangle.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || Color(active.rectangle.backgroundColor).saturate(0.5).darken(0.25).rgbString(); - active.rectangle.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || Color(active.rectangle.borderColor).saturate(0.5).darken(0.25).rgbString(); + + // Built in hover actions + if(active && this.options.hoverMode){ + switch(this.options.hoverMode){ + case 'single': + active.element.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || helpers.color(active.element.backgroundColor).saturate(0.5).darken(0.25).rgbString(); + active.element.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || helpers.color(active.element.borderColor).saturate(0.5).darken(0.25).rgbString(); + break; + case 'label': + break; + case 'dataset': + break; + default: + // do nothing } - else if(this.options.hoverMode == 'bars'){} - } + // Only animate for major events if(!this.animating){ // If entering if(!this.lastActive && active){ - this.render(false, this.options.hoverDuration); + this.render(false, this.options.hoverAnimationDuration); } - // If different bar - if(this.lastActive && active && this.lastActive.rectangle !== active.rectangle){ - this.render(false, this.options.hoverDuration); + // If different element + if(this.lastActive && active && this.lastActive.element !== active.element){ + this.render(false, this.options.hoverAnimationDuration); } // if Leaving if (this.lastActive && !active){ - this.render(false, this.options.hoverDuration); + this.render(false, this.options.hoverAnimationDuration); } } + // Remember Last Active this.lastActive = active; if (this.options.showTooltips){ - this.showTooltip(active); + this.showTooltip(active, this.options.hoverMode); } }, // Calculate the base point for the bar. @@ -229,13 +255,13 @@ var barsArray = [], eventPosition = helpers.getRelativePosition(e), datasetIterator = function(dataset){ - barsArray.push(dataset.metaData[barIndex]); + barsArray.push(dataset.metaData[elementIndex]); }, - barIndex; + elementIndex; for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; barIndex++) { - if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x,eventPosition.y)){ + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x,eventPosition.y)){ helpers.each(this.data.datasets, datasetIterator); return barsArray; } @@ -251,12 +277,12 @@ var eventPosition = helpers.getRelativePosition(e); for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; ++barIndex) { - if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { bar = { - rectangle : this.data.datasets[datasetIndex].metaData[barIndex], + element : this.data.datasets[datasetIndex].metaData[elementIndex], datasetIndex : datasetIndex, - barIndex : barIndex, + elementIndex : elementIndex, }; return bar; } diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8a476551b0a..49e03ffc599 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -883,9 +883,21 @@ ctx.lineTo(x, y + radius); ctx.quadraticCurveTo(x, y, x + radius, y); ctx.closePath(); + }, + color = helpers.color = function(color){ + if(!window.Color){ + console.log('Color.js not found!'); + return color; + } + return window.Color(color); + }, + isArray = helpers.isArray = function(obj){ + if (!Array.isArray) { + return Object.prototype.toString.call(arg) === '[object Array]'; + } + return Array.isArray(obj); }; - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. //Destroy method on the chart will remove the instance of the chart from this reference. Chart.instances = {}; @@ -988,45 +1000,46 @@ delete Chart.instances[this.id]; }, - showTooltip : function(ChartElements, forceRedraw){ - // Only redraw the chart if we've actually changed what we're hovering on. - if (typeof this.activeElements === 'undefined') this.activeElements = []; - - var isChanged = (function(Elements){ - var changed = false; + showTooltip : function(elements, hoverMode){ - if (Elements.length !== this.activeElements.length){ - changed = true; - return changed; + // Hide if no elements + if(!elements){ + if(this.options.customTooltips){ + this.options.customTooltips(false); + } + if(!this.animating){ + this.render(false, this.options.hoverAnimationDuration); } - - each(Elements, function(element, index){ - if (element !== this.activeElements[index]){ - changed = true; - } - }, this); - return changed; - }).call(this, ChartElements); - - if (!isChanged && !forceRedraw){ return; } - else{ - this.activeElements = ChartElements; - } - this.draw(); - if(this.options.customTooltips){ - this.options.customTooltips(false); - } - if (ChartElements.length > 0){ - // If we have multiple datasets, show a MultiTooltip for all of the data points at that index - if (this.data.datasets && this.data.datasets.length > 1) { + + switch(hoverMode){ + case 'single': + var tooltipPosition = elements.element.tooltipPosition(); + new Chart.Tooltip({ + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + xPadding: this.options.tooltipXPadding, + yPadding: this.options.tooltipYPadding, + backgroundColor: this.options.tooltipBackgroundColor, + 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: template(this.options.tooltipTemplate, elements.element), + chart: this.chart, + custom: this.options.customTooltips + }).draw(); + break; + case 'label': var dataArray, dataIndex; for (var i = this.data.datasets.length - 1; i >= 0; i--) { dataArray = this.data.datasets[i].metaData; - dataIndex = indexOf(dataArray, ChartElements[0]); + dataIndex = indexOf(dataArray, elements[0]); if (dataIndex !== -1){ break; } @@ -1096,34 +1109,17 @@ labels: tooltipLabels, legendColors: tooltipColors, legendColorBackground : this.options.multiTooltipKeyBackground, - title: ChartElements[0].label, + title: elements[0].label, chart: this.chart, ctx: this.chart.ctx, custom: this.options.customTooltips }).draw(); - - } else { - each(ChartElements, function(Element) { - var tooltipPosition = Element.tooltipPosition(); - new Chart.Tooltip({ - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - xPadding: this.options.tooltipXPadding, - yPadding: this.options.tooltipYPadding, - backgroundColor: this.options.tooltipBackgroundColor, - 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: template(this.options.tooltipTemplate, Element), - chart: this.chart, - custom: this.options.customTooltips - }).draw(); - }, this); - } + break; + case 'dataset': + break; + default: } + return this; }, toBase64Image : function(){ @@ -1206,7 +1202,7 @@ // Color transitions if possible if(typeof value === 'string'){ try{ - var color = Color(this._start[key]).mix(Color(this[key]), ease); + var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); this._vm[key] = color.rgbString(); } catch(err){ this._vm[key] = value; @@ -1392,7 +1388,21 @@ { return (chartX >= this.x - this.width / 2 && chartX <= this.x + this.width / 2) && (chartY >= this.base && chartY <= this.y); } - } + }, + tooltipPosition : function(){ + if (this.y < this.base){ + return { + x : this.x, + y : this.y + }; + } + else{ + return { + x : this.x, + y : this.base + }; + } + }, }); Chart.Animation = Chart.Element.extend({ From 9f98334d6f2615a54492e3e581dbad0e3d3dba06 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 12 May 2015 15:42:20 -0600 Subject: [PATCH 016/424] Mid-code commit --- samples/bar.html | 2 - src/Chart.Bar.js | 119 ++++++++------- src/Chart.Core.js | 365 ++++++++++++++++++++++------------------------ 3 files changed, 239 insertions(+), 247 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index 0ddfd27408e..17afaf6af01 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -49,8 +49,6 @@ barChartData.datasets[1].data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; window.myBar.update(); - - console.log(window.barChartData); }); diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 01872dde7b7..386e305dcb1 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -87,7 +87,6 @@ //Declare the extension of the default point, to cater for the options passed in to the constructor this.BarClass = Chart.Rectangle.extend({ ctx : this.chart.ctx, - _vm: {} }); // Build Scale @@ -112,6 +111,29 @@ bar.save(); }, this); + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _options: this.options, + opacity:0, + xPadding: this.options.tooltipXPadding, + yPadding: this.options.tooltipYPadding, + xOffset: this.options.tooltipXOffset, + backgroundColor: this.options.tooltipBackgroundColor, + 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, + caretHeight: this.options.tooltipCaretSize, + cornerRadius: this.options.tooltipCornerRadius, + legendColorBackground : this.options.multiTooltipKeyBackground, + }, this); + + // Update the chart with the latest data. this.update(); }, onHover: function(e){ @@ -122,7 +144,7 @@ return false; } - var active = function(){ + this.active = function(){ switch(this.options.hoverMode){ case 'single': return this.getBarAtEvent(e); @@ -155,15 +177,15 @@ // On Hover hook if(this.options.onHover){ - this.options.onHover.call(this, active); + this.options.onHover.call(this, this.active); } // Built in hover actions - if(active && this.options.hoverMode){ + if(this.active && this.options.hoverMode){ switch(this.options.hoverMode){ case 'single': - active.element.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || helpers.color(active.element.backgroundColor).saturate(0.5).darken(0.25).rgbString(); - active.element.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || helpers.color(active.element.borderColor).saturate(0.5).darken(0.25).rgbString(); + this.active.element.backgroundColor = this.data.datasets[this.active.datasetIndex].hoverBackgroundColor || helpers.color(this.active.element.backgroundColor).saturate(0.5).darken(0.25).rgbString(); + this.active.element.borderColor = this.data.datasets[this.active.datasetIndex].hoverBorderColor || helpers.color(this.active.element.borderColor).saturate(0.5).darken(0.25).rgbString(); break; case 'label': break; @@ -174,30 +196,53 @@ } } + + // Built in Tooltips + if(this.options.showTooltips){ + + // The usual + this.tooltip.initialize(); + + // Active Details + if(this.active){ + var tooltipPosition = this.active.element.tooltipPosition(); + helpers.extend(this.tooltip, { + opacity: 1, + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + _active: this.active.element, + }); + this.tooltip.updateContent(); + } + else{ + // Inactive Details + helpers.extend(this.tooltip, { + opacity: 0, + _active: false, + }); + } + } + // Only animate for major events if(!this.animating){ // If entering - if(!this.lastActive && active){ + if(!this.lastActive && this.active){ this.render(false, this.options.hoverAnimationDuration); } // If different element - if(this.lastActive && active && this.lastActive.element !== active.element){ + if(this.lastActive && this.active && this.lastActive.element !== this.active.element){ this.render(false, this.options.hoverAnimationDuration); } // if Leaving - if (this.lastActive && !active){ + if (this.lastActive && !this.active){ this.render(false, this.options.hoverAnimationDuration); } } // Remember Last Active - this.lastActive = active; - - if (this.options.showTooltips){ - this.showTooltip(active, this.options.hoverMode); - } + this.lastActive = this.active; }, // Calculate the base point for the bar. // If the scale has a 0 point, use that as the base @@ -349,36 +394,8 @@ this.scale = new this.ScaleClass(scaleOptions); }, - addData : function(valuesArray,label){ - //Map the values array for each of the datasets - helpers.each(valuesArray,function(value,datasetIndex){ - //Add a new point for each piece of data, passing any required data to draw. - this.data.datasets[datasetIndex].bars.push(new this.BarClass({ - value : value, - label : label, - datasetLabel: this.data.datasets[datasetIndex].label, - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, this.scale.valuesCount+1), - y: this.calculateBarBase(), - width : this.scale.calculateBarWidth(this.data.datasets.length), - base : this.calculateBarBase(), - borderColor : this.data.datasets[datasetIndex].borderColor, - backgroundColor : this.data.datasets[datasetIndex].backgroundColor - })); - },this); - - this.scale.addXLabel(label); - //Then re-render the chart. - this.update(); - }, - removeData : function(){ - this.scale.removeXLabel(); - //Then re-render the chart. - helpers.each(this.data.datasets,function(dataset){ - dataset.bars.shift(); - },this); - this.update(); - }, - reflow : function(){ + // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function + /*reflow : function(){ helpers.extend(this.BarClass.prototype,{ y: this.calculateBarBase(), // so that we animate from the baseline base : this.calculateBarBase() @@ -388,7 +405,7 @@ width : this.chart.width }); this.scale.update(newScaleProps); - }, + },*/ draw : function(ease){ var easingDecimal = ease || 1; @@ -402,16 +419,12 @@ // Update the bar basepoint bar.base = this.calculateBarBase(); //Transition - bar.transition([ - 'x', - 'y', - 'width', - 'backgroundColor', - 'borderColor', - 'borderWidth' - ], easingDecimal).draw(); + bar.transition(easingDecimal).draw(); } }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); } }); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 49e03ffc599..f3b000806f7 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1000,128 +1000,6 @@ delete Chart.instances[this.id]; }, - showTooltip : function(elements, hoverMode){ - - // Hide if no elements - if(!elements){ - if(this.options.customTooltips){ - this.options.customTooltips(false); - } - if(!this.animating){ - this.render(false, this.options.hoverAnimationDuration); - } - return; - } - - switch(hoverMode){ - case 'single': - var tooltipPosition = elements.element.tooltipPosition(); - new Chart.Tooltip({ - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - xPadding: this.options.tooltipXPadding, - yPadding: this.options.tooltipYPadding, - backgroundColor: this.options.tooltipBackgroundColor, - 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: template(this.options.tooltipTemplate, elements.element), - chart: this.chart, - custom: this.options.customTooltips - }).draw(); - break; - case 'label': - var dataArray, - dataIndex; - - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - dataArray = this.data.datasets[i].metaData; - dataIndex = indexOf(dataArray, elements[0]); - if (dataIndex !== -1){ - break; - } - } - var tooltipLabels = [], - tooltipColors = [], - medianPosition = (function(index) { - - // Get all the points at that particular index - var Elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this.data.datasets, function(dataset){ - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ - Elements.push(dataCollection[dataIndex]); - } - }); - - helpers.each(Elements, function(element) { - xPositions.push(element.x); - yPositions.push(element.y); - - - //Include any colour information about the element - tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element)); - tooltipColors.push({ - fill: element._vm.backgroundColor || element.backgroundColor, - stroke: element._vm.borderColor || element.borderColor - }); - - }, this); - - yMin = min(yPositions); - yMax = max(yPositions); - - xMin = min(xPositions); - xMax = max(xPositions); - - return { - x: (xMin > this.chart.width/2) ? xMin : xMax, - y: (yMin + yMax)/2 - }; - }).call(this, dataIndex); - - new Chart.MultiTooltip({ - x: medianPosition.x, - y: medianPosition.y, - xPadding: this.options.tooltipXPadding, - yPadding: this.options.tooltipYPadding, - xOffset: this.options.tooltipXOffset, - backgroundColor: this.options.tooltipBackgroundColor, - 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: tooltipLabels, - legendColors: tooltipColors, - legendColorBackground : this.options.multiTooltipKeyBackground, - title: elements[0].label, - chart: this.chart, - ctx: this.chart.ctx, - custom: this.options.customTooltips - }).draw(); - break; - case 'dataset': - break; - default: - } - - return this; - }, toBase64Image : function(){ return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); } @@ -1169,6 +1047,9 @@ }; Chart.Element = function(configuration){ + extend(this,{ + _vm: {}, + }); extend(this,configuration); this.initialize.apply(this,arguments); }; @@ -1180,14 +1061,14 @@ delete this._vm._start; return this; }, - transition : function(props, ease){ + transition : function(ease){ if(!this._start){ this._start = clone(this._vm); } each(this,function(value, key){ // Only non-vm properties - if(key === '_vm' || !this.hasOwnProperty(key)){ + if(key[0] === '_' || !this.hasOwnProperty(key)){ return; } @@ -1197,25 +1078,28 @@ return; } - // If transition property, do transition with ease (no pun intended) - if(props.indexOf(key) > -1){ - // Color transitions if possible - if(typeof value === 'string'){ - try{ - var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); - this._vm[key] = color.rgbString(); - } catch(err){ - this._vm[key] = value; - } - return; + // No unnecessary computations + if(this[key] === this._vm[key]){ + return; + } + + // Color transitions if possible + if(typeof value === 'string'){ + try{ + var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); + this._vm[key] = color.rgbString(); + } catch(err){ + this._vm[key] = value; } - // Everything else, presumably numbers + } + // Number transitions + else if(typeof value === 'number'){ this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; - return; } - - // Non-transitionals - this._vm[key] = value; + // Non-transitionals or strings + else{ + this._vm[key] = value; + } },this); if(ease === 1){ @@ -1416,84 +1300,181 @@ }); Chart.Tooltip = Chart.Element.extend({ + updateContent: function(){ + + switch(this._options.hoverMode){ + case 'single': + helpers.extend(this, { + text: template(this._tooltipTemplate, this._active) + }); + return this; + + } + + return; + + + var dataArray, + dataIndex; + + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + dataArray = this.data.datasets[i].metaData; + dataIndex = indexOf(dataArray, this.active[0]); + if (dataIndex !== -1){ + break; + } + } + var tooltipLabels = [], + tooltipColors = [], + medianPosition = (function(index) { + + // Get all the points at that particular index + var Elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this.data.datasets, function(dataset){ + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ + Elements.push(dataCollection[dataIndex]); + } + }); + + helpers.each(Elements, function(element) { + xPositions.push(element.x); + yPositions.push(element.y); + + + //Include any colour information about the element + tooltipLabels.push(helpers.template(this.multiTooltipTemplate, element)); + tooltipColors.push({ + fill: element._vm.backgroundColor || element.backgroundColor, + stroke: element._vm.borderColor || element.borderColor + }); + + }, this); + + yMin = min(yPositions); + yMax = max(yPositions); + + xMin = min(xPositions); + xMax = max(xPositions); + + return { + x: (xMin > this.chart.width/2) ? xMin : xMax, + y: (yMin + yMax)/2 + }; + }).call(this, dataIndex); + + new Chart.MultiTooltip({ + x: medianPosition.x, + y: medianPosition.y, + xPadding: this.tooltipXPadding, + yPadding: this.tooltipYPadding, + xOffset: this.tooltipXOffset, + backgroundColor: this.tooltipBackgroundColor, + textColor: this.tooltipFontColor, + fontFamily: this.tooltipFontFamily, + fontStyle: this.tooltipFontStyle, + fontSize: this.tooltipFontSize, + titleTextColor: this.tooltipTitleFontColor, + titleFontFamily: this.tooltipTitleFontFamily, + titleFontStyle: this.tooltipTitleFontStyle, + titleFontSize: this.tooltipTitleFontSize, + cornerRadius: this.tooltipCornerRadius, + labels: tooltipLabels, + legendColors: tooltipColors, + legendColorBackground : this.multiTooltipKeyBackground, + title: this.data.datasets[0].label, + chart: this.chart, + ctx: this.chart.ctx, + custom: this.customTooltips + }).draw(); + + return this; + }, draw : function(){ - var ctx = this.chart.ctx; - ctx.font = fontString(this.fontSize,this.fontStyle,this.fontFamily); + var ctx = this._chart.ctx; + var vm = this._vm; + + ctx.font = fontString(vm.fontSize,vm.fontStyle,vm.fontFamily); - this.xAlign = "center"; - this.yAlign = "above"; + vm.xAlign = "center"; + vm.yAlign = "above"; //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = this.caretPadding = 2; + var caretPadding = vm.caretPadding = 2; - var tooltipWidth = ctx.measureText(this.text).width + 2*this.xPadding, - tooltipRectHeight = this.fontSize + 2*this.yPadding, - tooltipHeight = tooltipRectHeight + this.caretHeight + caretPadding; + var tooltipWidth = ctx.measureText(vm.text).width + 2*vm.xPadding, + tooltipRectHeight = vm.fontSize + 2*vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - if (this.x + tooltipWidth/2 >this.chart.width){ - this.xAlign = "left"; - } else if (this.x - tooltipWidth/2 < 0){ - this.xAlign = "right"; + if (vm.x + tooltipWidth/2 >this._chart.width){ + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth/2 < 0){ + vm.xAlign = "right"; } - if (this.y - tooltipHeight < 0){ - this.yAlign = "below"; + if (vm.y - tooltipHeight < 0){ + vm.yAlign = "below"; } + var tooltipX = vm.x - tooltipWidth/2, + tooltipY = vm.y - tooltipHeight; - var tooltipX = this.x - tooltipWidth/2, - tooltipY = this.y - tooltipHeight; - - ctx.fillStyle = this.backgroundColor; + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips - if(this.custom){ - this.custom(this); + if(this._custom){ + this._custom(this._vm); } else{ - switch(this.yAlign) - { - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(this.x,this.y - caretPadding); - ctx.lineTo(this.x + this.caretHeight, this.y - (caretPadding + this.caretHeight)); - ctx.lineTo(this.x - this.caretHeight, this.y - (caretPadding + this.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = this.y + caretPadding + this.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(this.x, this.y + caretPadding); - ctx.lineTo(this.x + this.caretHeight, this.y + caretPadding + this.caretHeight); - ctx.lineTo(this.x - this.caretHeight, this.y + caretPadding + this.caretHeight); - ctx.closePath(); - ctx.fill(); - break; + switch(vm.yAlign){ + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x,vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; } - switch(this.xAlign) - { - case "left": - tooltipX = this.x - tooltipWidth + (this.cornerRadius + this.caretHeight); - break; - case "right": - tooltipX = this.x - (this.cornerRadius + this.caretHeight); - break; + switch(vm.xAlign){ + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; } - drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,this.cornerRadius); + drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,vm.cornerRadius); ctx.fill(); - ctx.fillStyle = this.textColor; + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); ctx.textAlign = "center"; ctx.textBaseline = "middle"; - ctx.fillText(this.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); + ctx.fillText(vm.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); + } } }); From 63e115e7a8547ada3d334826a3620af965029066 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 12 May 2015 15:47:24 -0600 Subject: [PATCH 017/424] hoverMode: "single" tooltips --- src/Chart.Core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index f3b000806f7..db7d16da42f 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1305,7 +1305,7 @@ switch(this._options.hoverMode){ case 'single': helpers.extend(this, { - text: template(this._tooltipTemplate, this._active) + text: template(this._options.tooltipTemplate, this._active) }); return this; From d26f37236dcd64472b91ed03f90b27e571ef469f Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 12 May 2015 18:01:28 -0400 Subject: [PATCH 018/424] Update package.json for color lib location --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 37f1d7f772b..5004db75d86 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "dependences": {}, "devDependencies": { - "color": "file:../../../../var/folders/rv/vd7mrb5j0hnbrr_2f3q2p6m00000gn/T/npm-53789-2bfe35a6/git-cache-40335d988a8e/54fd04acedef6ccdc54a9929be298945a8093496", + "color": "git://github.com/chartjs/color", "gulp": "3.5.x", "gulp-concat": "~2.1.x", "gulp-connect": "~2.0.5", From 4ef57315da7e74e16eb8a910f0b971179f08de51 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 12 May 2015 17:22:47 -0600 Subject: [PATCH 019/424] Getting into 'label' hoverMode tooltips --- samples/bar.html | 2 +- src/Chart.Bar.js | 69 +++++++++++++--------- src/Chart.Core.js | 142 ++++++++++++++++++++-------------------------- 3 files changed, 103 insertions(+), 110 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index 17afaf6af01..b698faf8ac6 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -36,7 +36,7 @@ var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx).Bar(barChartData, { responsive: true, - hoverMode: 'single', + hoverMode: 'label', scaleBeginAtZero: false, }); } diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 386e305dcb1..c7dde124a31 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -106,6 +106,8 @@ width : this.scale.calculateBarWidth(this.data.datasets.length), x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), y: this.calculateBarBase(), + _datasetIndex: datasetIndex, + _index: index, }); // Copy to view model bar.save(); @@ -114,6 +116,7 @@ // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ _chart: this.chart, + _data: this.data, _options: this.options, opacity:0, xPadding: this.options.tooltipXPadding, @@ -144,6 +147,7 @@ return false; } + // Find Active Elements this.active = function(){ switch(this.options.hoverMode){ case 'single': @@ -157,14 +161,18 @@ } }.call(this); + // On Hover hook + if(this.options.onHover){ + this.options.onHover.call(this, this.active); + } // Remove styling for last active (even if it may still be active) if(this.lastActive){ switch(this.options.hoverMode){ case 'single': - this.lastActive.element.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; - this.lastActive.element.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; - this.lastActive.element.borderWidth = 0; + this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; + this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; + this.lastActive[0].borderWidth = 0; break; case 'label': break; @@ -174,18 +182,13 @@ // do nothing } } - - // On Hover hook - if(this.options.onHover){ - this.options.onHover.call(this, this.active); - } // Built in hover actions if(this.active && this.options.hoverMode){ switch(this.options.hoverMode){ case 'single': - this.active.element.backgroundColor = this.data.datasets[this.active.datasetIndex].hoverBackgroundColor || helpers.color(this.active.element.backgroundColor).saturate(0.5).darken(0.25).rgbString(); - this.active.element.borderColor = this.data.datasets[this.active.datasetIndex].hoverBorderColor || helpers.color(this.active.element.borderColor).saturate(0.5).darken(0.25).rgbString(); + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.25).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.25).rgbString(); break; case 'label': break; @@ -200,22 +203,20 @@ // Built in Tooltips if(this.options.showTooltips){ - // The usual + // The usual updates this.tooltip.initialize(); - // Active Details + // Active if(this.active){ - var tooltipPosition = this.active.element.tooltipPosition(); helpers.extend(this.tooltip, { opacity: 1, - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - _active: this.active.element, + _active: this.active, }); - this.tooltip.updateContent(); + + this.tooltip.update(); } else{ - // Inactive Details + // Inactive helpers.extend(this.tooltip, { opacity: 0, _active: false, @@ -227,16 +228,31 @@ if(!this.animating){ // If entering if(!this.lastActive && this.active){ + console.log('entering'); this.render(false, this.options.hoverAnimationDuration); } + var changed = false; + + if (this.active.length !== this.lastActive.length){ + changed = true; + } + + helpers.each(this.active, function(element, index){ + if (element !== this.lastActive[index]){ + changed = true; + } + }, this); + // If different element - if(this.lastActive && this.active && this.lastActive.element !== this.active.element){ + if(this.lastActive && this.active && changed){ + console.log('changing'); this.render(false, this.options.hoverAnimationDuration); } // if Leaving if (this.lastActive && !this.active){ + console.log('leaving'); this.render(false, this.options.hoverAnimationDuration); } } @@ -279,6 +295,8 @@ borderColor : this.data.datasets[datasetIndex].borderColor, borderWidth : this.data.datasets[datasetIndex].borderWidth, backgroundColor : this.data.datasets[datasetIndex].backgroundColor, + _datasetIndex: datasetIndex, + _index: index, _start: undefined }); }, this); @@ -308,33 +326,28 @@ for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x,eventPosition.y)){ helpers.each(this.data.datasets, datasetIterator); - return barsArray; } } } - return barsArray; + return barsArray.length ? barsArray : false; }, // Get the single bar that was clicked on // @return : An object containing the dataset index and bar index of the matching bar. Also contains the rectangle that was drawn getBarAtEvent : function(e) { - var bar; + var bar = []; var eventPosition = helpers.getRelativePosition(e); for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - bar = { - element : this.data.datasets[datasetIndex].metaData[elementIndex], - datasetIndex : datasetIndex, - elementIndex : elementIndex, - }; + bar.push(this.data.datasets[datasetIndex].metaData[elementIndex]); return bar; } } } - return bar; + return false; }, buildScale : function(labels){ var self = this; diff --git a/src/Chart.Core.js b/src/Chart.Core.js index db7d16da42f..9f80f2fa643 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1300,102 +1300,82 @@ }); Chart.Tooltip = Chart.Element.extend({ - updateContent: function(){ - + update: function(){ switch(this._options.hoverMode){ case 'single': helpers.extend(this, { - text: template(this._options.tooltipTemplate, this._active) + text: template(this._options.tooltipTemplate, this._active), + }); + var tooltipPosition = this._active[0].tooltipPosition(); + helpers.extend(this.tooltip, { + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), }); return this; + case 'label': - } + var dataArray, + dataIndex; - return; + var tooltipLabels = [], + tooltipColors = []; + for (var i = this._data.datasets.length - 1; i >= 0; i--) { + dataArray = this._data.datasets[i].metaData; + dataIndex = indexOf(dataArray, this._active[0]); + if (dataIndex !== -1){ + break; + } + } - var dataArray, - dataIndex; + var medianPosition = (function(index) { + // Get all the points at that particular index + var elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this._data.datasets, function(dataset){ + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ + elements.push(dataCollection[dataIndex]); + } + }); - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - dataArray = this.data.datasets[i].metaData; - dataIndex = indexOf(dataArray, this.active[0]); - if (dataIndex !== -1){ - break; - } - } - var tooltipLabels = [], - tooltipColors = [], - medianPosition = (function(index) { - - // Get all the points at that particular index - var Elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this.data.datasets, function(dataset){ - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ - Elements.push(dataCollection[dataIndex]); - } - }); + helpers.each(elements, function(element) { + xPositions.push(element._vm.x); + yPositions.push(element._vm.y); - helpers.each(Elements, function(element) { - xPositions.push(element.x); - yPositions.push(element.y); + //Include any colour information about the element + tooltipLabels.push(helpers.template(this._options.multiTooltipTemplate, element)); + tooltipColors.push({ + fill: element._vm.backgroundColor, + stroke: element._vm.borderColor + }); + }, this); - //Include any colour information about the element - tooltipLabels.push(helpers.template(this.multiTooltipTemplate, element)); - tooltipColors.push({ - fill: element._vm.backgroundColor || element.backgroundColor, - stroke: element._vm.borderColor || element.borderColor - }); + yMin = min(yPositions); + yMax = max(yPositions); - }, this); - - yMin = min(yPositions); - yMax = max(yPositions); - - xMin = min(xPositions); - xMax = max(xPositions); - - return { - x: (xMin > this.chart.width/2) ? xMin : xMax, - y: (yMin + yMax)/2 - }; - }).call(this, dataIndex); - - new Chart.MultiTooltip({ - x: medianPosition.x, - y: medianPosition.y, - xPadding: this.tooltipXPadding, - yPadding: this.tooltipYPadding, - xOffset: this.tooltipXOffset, - backgroundColor: this.tooltipBackgroundColor, - textColor: this.tooltipFontColor, - fontFamily: this.tooltipFontFamily, - fontStyle: this.tooltipFontStyle, - fontSize: this.tooltipFontSize, - titleTextColor: this.tooltipTitleFontColor, - titleFontFamily: this.tooltipTitleFontFamily, - titleFontStyle: this.tooltipTitleFontStyle, - titleFontSize: this.tooltipTitleFontSize, - cornerRadius: this.tooltipCornerRadius, - labels: tooltipLabels, - legendColors: tooltipColors, - legendColorBackground : this.multiTooltipKeyBackground, - title: this.data.datasets[0].label, - chart: this.chart, - ctx: this.chart.ctx, - custom: this.customTooltips - }).draw(); + xMin = min(xPositions); + xMax = max(xPositions); - return this; + return { + x: (xMin > this._chart.width/2) ? xMin : xMax, + y: (yMin + yMax)/2 + }; + }).call(this, dataIndex); + + helpers.extend(this, { + x: medianPosition.x, + y: medianPosition.y, + }); + return this; + } }, draw : function(){ From ef4c46f2be3bc8d25cabff3eef95355ef5505b59 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 14 May 2015 17:25:56 -0600 Subject: [PATCH 020/424] labelMode Tooltips almost there! --- src/Chart.Bar.js | 16 --- src/Chart.Core.js | 294 +++++++++++++++++++++++++--------------------- 2 files changed, 160 insertions(+), 150 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index c7dde124a31..b5fb3d672d8 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -118,22 +118,6 @@ _chart: this.chart, _data: this.data, _options: this.options, - opacity:0, - xPadding: this.options.tooltipXPadding, - yPadding: this.options.tooltipYPadding, - xOffset: this.options.tooltipXOffset, - backgroundColor: this.options.tooltipBackgroundColor, - 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, - caretHeight: this.options.tooltipCaretSize, - cornerRadius: this.options.tooltipCornerRadius, - legendColorBackground : this.options.multiTooltipKeyBackground, }, this); // Update the chart with the latest data. diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 9f80f2fa643..eed7d13b84f 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -169,7 +169,7 @@ tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", // String - Template string for single tooltips - multiTooltipTemplate: "<%= value %>", + multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", // String - Colour behind the legend colour block multiTooltipKeyBackground: '#fff', @@ -1065,6 +1065,7 @@ if(!this._start){ this._start = clone(this._vm); } + each(this,function(value, key){ // Only non-vm properties @@ -1300,7 +1301,33 @@ }); Chart.Tooltip = Chart.Element.extend({ + initialize : function(){ + var options = this._options; + extend(this, { + opacity:0, + xPadding: options.tooltipXPadding, + yPadding: options.tooltipYPadding, + xOffset: options.tooltipXOffset, + backgroundColor: options.tooltipBackgroundColor, + textColor: options.tooltipFontColor, + _fontFamily: options.tooltipFontFamily, + _fontStyle: options.tooltipFontStyle, + fontSize: options.tooltipFontSize, + titleTextColor: options.tooltipTitleFontColor, + _titleFontFamily: options.tooltipTitleFontFamily, + _titleFontStyle: options.tooltipTitleFontStyle, + titleFontSize: options.tooltipTitleFontSize, + caretHeight: options.tooltipCaretSize, + cornerRadius: options.tooltipCornerRadius, + legendColorBackground : options.multiTooltipKeyBackground, + labels: [], + colors: [], + }); + }, update: function(){ + + var ctx = this._chart.ctx; + switch(this._options.hoverMode){ case 'single': helpers.extend(this, { @@ -1311,14 +1338,17 @@ x: Math.round(tooltipPosition.x), y: Math.round(tooltipPosition.y), }); - return this; + break; + case 'label': + // Tooltip Content + var dataArray, dataIndex; - var tooltipLabels = [], - tooltipColors = []; + var labels = [], + colors = []; for (var i = this._data.datasets.length - 1; i >= 0; i--) { dataArray = this._data.datasets[i].metaData; @@ -1350,8 +1380,8 @@ yPositions.push(element._vm.y); //Include any colour information about the element - tooltipLabels.push(helpers.template(this._options.multiTooltipTemplate, element)); - tooltipColors.push({ + labels.push(helpers.template(this._options.multiTooltipTemplate, element)); + colors.push({ fill: element._vm.backgroundColor, stroke: element._vm.borderColor }); @@ -1366,134 +1396,168 @@ return { x: (xMin > this._chart.width/2) ? xMin : xMax, - y: (yMin + yMax)/2 + y: (yMin + yMax)/2, }; }).call(this, dataIndex); + // Apply for now helpers.extend(this, { x: medianPosition.x, y: medianPosition.y, + labels: labels, + title: this._active[0].label, + legendColors: colors, + legendBackgroundColor : this._options.multiTooltipKeyBackground, }); - return this; + + + // Calculate Appearance Tweaks + + this.height = (labels.length * this.fontSize) + ((labels.length-1) * (this.fontSize/2)) + (this.yPadding*2) + this.titleFontSize *1.5; + + var titleWidth = ctx.measureText(this.title).width, + //Label has a legend square as well so account for this. + labelWidth = longestText(ctx,this.font,labels) + this.fontSize + 3, + longestTextWidth = max([labelWidth,titleWidth]); + + this.width = longestTextWidth + (this.xPadding*2); + + + var halfHeight = this.height/2; + + //Check to ensure the height will fit on the canvas + if (this.y - halfHeight < 0 ){ + this.y = halfHeight; + } else if (this.y + halfHeight > this._chart.height){ + this.y = this._chart.height - halfHeight; + } + + //Decide whether to align left or right based on position on canvas + if (this.x > this._chart.width/2){ + this.x -= this.xOffset + this.width; + } else { + this.x += this.xOffset; + } + break; } + + return this; }, draw : function(){ - var ctx = this._chart.ctx; var vm = this._vm; - ctx.font = fontString(vm.fontSize,vm.fontStyle,vm.fontFamily); + switch(this._options.hoverMode){ + case 'single': - vm.xAlign = "center"; - vm.yAlign = "above"; + ctx.font = fontString(vm.fontSize,vm.fontStyle,vm.fontFamily); - //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding = 2; + vm.xAlign = "center"; + vm.yAlign = "above"; - var tooltipWidth = ctx.measureText(vm.text).width + 2*vm.xPadding, - tooltipRectHeight = vm.fontSize + 2*vm.yPadding, - tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; + //Distance between the actual element.y position and the start of the tooltip caret + var caretPadding = vm.caretPadding = 2; - if (vm.x + tooltipWidth/2 >this._chart.width){ - vm.xAlign = "left"; - } else if (vm.x - tooltipWidth/2 < 0){ - vm.xAlign = "right"; - } + var tooltipWidth = ctx.measureText(vm.text).width + 2*vm.xPadding, + tooltipRectHeight = vm.fontSize + 2*vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - if (vm.y - tooltipHeight < 0){ - vm.yAlign = "below"; - } + if (vm.x + tooltipWidth/2 >this._chart.width){ + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth/2 < 0){ + vm.xAlign = "right"; + } - var tooltipX = vm.x - tooltipWidth/2, - tooltipY = vm.y - tooltipHeight; + if (vm.y - tooltipHeight < 0){ + vm.yAlign = "below"; + } - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + var tooltipX = vm.x - tooltipWidth/2, + tooltipY = vm.y - tooltipHeight; - // Custom Tooltips - if(this._custom){ - this._custom(this._vm); - } - else{ - switch(vm.yAlign){ - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x,vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - switch(vm.xAlign){ - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } + // Custom Tooltips + if(this._custom){ + this._custom(this._vm); + } + else{ + switch(vm.yAlign){ + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x,vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } - drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,vm.cornerRadius); + switch(vm.xAlign){ + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } - ctx.fill(); + drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); + ctx.fill(); - } - } - }); + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); - Chart.MultiTooltip = Chart.Element.extend({ - initialize : function(){ - this.font = fontString(this.fontSize,this.fontStyle,this.fontFamily); + } + break; + case 'label': - this.titleFont = fontString(this.titleFontSize,this.titleFontStyle,this.titleFontFamily); + drawRoundedRectangle(ctx,vm.x,vm.y - vm.height/2,vm.width,vm.height,vm.cornerRadius); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + ctx.fill(); + ctx.closePath(); - this.height = (this.labels.length * this.fontSize) + ((this.labels.length-1) * (this.fontSize/2)) + (this.yPadding*2) + this.titleFontSize *1.5; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); + ctx.font = vm.titleFont; - this.ctx.font = this.titleFont; + ctx.fillText(vm.title,vm.x + vm.xPadding, this.getLineHeight(0)); - var titleWidth = this.ctx.measureText(this.title).width, - //Label has a legend square as well so account for this. - labelWidth = longestText(this.ctx,this.font,this.labels) + this.fontSize + 3, - longestTextWidth = max([labelWidth,titleWidth]); + ctx.font = vm.font; + helpers.each(vm.labels,function(label,index){ + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.fillText(label,vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); - this.width = longestTextWidth + (this.xPadding*2); + //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) + //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + //Instead we'll make a white filled block to put the legendColour palette over. + ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); - var halfHeight = this.height/2; + ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); - //Check to ensure the height will fit on the canvas - if (this.y - halfHeight < 0 ){ - this.y = halfHeight; - } else if (this.y + halfHeight > this.chart.height){ - this.y = this.chart.height - halfHeight; - } - //Decide whether to align left or right based on position on canvas - if (this.x > this.chart.width/2){ - this.x -= this.xOffset + this.width; - } else { - this.x += this.xOffset; + },this); + break; } - - }, getLineHeight : function(index){ var baseLineHeight = this.y - (this.height/2) + this.yPadding, @@ -1507,44 +1571,6 @@ } }, - draw : function(){ - // Custom Tooltips - if(this.custom){ - this.custom(this); - } - else{ - drawRoundedRectangle(this.ctx,this.x,this.y - this.height/2,this.width,this.height,this.cornerRadius); - var ctx = this.ctx; - ctx.fillStyle = this.backgroundColor; - ctx.fill(); - ctx.closePath(); - - ctx.textAlign = "left"; - ctx.textBaseline = "middle"; - ctx.fillStyle = this.titleTextColor; - ctx.font = this.titleFont; - - ctx.fillText(this.title,this.x + this.xPadding, this.getLineHeight(0)); - - ctx.font = this.font; - helpers.each(this.labels,function(label,index){ - ctx.fillStyle = this.textColor; - ctx.fillText(label,this.x + this.xPadding + this.fontSize + 3, this.getLineHeight(index + 1)); - - //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) - //ctx.clearRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize/2, this.fontSize, this.fontSize); - //Instead we'll make a white filled block to put the legendColour palette over. - - ctx.fillStyle = this.legendColorBackground; - ctx.fillRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize/2, this.fontSize, this.fontSize); - - ctx.fillStyle = this.legendColors[index].fill; - ctx.fillRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize/2, this.fontSize, this.fontSize); - - - },this); - } - } }); Chart.Scale = Chart.Element.extend({ From b432a3d6dbacb0852d4acc623498188d71670107 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 14 May 2015 23:18:47 -0600 Subject: [PATCH 021/424] labelMode tooltips and hover events --- Chart.js | 861 +++++++++++++++++++++++++--------------------- Chart.min.js | 6 +- samples/bar.html | 1 + src/Chart.Bar.js | 50 ++- src/Chart.Core.js | 64 ++-- 5 files changed, 543 insertions(+), 439 deletions(-) diff --git a/Chart.js b/Chart.js index 4a26d8b9eb3..acb14e30c2f 100644 --- a/Chart.js +++ b/Chart.js @@ -169,7 +169,7 @@ tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", // String - Template string for single tooltips - multiTooltipTemplate: "<%= value %>", + multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", // String - Colour behind the legend colour block multiTooltipKeyBackground: '#fff', @@ -883,9 +883,21 @@ ctx.lineTo(x, y + radius); ctx.quadraticCurveTo(x, y, x + radius, y); ctx.closePath(); + }, + color = helpers.color = function(color){ + if(!window.Color){ + console.log('Color.js not found!'); + return color; + } + return window.Color(color); + }, + isArray = helpers.isArray = function(obj){ + if (!Array.isArray) { + return Object.prototype.toString.call(arg) === '[object Array]'; + } + return Array.isArray(obj); }; - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. //Destroy method on the chart will remove the instance of the chart from this reference. Chart.instances = {}; @@ -957,7 +969,7 @@ animation.onAnimationProgress = this.options.onAnimationProgress; animation.onAnimationComplete = this.options.onAnimationComplete; - Chart.animationService.addAnimation(this, animation); + Chart.animationService.addAnimation(this, animation, customDuration); } else{ this.draw(); @@ -988,144 +1000,6 @@ delete Chart.instances[this.id]; }, - showTooltip : function(ChartElements, forceRedraw){ - // Only redraw the chart if we've actually changed what we're hovering on. - if (typeof this.activeElements === 'undefined') this.activeElements = []; - - var isChanged = (function(Elements){ - var changed = false; - - if (Elements.length !== this.activeElements.length){ - changed = true; - return changed; - } - - each(Elements, function(element, index){ - if (element !== this.activeElements[index]){ - changed = true; - } - }, this); - return changed; - }).call(this, ChartElements); - - if (!isChanged && !forceRedraw){ - return; - } - else{ - this.activeElements = ChartElements; - } - this.draw(); - if(this.options.customTooltips){ - this.options.customTooltips(false); - } - if (ChartElements.length > 0){ - // If we have multiple datasets, show a MultiTooltip for all of the data points at that index - if (this.data.datasets && this.data.datasets.length > 1) { - var dataArray, - dataIndex; - - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - dataArray = this.data.datasets[i].metaData; - dataIndex = indexOf(dataArray, ChartElements[0]); - if (dataIndex !== -1){ - break; - } - } - var tooltipLabels = [], - tooltipColors = [], - medianPosition = (function(index) { - - // Get all the points at that particular index - var Elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this.data.datasets, function(dataset){ - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ - Elements.push(dataCollection[dataIndex]); - } - }); - - helpers.each(Elements, function(element) { - xPositions.push(element.x); - yPositions.push(element.y); - - - //Include any colour information about the element - tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element)); - tooltipColors.push({ - fill: element._vm.backgroundColor || element.backgroundColor, - stroke: element._vm.borderColor || element.borderColor - }); - - }, this); - - yMin = min(yPositions); - yMax = max(yPositions); - - xMin = min(xPositions); - xMax = max(xPositions); - - return { - x: (xMin > this.chart.width/2) ? xMin : xMax, - y: (yMin + yMax)/2 - }; - }).call(this, dataIndex); - - new Chart.MultiTooltip({ - x: medianPosition.x, - y: medianPosition.y, - xPadding: this.options.tooltipXPadding, - yPadding: this.options.tooltipYPadding, - xOffset: this.options.tooltipXOffset, - backgroundColor: this.options.tooltipBackgroundColor, - 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: tooltipLabels, - legendColors: tooltipColors, - legendColorBackground : this.options.multiTooltipKeyBackground, - title: ChartElements[0].label, - chart: this.chart, - ctx: this.chart.ctx, - custom: this.options.customTooltips - }).draw(); - - } else { - each(ChartElements, function(Element) { - var tooltipPosition = Element.tooltipPosition(); - new Chart.Tooltip({ - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - xPadding: this.options.tooltipXPadding, - yPadding: this.options.tooltipYPadding, - backgroundColor: this.options.tooltipBackgroundColor, - 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: template(this.options.tooltipTemplate, Element), - chart: this.chart, - custom: this.options.customTooltips - }).draw(); - }, this); - } - } - return this; - }, toBase64Image : function(){ return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); } @@ -1173,6 +1047,9 @@ }; Chart.Element = function(configuration){ + extend(this,{ + _vm: {}, + }); extend(this,configuration); this.initialize.apply(this,arguments); }; @@ -1184,14 +1061,22 @@ delete this._vm._start; return this; }, - transition : function(props, ease){ + pivot: function(){ + if(this._start){ + this._start = clone(this); + helpers.extend(this._start, this._vm); + } + return this; + }, + transition : function(ease){ if(!this._start){ this._start = clone(this._vm); } + each(this,function(value, key){ // Only non-vm properties - if(key === '_vm' || !this.hasOwnProperty(key)){ + if(key[0] === '_' || !this.hasOwnProperty(key)){ return; } @@ -1201,25 +1086,28 @@ return; } - // If transition property, do transition with ease (no pun intended) - if(props.indexOf(key) > -1){ - // Color transitions if possible - if(typeof value === 'string'){ - try{ - var color = Color(this._start[key]).mix(Color(this[key]), ease); - this._vm[key] = color.rgbString(); - } catch(err){ - this._vm[key] = value; - } - return; + // No unnecessary computations + if(this[key] === this._vm[key]){ + return; + } + + // Color transitions if possible + if(typeof value === 'string'){ + try{ + var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); + this._vm[key] = color.rgbString(); + } catch(err){ + this._vm[key] = value; } - // Everything else, presumably numbers + } + // Number transitions + else if(typeof value === 'number'){ this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; - return; } - - // Non-transitionals - this._vm[key] = value; + // Non-transitionals or strings + else{ + this._vm[key] = value; + } },this); if(ease === 1){ @@ -1385,8 +1273,27 @@ }, inRange : function(chartX,chartY){ var vm = this._vm; - return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= vm.base); - } + if (vm.y < vm.base){ + return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= vm.base); + } else{ + return (chartX >= vm.x - vm.width / 2 && chartX <= vm.x + vm.width / 2) && (chartY >= vm.base && chartY <= vm.y); + } + }, + tooltipPosition : function(){ + var vm = this._vm; + if (vm.y < vm.base){ + return { + x : vm.x, + y : vm.y + }; + } + else{ + return { + x : vm.x, + y : vm.base + }; + } + }, }); Chart.Animation = Chart.Element.extend({ @@ -1400,174 +1307,275 @@ }); Chart.Tooltip = Chart.Element.extend({ - draw : function(){ + initialize : function(){ + var options = this._options; + extend(this, { + opacity:0, + xPadding: options.tooltipXPadding, + yPadding: options.tooltipYPadding, + xOffset: options.tooltipXOffset, + backgroundColor: options.tooltipBackgroundColor, + textColor: options.tooltipFontColor, + _fontFamily: options.tooltipFontFamily, + _fontStyle: options.tooltipFontStyle, + fontSize: options.tooltipFontSize, + titleTextColor: options.tooltipTitleFontColor, + _titleFontFamily: options.tooltipTitleFontFamily, + _titleFontStyle: options.tooltipTitleFontStyle, + titleFontSize: options.tooltipTitleFontSize, + caretHeight: options.tooltipCaretSize, + cornerRadius: options.tooltipCornerRadius, + legendColorBackground : options.multiTooltipKeyBackground, + labels: [], + colors: [], + }); + }, + update: function(){ - var ctx = this.chart.ctx; + var ctx = this._chart.ctx; - ctx.font = fontString(this.fontSize,this.fontStyle,this.fontFamily); + switch(this._options.hoverMode){ + case 'single': + helpers.extend(this, { + text: template(this._options.tooltipTemplate, this._active), + }); + var tooltipPosition = this._active[0].tooltipPosition(); + helpers.extend(this.tooltip, { + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + }); + break; - this.xAlign = "center"; - this.yAlign = "above"; + case 'label': - //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = this.caretPadding = 2; + // Tooltip Content - var tooltipWidth = ctx.measureText(this.text).width + 2*this.xPadding, - tooltipRectHeight = this.fontSize + 2*this.yPadding, - tooltipHeight = tooltipRectHeight + this.caretHeight + caretPadding; + var dataArray, + dataIndex; - if (this.x + tooltipWidth/2 >this.chart.width){ - this.xAlign = "left"; - } else if (this.x - tooltipWidth/2 < 0){ - this.xAlign = "right"; - } + var labels = [], + colors = []; - if (this.y - tooltipHeight < 0){ - this.yAlign = "below"; - } + for (var i = this._data.datasets.length - 1; i >= 0; i--) { + dataArray = this._data.datasets[i].metaData; + dataIndex = indexOf(dataArray, this._active[0]); + if (dataIndex !== -1){ + break; + } + } + var medianPosition = (function(index) { + // Get all the points at that particular index + var elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this._data.datasets, function(dataset){ + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ + elements.push(dataCollection[dataIndex]); + } + }); - var tooltipX = this.x - tooltipWidth/2, - tooltipY = this.y - tooltipHeight; + helpers.each(elements, function(element) { + xPositions.push(element._vm.x); + yPositions.push(element._vm.y); - ctx.fillStyle = this.backgroundColor; + //Include any colour information about the element + labels.push(helpers.template(this._options.multiTooltipTemplate, element)); + colors.push({ + fill: element._vm.backgroundColor, + stroke: element._vm.borderColor + }); - // Custom Tooltips - if(this.custom){ - this.custom(this); - } - else{ - switch(this.yAlign) - { - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(this.x,this.y - caretPadding); - ctx.lineTo(this.x + this.caretHeight, this.y - (caretPadding + this.caretHeight)); - ctx.lineTo(this.x - this.caretHeight, this.y - (caretPadding + this.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = this.y + caretPadding + this.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(this.x, this.y + caretPadding); - ctx.lineTo(this.x + this.caretHeight, this.y + caretPadding + this.caretHeight); - ctx.lineTo(this.x - this.caretHeight, this.y + caretPadding + this.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } + }, this); - switch(this.xAlign) - { - case "left": - tooltipX = this.x - tooltipWidth + (this.cornerRadius + this.caretHeight); - break; - case "right": - tooltipX = this.x - (this.cornerRadius + this.caretHeight); - break; - } + yMin = min(yPositions); + yMax = max(yPositions); - drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,this.cornerRadius); + xMin = min(xPositions); + xMax = max(xPositions); - ctx.fill(); + return { + x: (xMin > this._chart.width/2) ? xMin : xMax, + y: (yMin + yMax)/2, + }; + }).call(this, dataIndex); - ctx.fillStyle = this.textColor; - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(this.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); - } - } - }); + // Apply for now + helpers.extend(this, { + x: medianPosition.x, + y: medianPosition.y, + labels: labels, + title: this._active.length ? this._active[0].label : '', + legendColors: colors, + legendBackgroundColor : this._options.multiTooltipKeyBackground, + }); - Chart.MultiTooltip = Chart.Element.extend({ - initialize : function(){ - this.font = fontString(this.fontSize,this.fontStyle,this.fontFamily); - this.titleFont = fontString(this.titleFontSize,this.titleFontStyle,this.titleFontFamily); + // Calculate Appearance Tweaks - this.height = (this.labels.length * this.fontSize) + ((this.labels.length-1) * (this.fontSize/2)) + (this.yPadding*2) + this.titleFontSize *1.5; + this.height = (labels.length * this.fontSize) + ((labels.length-1) * (this.fontSize/2)) + (this.yPadding*2) + this.titleFontSize *1.5; - this.ctx.font = this.titleFont; + var titleWidth = ctx.measureText(this.title).width, + //Label has a legend square as well so account for this. + labelWidth = longestText(ctx,this.font,labels) + this.fontSize + 3, + longestTextWidth = max([labelWidth,titleWidth]); - var titleWidth = this.ctx.measureText(this.title).width, - //Label has a legend square as well so account for this. - labelWidth = longestText(this.ctx,this.font,this.labels) + this.fontSize + 3, - longestTextWidth = max([labelWidth,titleWidth]); + this.width = longestTextWidth + (this.xPadding*2); - this.width = longestTextWidth + (this.xPadding*2); + var halfHeight = this.height/2; - var halfHeight = this.height/2; + //Check to ensure the height will fit on the canvas + if (this.y - halfHeight < 0 ){ + this.y = halfHeight; + } else if (this.y + halfHeight > this._chart.height){ + this.y = this._chart.height - halfHeight; + } - //Check to ensure the height will fit on the canvas - if (this.y - halfHeight < 0 ){ - this.y = halfHeight; - } else if (this.y + halfHeight > this.chart.height){ - this.y = this.chart.height - halfHeight; + //Decide whether to align left or right based on position on canvas + if (this.x > this._chart.width/2){ + this.x -= this.xOffset + this.width; + } else { + this.x += this.xOffset; + } + break; } - //Decide whether to align left or right based on position on canvas - if (this.x > this.chart.width/2){ - this.x -= this.xOffset + this.width; - } else { - this.x += this.xOffset; - } + return this; + }, + draw : function(){ + var ctx = this._chart.ctx; + var vm = this._vm; - }, - getLineHeight : function(index){ - var baseLineHeight = this.y - (this.height/2) + this.yPadding, - afterTitleIndex = index-1; + switch(this._options.hoverMode){ + case 'single': - //If the index is zero, we're getting the title - if (index === 0){ - return baseLineHeight + this.titleFontSize/2; - } else{ - return baseLineHeight + ((this.fontSize*1.5*afterTitleIndex) + this.fontSize/2) + this.titleFontSize * 1.5; - } + ctx.font = fontString(vm.fontSize,vm._fontStyle,vm._fontFamily); - }, - draw : function(){ - // Custom Tooltips - if(this.custom){ - this.custom(this); - } - else{ - drawRoundedRectangle(this.ctx,this.x,this.y - this.height/2,this.width,this.height,this.cornerRadius); - var ctx = this.ctx; - ctx.fillStyle = this.backgroundColor; - ctx.fill(); - ctx.closePath(); + vm.xAlign = "center"; + vm.yAlign = "above"; - ctx.textAlign = "left"; - ctx.textBaseline = "middle"; - ctx.fillStyle = this.titleTextColor; - ctx.font = this.titleFont; + //Distance between the actual element.y position and the start of the tooltip caret + var caretPadding = vm.caretPadding = 2; - ctx.fillText(this.title,this.x + this.xPadding, this.getLineHeight(0)); + var tooltipWidth = ctx.measureText(vm.text).width + 2*vm.xPadding, + tooltipRectHeight = vm.fontSize + 2*vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - ctx.font = this.font; - helpers.each(this.labels,function(label,index){ - ctx.fillStyle = this.textColor; - ctx.fillText(label,this.x + this.xPadding + this.fontSize + 3, this.getLineHeight(index + 1)); + if (vm.x + tooltipWidth/2 >this._chart.width){ + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth/2 < 0){ + vm.xAlign = "right"; + } - //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) - //ctx.clearRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize/2, this.fontSize, this.fontSize); - //Instead we'll make a white filled block to put the legendColour palette over. + if (vm.y - tooltipHeight < 0){ + vm.yAlign = "below"; + } - ctx.fillStyle = this.legendColorBackground; - ctx.fillRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize/2, this.fontSize, this.fontSize); + var tooltipX = vm.x - tooltipWidth/2, + tooltipY = vm.y - tooltipHeight; - ctx.fillStyle = this.legendColors[index].fill; - ctx.fillRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize/2, this.fontSize, this.fontSize); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + // Custom Tooltips + if(this._custom){ + this._custom(this._vm); + } + else{ + switch(vm.yAlign){ + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x,vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } - },this); + switch(vm.xAlign){ + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } + + drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,vm.cornerRadius); + + ctx.fill(); + + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); + + } + break; + case 'label': + + drawRoundedRectangle(ctx, vm.x, vm.y - vm.height/2, vm.width, vm.height, vm.cornerRadius); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + ctx.fill(); + ctx.closePath(); + + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); + ctx.font = fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); + ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); + + ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + helpers.each(vm.labels,function(label,index){ + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.fillText(label,vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); + + //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) + //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + //Instead we'll make a white filled block to put the legendColour palette over. + + ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + + },this); + break; } - } + }, + getLineHeight : function(index){ + var baseLineHeight = this._vm.y - (this._vm.height/2) + this._vm.yPadding, + afterTitleIndex = index-1; + + //If the index is zero, we're getting the title + if (index === 0){ + return baseLineHeight + this._vm.titleFontSize/2; + } else{ + return baseLineHeight + ((this._vm.fontSize*1.5*afterTitleIndex) + this._vm.fontSize/2) + this._vm.titleFontSize * 1.5; + } + + }, }); Chart.Scale = Chart.Element.extend({ @@ -2037,7 +2045,7 @@ } } if(this.showLabels){ - ctx.font = fontString(this.fontSize,this.fontStyle,this.fontFamily); + ctx.font = fontString(this.fontSize,this._fontStyle,this._fontFamily); if (this.showLabelBackdrop){ var labelWidth = ctx.measureText(label).width; ctx.fillStyle = this.backdropColor; @@ -2108,8 +2116,11 @@ frameDuration: 17, animations: [], dropFrames: 0, - addAnimation: function(chartInstance, animationObject) { - chartInstance.animating = true; + addAnimation: function(chartInstance, animationObject, customDuration) { + + if(!customDuration){ + chartInstance.animating = true; + } for (var index = 0; index < this.animations.length; ++ index){ if (this.animations[index].chartInstance === chartInstance){ @@ -2263,14 +2274,14 @@ //Number - Spacing between data sets within X values barDatasetSpacing : 1, - //String - Hover mode for events - hoverMode : 'bars', // 'bar', 'dataset' + //String / Boolean - Hover mode for events. + hoverMode : 'single', // 'label', 'dataset', 'false' //Function - Custom hover handler onHover : null, //Function - Custom hover handler - hoverDuration : 400, + hoverAnimationDuration : 400, //String - A legend template legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " @@ -2291,10 +2302,10 @@ this.ScaleClass = Chart.Scale.extend({ offsetGridLines : true, - calculateBarX : function(datasetCount, datasetIndex, barIndex){ + calculateBarX : function(datasetCount, datasetIndex, elementIndex){ //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar var xWidth = this.calculateBaseWidth(), - xAbsolute = this.calculateX(barIndex) - (xWidth/2), + xAbsolute = this.calculateX(elementIndex) - (xWidth/2), barWidth = this.calculateBarWidth(datasetCount); return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth/2; @@ -2316,7 +2327,6 @@ //Declare the extension of the default point, to cater for the options passed in to the constructor this.BarClass = Chart.Rectangle.extend({ ctx : this.chart.ctx, - _vm: {} }); // Build Scale @@ -2335,72 +2345,179 @@ helpers.extend(bar, { width : this.scale.calculateBarWidth(this.data.datasets.length), x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.endPoint, + y: this.calculateBarBase(), + _datasetIndex: datasetIndex, + _index: index, }); // Copy to view model bar.save(); }, this); + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Update the chart with the latest data. this.update(); }, onHover: function(e){ - var active; + + // If exiting chart if(e.type == 'mouseout'){ return false; } - if(this.options.hoverMode == 'bar'){ - active = this.getBarAtEvent(e); - } - else if(this.options.hoverMode == 'bars'){} + this.lastActive = this.lastActive || []; - // Remove styling for last active - if(this.lastActive){ - if(this.options.hoverMode == 'bar'){ - this.lastActive.rectangle.backgroundColor = this.data.datasets[this.lastActive.datasetIndex].backgroundColor; - this.lastActive.rectangle.borderColor = this.data.datasets[this.lastActive.datasetIndex].borderColor; - this.lastActive.rectangle.borderWidth = 0; + // Find Active Elements + this.active = function(){ + switch(this.options.hoverMode){ + case 'single': + return this.getBarAtEvent(e); + case 'label': + return this.getBarsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; } - else if(this.options.hoverMode == 'bars'){} - } + }.call(this); - // Custom Hover actions + // On Hover hook if(this.options.onHover){ - this.options.onHover.call(this, active); + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if(this.lastActive){ + switch(this.options.hoverMode){ + case 'single': + this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; + this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; + this.lastActive[0].borderWidth = 0; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; + this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; + this.lastActive[i].borderWidth = 0; + } + break; + case 'dataset': + break; + default: + // do nothing + } } - else if(active){ - // or default hover action - if(this.options.hoverMode == 'bar'){ - active.rectangle.backgroundColor = this.data.datasets[active.datasetIndex].hoverBackgroundColor || Color(active.rectangle.backgroundColor).saturate(0.5).darken(0.25).rgbString(); - active.rectangle.borderColor = this.data.datasets[active.datasetIndex].hoverBorderColor || Color(active.rectangle.borderColor).saturate(0.5).darken(0.25).rgbString(); + + // Built in hover actions + if(this.active.length && this.options.hoverMode){ + switch(this.options.hoverMode){ + case 'single': + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + } + break; + case 'dataset': + break; + default: + // do nothing } - else if(this.options.hoverMode == 'bars'){} + } + + + // Built in Tooltips + if(this.options.showTooltips){ + + // The usual updates + this.tooltip.initialize(); + // Active + if(this.active.length){ + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } + else{ + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } } + if(!this.animating){ + // If entering - if(!this.lastActive && active){ - this.render(false, this.options.hoverDuration); + if(!this.lastActive.length && this.active.length){ + console.log('entering'); + this.tooltip.pivot(); + this.stop(); + this.render(false, this.options.hoverAnimationDuration); } - // If different bar - if(this.lastActive && active && this.lastActive.rectangle !== active.rectangle){ - this.render(false, this.options.hoverDuration); + var changed; + + helpers.each(this.active, function(element, index){ + if (element !== this.lastActive[index]){ + changed = true; + } + }, this); + + // If different element + if(this.lastActive.length && this.active.length && changed){ + console.log('changing'); + this.tooltip.pivot(); + this.stop(); + this.render(false, this.options.hoverAnimationDuration); } // if Leaving - if (this.lastActive && !active){ - this.render(false, this.options.hoverDuration); + if (this.lastActive.length && !this.active.length){ + console.log('leaving'); + this.tooltip.pivot(); + this.stop(); + this.render(false, this.options.hoverAnimationDuration); } - } - this.lastActive = active; + } - if (this.options.showTooltips){ - this.showTooltip(active); + // Remember Last Active + + this.lastActive = this.active; + }, + // Calculate the base point for the bar. + // If the scale has a 0 point, use that as the base + // If the scale min and max are both positive, use the bottom as a base + // If the scale min and max are both negative, use the top as a base + calculateBarBase: function() { + var base = this.scale.endPoint; + + if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) + { + base = this.scale.calculateY(0); + base += this.options.scaleGridLineWidth; + } + else if (this.scale.min < 0 && this.scale.max < 0) + { + // All values are negative. Use the top as the base + base = this.scale.startPoint; } + + return base; }, update : function(){ @@ -2417,11 +2534,12 @@ borderColor : this.data.datasets[datasetIndex].borderColor, borderWidth : this.data.datasets[datasetIndex].borderWidth, backgroundColor : this.data.datasets[datasetIndex].backgroundColor, + _datasetIndex: datasetIndex, + _index: index, _start: undefined }); }, this); - this.render(); }, eachBars : function(callback){ @@ -2438,41 +2556,36 @@ var barsArray = [], eventPosition = helpers.getRelativePosition(e), datasetIterator = function(dataset){ - barsArray.push(dataset.metaData[barIndex]); + barsArray.push(dataset.metaData[elementIndex]); }, - barIndex; + elementIndex; for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; barIndex++) { - if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x,eventPosition.y)){ + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x,eventPosition.y)){ helpers.each(this.data.datasets, datasetIterator); - return barsArray; } } } - return barsArray; + return barsArray.length ? barsArray : []; }, // Get the single bar that was clicked on // @return : An object containing the dataset index and bar index of the matching bar. Also contains the rectangle that was drawn getBarAtEvent : function(e) { - var bar; + var bar = []; var eventPosition = helpers.getRelativePosition(e); for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var barIndex = 0; barIndex < this.data.datasets[datasetIndex].metaData.length; ++barIndex) { - if (this.data.datasets[datasetIndex].metaData[barIndex].inRange(eventPosition.x, eventPosition.y)) { - bar = { - rectangle : this.data.datasets[datasetIndex].metaData[barIndex], - datasetIndex : datasetIndex, - barIndex : barIndex, - }; + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + bar.push(this.data.datasets[datasetIndex].metaData[elementIndex]); return bar; } } } - return bar; + return []; }, buildScale : function(labels){ var self = this; @@ -2532,46 +2645,18 @@ this.scale = new this.ScaleClass(scaleOptions); }, - addData : function(valuesArray,label){ - //Map the values array for each of the datasets - helpers.each(valuesArray,function(value,datasetIndex){ - //Add a new point for each piece of data, passing any required data to draw. - this.data.datasets[datasetIndex].bars.push(new this.BarClass({ - value : value, - label : label, - datasetLabel: this.data.datasets[datasetIndex].label, - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, this.scale.valuesCount+1), - y: this.scale.endPoint, - width : this.scale.calculateBarWidth(this.data.datasets.length), - base : this.scale.endPoint, - borderColor : this.data.datasets[datasetIndex].borderColor, - backgroundColor : this.data.datasets[datasetIndex].backgroundColor - })); - },this); - - this.scale.addXLabel(label); - //Then re-render the chart. - this.update(); - }, - removeData : function(){ - this.scale.removeXLabel(); - //Then re-render the chart. - helpers.each(this.data.datasets,function(dataset){ - dataset.bars.shift(); - },this); - this.update(); - }, - reflow : function(){ + // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function + /*reflow : function(){ helpers.extend(this.BarClass.prototype,{ - y: this.scale.endPoint, - base : this.scale.endPoint + y: this.calculateBarBase(), // so that we animate from the baseline + base : this.calculateBarBase() }); var newScaleProps = helpers.extend({ height : this.chart.height, width : this.chart.width }); this.scale.update(newScaleProps); - }, + },*/ draw : function(ease){ var easingDecimal = ease || 1; @@ -2583,18 +2668,14 @@ this.eachBars(function(bar, index, datasetIndex){ if (bar.hasValue()){ // Update the bar basepoint - bar.base = this.scale.endPoint; + bar.base = this.calculateBarBase(); //Transition - bar.transition([ - 'x', - 'y', - 'width', - 'backgroundColor', - 'borderColor', - 'borderWidth' - ], easingDecimal).draw(); + bar.transition(easingDecimal).draw(); } }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); } }); diff --git a/Chart.min.js b/Chart.min.js index 77e12387a4b..0b03b1c444a 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,6 +7,6 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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(){}}},i.types={};var s=i.helpers={},n=s.each=function(t,e,i){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(e(n))return n}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},s=function(){this.constructor=i};return s.prototype=e.prototype,i.prototype=new s,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),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 define&&define.amd,g=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=s.max=function(t){return Math.max.apply(Math,t)},v=s.min=function(t){return Math.min.apply(Math,t)},m=(s.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=s.radians=function(t){return t*(Math.PI/180)},y=(s.getAngleFromPoint=function(t,e){var i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s),a=2*Math.PI+Math.atan2(s,i);return 0>i&&0>s&&(a+=2*Math.PI),{angle:a,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),w=(s.splineCurve=function(t,e,i,s){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=s*n/(n+a),r=s*a/(n+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(s.calculateScaleRange=function(t,e,i,s,n){var a=2,o=Math.floor(e/(1.5*i)),r=a>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!s?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=a,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},s.template=function(t,e){function i(t,e){var i=/\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 e?i(e):i}if(t instanceof Function)return t(e);var s={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,s){var a=new Array(e);return t&&n(a,function(e,n){a[n]=S(t,{value:i+s*(n+1)})}),a},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 e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),st?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(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,e,i,s,n,a){var o=0,r=x[i]||x.linear,h=function(){o++;var i=o/e,l=r(i);t.call(a,l,i,o),s.call(a,l,i),e>o?a.animationFrame=C(h):n.apply(a)};C(h)},s.getRelativePosition=function(t){var e,i,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,a=n.getBoundingClientRect();return s.touches?(e=s.touches[0].clientX-a.left,i=s.touches[0].clientY-a.top):(e=s.clientX-a.left,i=s.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(s.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),M=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-left"))+parseInt(F(e,"padding-right"));return e.clientWidth-i},A=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-bottom"))+parseInt(F(e,"padding-top"));return e.clientHeight-i},F=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=s+"px",e.canvas.height=s*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),T=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},z=s.longestText=function(t,e,i){t.font=e;var s=0;return n(i,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},O=s.drawRoundedRectangle=function(t,e,i,s,n,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+s-a,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+n-a),t.quadraticCurveTo(e+s,i+n,e+s-a,i+n),t.lineTo(e+a,i+n),t.quadraticCurveTo(e,i+n,e,i+n-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};i.instances={},i.Type=function(t,e,s){this.options=e,this.chart=s,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return T(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=M(this.chart.canvas),s=this.options.maintainAspectRatio?i/this.chart.aspectRatio:A(this.chart.canvas);return e.width=this.chart.width=i,e.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,e){if(t&&this.reflow(),this.options.animation&&!t){var n=new i.Animation;n.numSteps=(e||this.options.animationDuration)/16.66,n.easing=this.options.animationEasing,n.render=function(t,e){var i=s.easingEffects[e.easing],n=e.currentStep/e.numSteps,a=i(n);t.draw(a,n,e.currentStep)},n.onAnimationProgress=this.options.onAnimationProgress,n.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,n)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},showTooltip:function(t,e){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var a=function(t){var e=!1;return t.length!==this.activeElements.length?e=!0:(n(t,function(t,i){t!==this.activeElements[i]&&(e=!0)},this),e)}.call(this,t);if(a||e){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.data.datasets&&this.data.datasets.length>1){for(var o,r,l=this.data.datasets.length-1;l>=0&&(o=this.data.datasets[l].metaData,r=h(o,t[0]),-1===r);l--);var c=[],u=[],d=function(t){var e,i,n,a,o,h=[],l=[],d=[];return s.each(this.data.datasets,function(t){e=t.metaData,e[r]&&e[r].hasValue()&&h.push(e[r])}),s.each(h,function(t){l.push(t.x),d.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._vm.backgroundColor||t.backgroundColor,stroke:t._vm.borderColor||t.borderColor})},this),o=v(d),n=f(d),a=v(l),i=f(l),{x:a>this.chart.width/2?a:i,y:(o+n)/2}}.call(this,r);new i.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,backgroundColor:this.options.tooltipBackgroundColor,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,custom:this.options.customTooltips}).draw()}else n(t,function(t){var e=t.tooltipPosition();new i.Tooltip({x:Math.round(e.x),y:Math.round(e.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,backgroundColor:this.options.tooltipBackgroundColor,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:S(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,s=function(){return e.apply(this,arguments)};if(s.prototype=a(e.prototype),o(s.prototype,t),s.extend=i.Type.extend,t.name||e.prototype.name){var n=t.name||e.prototype.name,h=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[n]=o(h,t.defaults),i.types[n]=s,i.prototype[n]=function(t,e){var a=r(i.defaults.global,i.defaults[n],e||{});return new s(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},transition:function(t,e){return this._start||(this._start=a(this._vm)),n(this,function(i,s){if("_vm"!==s&&this.hasOwnProperty(s)){if(!this._vm[s])return void(this._vm[s]=i||null);if(t.indexOf(s)>-1){if("string"==typeof i){try{var n=Color(this._start[s]).mix(Color(this[s]),e);this._vm[s]=n.rgbString()}catch(a){this._vm[s]=i}return}return void(this._vm[s]=(this[s]-this._start[s])*e+this._start[s])}this._vm[s]=i}},this),1===e&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return g(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.borderColor,e.lineWidth=this.borderWidth,e.fillStyle=this.backgroundColor,e.fill(),e.lineJoin="bevel",this.showBorder&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,s=t.x-i,n=t.x+i,a=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(s+=o,n-=o,a+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(s,t.base),e.lineTo(s,a),e.lineTo(n,a),e.lineTo(n,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base}}),i.Animation=i.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),i.Tooltip=i.Element.extend({draw:function(){var t=this.chart.ctx;t.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var e=this.caretPadding=2,i=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+e;this.x+i/2>this.chart.width?this.xAlign="left":this.x-i/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var a=this.x-i/2,o=this.y-n;if(t.fillStyle=this.backgroundColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-e),t.lineTo(this.x+this.caretHeight,this.y-(e+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(e+this.caretHeight)),t.closePath(),t.fill();break;case"below":o=this.y+e+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+e),t.lineTo(this.x+this.caretHeight,this.y+e+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+e+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":a=this.x-i+(this.cornerRadius+this.caretHeight);break;case"right":a=this.x-(this.cornerRadius+this.caretHeight)}O(t,a,o,i,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,a+i/2,o+s/2)}}}),i.MultiTooltip=i.Element.extend({initialize:function(){this.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=W(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,e=z(this.ctx,this.font,this.labels)+this.fontSize+3,i=f([e,t]);this.width=i+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 e=this.y-this.height/2+this.yPadding,i=t-1;return 0===t?e+this.titleFontSize/2:e+(1.5*this.fontSize*i+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{O(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.backgroundColor,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(e,i){t.fillStyle=this.textColor,t.fillText(e,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(i+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[i].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?z(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,a=z(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*s,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=i/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,a){var o=this.endPoint-e*a,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==a||h||(h=!0),h&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=s.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var s=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,s,n,a,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+s,n=e),t.x-sp&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var s,n=i*(this.drawingArea/this.steps),a=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e){t.animating=!0;for(var i=0;i1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var n=Date.now(),a=n-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"bars",onHover:null,hoverDuration:400,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:s,initialize:function(t){this.data=t;var s=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return a+o*e+e*s.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return e/t}}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx,_vm:{}}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.endPoint}),t.save()},this),this.update()},onHover:function(t){var e;return"mouseout"==t.type?!1:("bar"==this.options.hoverMode?e=this.getBarAtEvent(t):"bars"==this.options.hoverMode,this.lastActive&&("bar"==this.options.hoverMode?(this.lastActive.rectangle.backgroundColor=this.data.datasets[this.lastActive.datasetIndex].backgroundColor,this.lastActive.rectangle.borderColor=this.data.datasets[this.lastActive.datasetIndex].borderColor, -this.lastActive.rectangle.borderWidth=0):"bars"==this.options.hoverMode),this.options.onHover?this.options.onHover.call(this,e):e&&("bar"==this.options.hoverMode?(e.rectangle.backgroundColor=this.data.datasets[e.datasetIndex].hoverBackgroundColor||Color(e.rectangle.backgroundColor).saturate(.5).darken(.25).rgbString(),e.rectangle.borderColor=this.data.datasets[e.datasetIndex].hoverBorderColor||Color(e.rectangle.borderColor).saturate(.5).darken(.25).rgbString()):"bars"==this.options.hoverMode),this.animating||(!this.lastActive&&e&&this.render(!1,this.options.hoverDuration),this.lastActive&&e&&this.lastActive.rectangle!==e.rectangle&&this.render(!1,this.options.hoverDuration),this.lastActive&&!e&&this.render(!1,this.options.hoverDuration)),this.lastActive=e,void(this.options.showTooltips&&this.showTooltip(e)))},update:function(){this.scale.update(),this.eachBars(function(t,e,s){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,s,e),y:this.scale.calculateY(this.data.datasets[s].data[e]),value:this.data.datasets[s].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[s].label,borderColor:this.data.datasets[s].borderColor,borderWidth:this.data.datasets[s].borderWidth,backgroundColor:this.data.datasets[s].backgroundColor,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,s){i.each(e.metaData,t,this,s)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,s){i.each(e.data,t,this,s)},this)},getBarsAtEvent:function(t){for(var e,s=[],n=i.getRelativePosition(t),a=function(t){s.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:s,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(r[r.length-1].x,this.scale.endPoint),s.lineTo(r[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),i.each(r,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],s=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(s.x,s.y)&&e.push(t)},this),e},addData:function(t,e,i){var s=e||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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var s={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(s),i.each(e.data,function(i,n){var a;this.scale.animation||(a=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),s.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),s=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,a=Math.round((s.angle-1.5*Math.PI)/n),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),s.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,s)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:s.x,y:s.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(s,n){i.extend(this.datasets[e].points[n],{value:s,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),i.each(t.points,function(t,e){0===e?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,s){function n(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,s)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=s?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,s=this.alpha()-t.alpha(),n=((i*s==-1?i:(i+s)/(1+i*s))+1)/2,a=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),s=(r+h)/2,i=h==r?0:.5>=s?l/(h+r):l/(2-h-r),[e,100*i,100*s]}function n(t){var e,i,s,n=t[0],a=t[1],o=t[2],r=Math.min(n,a,o),h=Math.max(n,a,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(a-o)/l:a==h?e=2+(o-n)/l:o==h&&(e=4+(n-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=h/255*1e3/10,[e,i,s]}function a(t){var e=t[0],i=t[1],n=t[2],a=s(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[a,100*o,100*n]}function o(t){var e,i,s,n,a=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-a,1-o,1-r),e=(1-a-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,s=(1-r-n)/(1-n)||0,[100*e,100*i,100*s,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,s=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var n=.4124*e+.3576*i+.1805*s,a=.2126*e+.7152*i+.0722*s,o=.0193*e+.1192*i+.9505*s;return[100*n,100*a,100*o]}function c(t){var e,i,s,n=l(t),a=n[0],o=n[1],r=n[2];return a/=95.047,o/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(a-o),s=200*(o-r),[e,i,s]}function u(t){return V(c(t))}function d(t){var e,i,s,n,a,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)s=o+1/3*-(l-1),0>s&&s++,s>1&&s--,a=1>6*s?e+6*(i-e)*s:1>2*s?i:2>3*s?e+(i-e)*(2/3-s)*6:e,n[l]=255*a;return n}function p(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return a*=2,n*=1>=a?a:2-a,i=(a+n)/2,e=2*n/(a+n),[s,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,a=e-Math.floor(e),o=255*s*(1-i),r=255*s*(1-i*a),h=255*s*(1-i*(1-a)),s=255*s;switch(n){case 0:return[s,h,o];case 1:return[r,s,o];case 2:return[o,s,h];case 3:return[o,r,s];case 4:return[h,o,s];case 5:return[s,o,r]}}function w(t){var e,i,s=t[0],n=t[1]/100,a=t[2]/100;return i=(2-n)*a,e=n*a,e/=1>=i?i:2-i,e=e||0,i/=2,[s,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,s,n,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,s=6*a-e,0!=(1&e)&&(s=1-s),n=o+s*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return s(k(t))}function L(t){return n(k(t))}function M(t){return o(k(t))}function A(t){return h(k(t))}function F(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),s=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*s]}function R(t){return s(F(t))}function T(t){return n(F(t))}function W(t){return a(F(t))}function z(t){return h(F(t))}function O(t){var e,i,s,n=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*a+o*-.4986,i=n*-.9689+1.8758*a+.0415*o,s=.0557*n+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=12.92*s,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*e,255*i,255*s]}function I(t){var e,i,s,n=t[0],a=t[1],o=t[2];return n/=95.047,a/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(n-a),s=200*(a-o),[e,i,s]}function B(t){return V(I(t))}function E(t){var e,i,s,n,a=t[0],o=t[1],r=t[2];return 8>=a?(i=100*a/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),s=.008859>=s/108.883?s=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,s]}function V(t){var e,i,s,n=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),s=Math.sqrt(a*a+o*o),[n,s,i]}function D(t){return O(E(t))}function H(t){var e,i,s,n=t[0],a=t[1],o=t[2];return s=o/360*2*Math.PI,e=a*Math.cos(s),i=a*Math.sin(s),[n,e,i]}function q(t){return E(H(t))}function X(t){return D(H(t))}function _(t){return U[t]}function Y(t){return s(_(t))}function N(t){return n(_(t))}function j(t){return a(_(t))}function G(t){return o(_(t))}function Z(t){return c(_(t))}function Q(t){return l(_(t))}e.exports={rgb2hsl:s,rgb2hsv:n,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:M,hwb2keyword:A,cmyk2rgb:F,cmyk2hsl:R,cmyk2hsv:T,cmyk2hwb:W,cmyk2keyword:z,keyword2rgb:_,keyword2hsl:Y,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:O,xyz2lab:I,xyz2lch:B,lab2xyz:E,lab2rgb:D,lab2lch:V,lch2lab:H,lch2xyz:q,lch2rgb:X};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var s=t("./conversions"),n=function(){return new l};for(var a in s){n[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),s[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=s[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+s+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+s+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:s,getHsla:n,getRgb:o,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,s=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=s,i=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,n.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},i.types={};var n=i.helpers={},s=n.each=function(t,e,i){var n=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;n--){var s=t[n];if(e(s))return s}},n.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},n=function(){this.constructor=i};return n.prototype=e.prototype,i.prototype=new n,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),c=n.noop=function(){},u=n.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=n.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=n.amd="function"==typeof define&&define.amd,g=n.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=n.max=function(t){return Math.max.apply(Math,t)},v=n.min=function(t){return Math.min.apply(Math,t)},m=(n.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},n.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=n.radians=function(t){return t*(Math.PI/180)},y=(n.getAngleFromPoint=function(t,e){var i=e.x-t.x,n=e.y-t.y,s=Math.sqrt(i*i+n*n),a=2*Math.PI+Math.atan2(n,i);return 0>i&&0>n&&(a+=2*Math.PI),{angle:a,distance:s}},n.aliasPixel=function(t){return t%2===0?0:.5}),w=(n.splineCurve=function(t,e,i,n){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=n*s/(s+a),r=n*a/(s+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},n.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(n.calculateScaleRange=function(t,e,i,n,s){var a=2,o=Math.floor(e/(1.5*i)),r=a>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!n?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=n?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(s&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=a,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},n.template=function(t,e){function i(t,e){var i=/\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('');"):n[t]=n[t];return e?i(e):i}if(t instanceof Function)return t(e);var n={};return i(t,e)}),x=(n.generateLabels=function(t,e,i,n){var a=new Array(e);return t&&s(a,function(e,s){a[s]=S(t,{value:i+n*(s+1)})}),a},n.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 e=1.70158,i=0,n=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),nt?-.5*n*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):n*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=n.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(n.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),n.animationLoop=function(t,e,i,n,s,a){var o=0,r=x[i]||x.linear,h=function(){o++;var i=o/e,l=r(i);t.call(a,l,i,o),n.call(a,l,i),e>o?a.animationFrame=C(h):s.apply(a)};C(h)},n.getRelativePosition=function(t){var e,i,n=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return n.touches?(e=n.touches[0].clientX-a.left,i=n.touches[0].clientY-a.top):(e=n.clientX-a.left,i=n.clientY-a.top),{x:e,y:i}},n.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=n.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(n.bindEvents=function(t,e,i){t.events||(t.events={}),s(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},n.unbindEvents=function(t,e){s(e,function(e,i){P(t.chart.canvas,i,e)})}),A=n.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-left"))+parseInt(F(e,"padding-right"));return e.clientWidth-i},M=n.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-bottom"))+parseInt(F(e,"padding-top"));return e.clientHeight-i},F=n.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(n.getMaximumSize=n.getMaximumWidth,n.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,n=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=n+"px",e.canvas.height=n*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),W=n.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},z=n.fontString=function(t,e,i){return e+" "+t+"px "+i},T=n.longestText=function(t,e,i){t.font=e;var n=0;return s(i,function(e){var i=t.measureText(e).width;n=i>n?i:n}),n},_=n.drawRoundedRectangle=function(t,e,i,n,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+n-a,i),t.quadraticCurveTo(e+n,i,e+n,i+a),t.lineTo(e+n,i+s-a),t.quadraticCurveTo(e+n,i+s,e+n-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};n.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},n.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e,n){this.options=e,this.chart=n,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return W(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=A(this.chart.canvas),n=this.options.maintainAspectRatio?i/this.chart.aspectRatio:M(this.chart.canvas);return e.width=this.chart.width=i,e.height=this.chart.height=n,R(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t,e){if(t&&this.reflow(),this.options.animation&&!t){var s=new i.Animation;s.numSteps=(e||this.options.animationDuration)/16.66,s.easing=this.options.animationEasing,s.render=function(t,e){var i=n.easingEffects[e.easing],s=e.currentStep/e.numSteps,a=i(s);t.draw(a,s,e.currentStep)},s.onAnimationProgress=this.options.onAnimationProgress,s.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,s,e)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,n=function(){return e.apply(this,arguments)};if(n.prototype=a(e.prototype),o(n.prototype,t),n.extend=i.Type.extend,t.name||e.prototype.name){var s=t.name||e.prototype.name,h=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[s]=o(h,t.defaults),i.types[s]=n,i.prototype[s]=function(t,e){var a=r(i.defaults.global,i.defaults[s],e||{});return new n(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,{_vm:{}}),o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},pivot:function(){return this._start&&(this._start=a(this),n.extend(this._start,this._vm)),this},transition:function(t){return this._start||(this._start=a(this._vm)),s(this,function(e,i){if("_"!==i[0]&&this.hasOwnProperty(i)){if(!this._vm[i])return void(this._vm[i]=e||null);if(this[i]!==this._vm[i])if("string"==typeof e)try{var s=n.color(this._start[i]).mix(n.color(this[i]),t);this._vm[i]=s.rgbString()}catch(a){this._vm[i]=e}else"number"==typeof e?this._vm[i]=(this[i]-this._start[i])*t+this._start[i]:this._vm[i]=e}},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return g(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return s&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.borderColor,e.lineWidth=this.borderWidth,e.fillStyle=this.backgroundColor,e.fill(),e.lineJoin="bevel",this.showBorder&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,n=t.x-i,s=t.x+i,a=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(n+=o,s-=o,a+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(n,t.base),e.lineTo(n,a),e.lineTo(s,a),e.lineTo(s,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},tooltipPosition:function(){var t=this._vm;return t.y=0&&(i=this._data.datasets[r].metaData,s=h(i,this._active[0]),-1===s);r--);var l=function(t){var e,i,r,h,l,c=[],u=[],d=[];return n.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])}),n.each(c,function(t){u.push(t._vm.x),d.push(t._vm.y),a.push(n.template(this._options.multiTooltipTemplate,t)),o.push({fill:t._vm.backgroundColor,stroke:t._vm.borderColor})},this),l=v(d),r=f(d),h=v(u),i=f(u),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,s);n.extend(this,{x:l.x,y:l.y,labels:a,title:this._active.length?this._active[0].label:"",legendColors:o,legendBackgroundColor:this._options.multiTooltipKeyBackground}),this.height=a.length*this.fontSize+(a.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize;var c=t.measureText(this.title).width,u=T(t,this.font,a)+this.fontSize+3,d=f([u,c]);this.width=d+2*this.xPadding;var p=this.height/2;this.y-p<0?this.y=p:this.y+p>this._chart.height&&(this.y=this._chart.height-p),this.x>this._chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._vm;switch(this._options.hoverMode){case"single":t.font=z(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding=2,s=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,o=a+e.caretHeight+i;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-o;if(t.fillStyle=n.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._vm);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}_(t,r,h,s,a,e.cornerRadius),t.fill(),t.fillStyle=n.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+a/2)}break;case"label":_(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=n.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=n.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=z(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=z(e.fontSize,e._fontStyle,e._fontFamily),n.each(e.labels,function(i,s){t.fillStyle=n.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=n.color(e.legendBackgroundColor).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize),t.fillStyle=n.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._vm.y-this._vm.height/2+this._vm.yPadding,i=t-1;return 0===t?e+this._vm.titleFontSize/2:e+(1.5*this._vm.fontSize*i+this._vm.fontSize/2)+1.5*this._vm.titleFontSize}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?T(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var s,a=T(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)s=Math.cos(b(this.xLabelRotation)),t=s*i,e=s*n,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=s*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),n=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(n+=i/2),Math.round(n)},update:function(t){n.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,s(this.yLabels,function(s,a){var o=this.endPoint-e*a,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(s,i-10,o),0!==a||h||(h=!0),h&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=n.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),s(this.xLabels,function(e,i){var n=this.calculateX(i)+y(this.lineWidth),s=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(t.moveTo(s,this.endPoint),t.lineTo(s,this.startPoint-3),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(s,this.endPoint),t.lineTo(s,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(n,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,n,s,a,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+n,s=e),t.x-np&&(p=t.x+i,s=e):e>this.valuesCount/2&&t.x-i0){var n,s=i*(this.drawingArea/this.steps),a=this.yCenter-s;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var n=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],n.x,n.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var s=Date.now(),a=s-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&n.requestAnimFrame.call(window,this.digestWrapper)}},n.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){s(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"single",onHover:null,hoverAnimationDuration:400,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:n,initialize:function(t){this.data=t;var n=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.calculateX(i)-s/2,o=this.calculateBarWidth(t);return a+o*e+e*n.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*n.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*n.barDatasetSpacing;return e/t}}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,n){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,n,e),y:this.calculateBarBase(),_datasetIndex:n,_index:e}),t.save()},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return!1;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hoverMode){case"single":return this.getBarAtEvent(t);case"label":return this.getBarsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive)switch(this.options.hoverMode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].borderColor, +this.lastActive[0].borderWidth=0;break;case"label":for(var e=0;e=0||this.scale.min>=0&&this.scale.max<=0?(t=this.scale.calculateY(0),t+=this.options.scaleGridLineWidth):this.scale.min<0&&this.scale.max<0&&(t=this.scale.startPoint),t},update:function(){this.scale.update(),this.eachBars(function(t,e,n){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,n,e),y:this.scale.calculateY(this.data.datasets[n].data[e]),value:this.data.datasets[n].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[n].label,borderColor:this.data.datasets[n].borderColor,borderWidth:this.data.datasets[n].borderWidth,backgroundColor:this.data.datasets[n].backgroundColor,_datasetIndex:n,_index:e,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,n){i.each(e.metaData,t,this,n)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,n){i.each(e.data,t,this,n)},this)},getBarsAtEvent:function(t){for(var e,n=[],s=i.getRelativePosition(t),a=function(t){n.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:n,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],n=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(n.x,n.y)&&e.push(t)},this),e},addData:function(t,e,i){var n=e||this.segments.length;this.segments.splice(n,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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:n,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(n.lineTo(r[r.length-1].x,this.scale.endPoint),n.lineTo(r[0].x,this.scale.endPoint),n.fillStyle=t.fillColor,n.closePath(),n.fill()),i.each(r,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:n,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],n=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(n.x,n.y)&&e.push(t)},this),e},addData:function(t,e,i){var n=e||this.segments.length;this.segments.splice(n,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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.push(t.value)});var n=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,n,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var n={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(n),i.each(e.data,function(i,s){var a;this.scale.animation||(a=this.scale.getPointPosition(s,this.scale.calculateCenterOffset(i))),n.points.push(new this.PointClass({value:i,label:t.labels[s],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),n=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),s=2*Math.PI/this.scale.valuesCount,a=Math.round((n.angle-1.5*Math.PI)/s),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),n.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),n=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,n)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var n=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:n.x,y:n.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(n,s){i.extend(this.datasets[e].points[s],{value:n,label:this.data.labels[s],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,n=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),n.lineWidth=this.options.datasetStrokeWidth,n.strokeStyle=t.strokeColor,n.beginPath(),i.each(t.points,function(t,e){0===e?n.moveTo(t.x,t.y):n.lineTo(t.x,t.y)},this),n.closePath(),n.stroke(),n.fillStyle=t.fillColor,n.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,n){function s(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return s(i?i:t)},c,c.exports,t,e,i,n)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,n=this.alpha()-t.alpha(),s=((i*n==-1?i:(i+n)/(1+i*n))+1)/2,a=1-s,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),n=(r+h)/2,i=h==r?0:.5>=n?l/(h+r):l/(2-h-r),[e,100*i,100*n]}function s(t){var e,i,n,s=t[0],a=t[1],o=t[2],r=Math.min(s,a,o),h=Math.max(s,a,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(a-o)/l:a==h?e=2+(o-s)/l:o==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),n=h/255*1e3/10,[e,i,n]}function a(t){var e=t[0],i=t[1],s=t[2],a=n(t)[0],o=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*o,100*s]}function o(t){var e,i,n,s,a=t[0]/255,o=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-o,1-r),e=(1-a-s)/(1-s)||0,i=(1-o-s)/(1-s)||0,n=(1-r-s)/(1-s)||0,[100*e,100*i,100*n,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var s=.4124*e+.3576*i+.1805*n,a=.2126*e+.7152*i+.0722*n,o=.0193*e+.1192*i+.9505*n;return[100*s,100*a,100*o]}function c(t){var e,i,n,s=l(t),a=s[0],o=s[1],r=s[2];return a/=95.047,o/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(a-o),n=200*(o-r),[e,i,n]}function u(t){return V(c(t))}function d(t){var e,i,n,s,a,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)n=o+1/3*-(l-1),0>n&&n++,n>1&&n--,a=1>6*n?e+6*(i-e)*n:1>2*n?i:2>3*n?e+(i-e)*(2/3-n)*6:e,s[l]=255*a;return s}function p(t){var e,i,n=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[n,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,n=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),o=255*n*(1-i),r=255*n*(1-i*a),h=255*n*(1-i*(1-a)),n=255*n;switch(s){case 0:return[n,h,o];case 1:return[r,n,o];case 2:return[o,n,h];case 3:return[o,r,n];case 4:return[h,o,n];case 5:return[n,o,r]}}function w(t){var e,i,n=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[n,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,n,s,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,n=6*a-e,0!=(1&e)&&(n=1-n),s=o+n*(i-o),e){default:case 6:case 0:r=i,g=s,b=o;break;case 1:r=s,g=i,b=o;break;case 2:r=o,g=i,b=s;break;case 3:r=o,g=s,b=i;break;case 4:r=s,g=o,b=i;break;case 5:r=i,g=o,b=s}return[255*r,255*g,255*b]}function P(t){return n(k(t))}function L(t){return s(k(t))}function A(t){return o(k(t))}function M(t){return h(k(t))}function F(t){var e,i,n,s=t[0]/100,a=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),n=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*n]}function R(t){return n(F(t))}function W(t){return s(F(t))}function z(t){return a(F(t))}function T(t){return h(F(t))}function _(t){var e,i,n,s=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*s+-1.5372*a+o*-.4986,i=s*-.9689+1.8758*a+.0415*o,n=.0557*s+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),n=Math.min(Math.max(0,n),1),[255*e,255*i,255*n]}function I(t){var e,i,n,s=t[0],a=t[1],o=t[2];return s/=95.047,a/=100,o/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(s-a),n=200*(a-o),[e,i,n]}function O(t){return V(I(t))}function B(t){var e,i,n,s,a=t[0],o=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+s-16/116)/7.787:95.047*Math.pow(o/500+s,3),n=.008859>=n/108.883?n=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,n]}function V(t){var e,i,n,s=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),n=Math.sqrt(a*a+o*o),[s,n,i]}function E(t){return _(B(t))}function D(t){var e,i,n,s=t[0],a=t[1],o=t[2];return n=o/360*2*Math.PI,e=a*Math.cos(n),i=a*Math.sin(n),[s,e,i]}function H(t){return B(D(t))}function q(t){return E(D(t))}function X(t){return U[t]}function Y(t){return n(X(t))}function j(t){return s(X(t))}function N(t){return a(X(t))}function G(t){return o(X(t))}function Z(t){return c(X(t))}function Q(t){return l(X(t))}e.exports={rgb2hsl:n,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:A,hwb2keyword:M,cmyk2rgb:F,cmyk2hsl:R,cmyk2hsv:W,cmyk2hwb:z,cmyk2keyword:T,keyword2rgb:X,keyword2hsl:Y,keyword2hsv:j,keyword2hwb:N,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:_,xyz2lab:I,xyz2lch:O,lab2xyz:B,lab2rgb:E,lab2lch:V,lch2lab:D,lch2xyz:H,lch2rgb:q};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var n=t("./conversions"),s=function(){return new l};for(var a in n){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),n[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),r=o[1],h=o[2];s[r]=s[r]||{},s[r][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=n[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+n+"%, "+s+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+n+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:n,getHsla:s,getRgb:o,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/samples/bar.html b/samples/bar.html index b698faf8ac6..c081ea8266d 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -38,6 +38,7 @@ responsive: true, hoverMode: 'label', scaleBeginAtZero: false, + hoverAnimationDuration: 400 }); } diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index b5fb3d672d8..5ccdcba3f70 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -131,6 +131,8 @@ return false; } + this.lastActive = this.lastActive || []; + // Find Active Elements this.active = function(){ switch(this.options.hoverMode){ @@ -159,6 +161,11 @@ this.lastActive[0].borderWidth = 0; break; case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; + this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; + this.lastActive[i].borderWidth = 0; + } break; case 'dataset': break; @@ -168,13 +175,17 @@ } // Built in hover actions - if(this.active && this.options.hoverMode){ + if(this.active.length && this.options.hoverMode){ switch(this.options.hoverMode){ case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.25).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.25).rgbString(); + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); break; case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + } break; case 'dataset': break; @@ -191,7 +202,7 @@ this.tooltip.initialize(); // Active - if(this.active){ + if(this.active.length){ helpers.extend(this.tooltip, { opacity: 1, _active: this.active, @@ -203,24 +214,22 @@ // Inactive helpers.extend(this.tooltip, { opacity: 0, - _active: false, }); } } - // Only animate for major events + if(!this.animating){ + // If entering - if(!this.lastActive && this.active){ + if(!this.lastActive.length && this.active.length){ console.log('entering'); + this.tooltip.pivot(); + this.stop(); this.render(false, this.options.hoverAnimationDuration); } - var changed = false; - - if (this.active.length !== this.lastActive.length){ - changed = true; - } + var changed; helpers.each(this.active, function(element, index){ if (element !== this.lastActive[index]){ @@ -229,19 +238,25 @@ }, this); // If different element - if(this.lastActive && this.active && changed){ + if(this.lastActive.length && this.active.length && changed){ console.log('changing'); + this.tooltip.pivot(); + this.stop(); this.render(false, this.options.hoverAnimationDuration); } // if Leaving - if (this.lastActive && !this.active){ + if (this.lastActive.length && !this.active.length){ console.log('leaving'); + this.tooltip.pivot(); + this.stop(); this.render(false, this.options.hoverAnimationDuration); } - } + + } // Remember Last Active + this.lastActive = this.active; }, // Calculate the base point for the bar. @@ -285,7 +300,6 @@ }); }, this); - this.render(); }, eachBars : function(callback){ @@ -314,7 +328,7 @@ } } - return barsArray.length ? barsArray : false; + return barsArray.length ? barsArray : []; }, // Get the single bar that was clicked on // @return : An object containing the dataset index and bar index of the matching bar. Also contains the rectangle that was drawn @@ -331,7 +345,7 @@ } } - return false; + return []; }, buildScale : function(labels){ var self = this; diff --git a/src/Chart.Core.js b/src/Chart.Core.js index eed7d13b84f..6c5c4f28517 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -969,7 +969,7 @@ animation.onAnimationProgress = this.options.onAnimationProgress; animation.onAnimationComplete = this.options.onAnimationComplete; - Chart.animationService.addAnimation(this, animation); + Chart.animationService.addAnimation(this, animation, customDuration); } else{ this.draw(); @@ -1061,6 +1061,13 @@ delete this._vm._start; return this; }, + pivot: function(){ + if(this._start){ + this._start = clone(this); + helpers.extend(this._start, this._vm); + } + return this; + }, transition : function(ease){ if(!this._start){ this._start = clone(this._vm); @@ -1265,26 +1272,25 @@ return vm.base - vm.y; }, inRange : function(chartX,chartY){ - if (this.y < this.base) - { - return (chartX >= this.x - this.width/2 && chartX <= this.x + this.width/2) && (chartY >= this.y && chartY <= this.base); - } - else - { - return (chartX >= this.x - this.width / 2 && chartX <= this.x + this.width / 2) && (chartY >= this.base && chartY <= this.y); + var vm = this._vm; + if (vm.y < vm.base){ + return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= vm.base); + } else{ + return (chartX >= vm.x - vm.width / 2 && chartX <= vm.x + vm.width / 2) && (chartY >= vm.base && chartY <= vm.y); } }, tooltipPosition : function(){ - if (this.y < this.base){ + var vm = this._vm; + if (vm.y < vm.base){ return { - x : this.x, - y : this.y + x : vm.x, + y : vm.y }; } else{ return { - x : this.x, - y : this.base + x : vm.x, + y : vm.base }; } }, @@ -1405,7 +1411,7 @@ x: medianPosition.x, y: medianPosition.y, labels: labels, - title: this._active[0].label, + title: this._active.length ? this._active[0].label : '', legendColors: colors, legendBackgroundColor : this._options.multiTooltipKeyBackground, }); @@ -1451,7 +1457,7 @@ switch(this._options.hoverMode){ case 'single': - ctx.font = fontString(vm.fontSize,vm.fontStyle,vm.fontFamily); + ctx.font = fontString(vm.fontSize,vm._fontStyle,vm._fontFamily); vm.xAlign = "center"; vm.yAlign = "above"; @@ -1527,7 +1533,7 @@ break; case 'label': - drawRoundedRectangle(ctx,vm.x,vm.y - vm.height/2,vm.width,vm.height,vm.cornerRadius); + drawRoundedRectangle(ctx, vm.x, vm.y - vm.height/2, vm.width, vm.height, vm.cornerRadius); ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); ctx.fill(); ctx.closePath(); @@ -1535,11 +1541,10 @@ ctx.textAlign = "left"; ctx.textBaseline = "middle"; ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); - ctx.font = vm.titleFont; + ctx.font = fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); + ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); - ctx.fillText(vm.title,vm.x + vm.xPadding, this.getLineHeight(0)); - - ctx.font = vm.font; + ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); helpers.each(vm.labels,function(label,index){ ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); ctx.fillText(label,vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); @@ -1549,10 +1554,10 @@ //Instead we'll make a white filled block to put the legendColour palette over. ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); },this); @@ -1560,14 +1565,14 @@ } }, getLineHeight : function(index){ - var baseLineHeight = this.y - (this.height/2) + this.yPadding, + var baseLineHeight = this._vm.y - (this._vm.height/2) + this._vm.yPadding, afterTitleIndex = index-1; //If the index is zero, we're getting the title if (index === 0){ - return baseLineHeight + this.titleFontSize/2; + return baseLineHeight + this._vm.titleFontSize/2; } else{ - return baseLineHeight + ((this.fontSize*1.5*afterTitleIndex) + this.fontSize/2) + this.titleFontSize * 1.5; + return baseLineHeight + ((this._vm.fontSize*1.5*afterTitleIndex) + this._vm.fontSize/2) + this._vm.titleFontSize * 1.5; } }, @@ -2040,7 +2045,7 @@ } } if(this.showLabels){ - ctx.font = fontString(this.fontSize,this.fontStyle,this.fontFamily); + ctx.font = fontString(this.fontSize,this._fontStyle,this._fontFamily); if (this.showLabelBackdrop){ var labelWidth = ctx.measureText(label).width; ctx.fillStyle = this.backdropColor; @@ -2111,8 +2116,11 @@ frameDuration: 17, animations: [], dropFrames: 0, - addAnimation: function(chartInstance, animationObject) { - chartInstance.animating = true; + addAnimation: function(chartInstance, animationObject, customDuration) { + + if(!customDuration){ + chartInstance.animating = true; + } for (var index = 0; index < this.animations.length; ++ index){ if (this.animations[index].chartInstance === chartInstance){ From f79ebdaa88c7d351258e5668cd5c210ada6a7b4e Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 15 May 2015 00:04:42 -0600 Subject: [PATCH 022/424] Stable Bar Chart, DRY core functions --- src/Chart.Bar.js | 123 +++++++++++----------------------------------- src/Chart.Core.js | 66 ++++++++++++++++++++----- 2 files changed, 83 insertions(+), 106 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 5ccdcba3f70..6699924d733 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -101,11 +101,11 @@ },this); // Set defaults for bars - this.eachBars(function(bar, index, datasetIndex){ + this.eachElement(function(bar, index, datasetIndex){ helpers.extend(bar, { width : this.scale.calculateBarWidth(this.data.datasets.length), x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.calculateBarBase(), + y: this.calculateBaseY(), _datasetIndex: datasetIndex, _index: index, }); @@ -128,7 +128,7 @@ // If exiting chart if(e.type == 'mouseout'){ - return false; + return this; } this.lastActive = this.lastActive || []; @@ -137,9 +137,9 @@ this.active = function(){ switch(this.options.hoverMode){ case 'single': - return this.getBarAtEvent(e); + return this.getElementAtEvent(e); case 'label': - return this.getBarsAtEvent(e); + return this.getElementsAtEvent(e); case 'dataset': return this.getDatasetAtEvent(e); default: @@ -153,7 +153,7 @@ } // Remove styling for last active (even if it may still be active) - if(this.lastActive){ + if(this.lastActive.length){ switch(this.options.hoverMode){ case 'single': this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; @@ -170,11 +170,11 @@ case 'dataset': break; default: - // do nothing + // Don't change anything } } - // Built in hover actions + // Built in hover styling if(this.active.length && this.options.hoverMode){ switch(this.options.hoverMode){ case 'single': @@ -190,7 +190,7 @@ case 'dataset': break; default: - // do nothing + // Don't change anything } } @@ -219,16 +219,8 @@ } + // Hover animations if(!this.animating){ - - // If entering - if(!this.lastActive.length && this.active.length){ - console.log('entering'); - this.tooltip.pivot(); - this.stop(); - this.render(false, this.options.hoverAnimationDuration); - } - var changed; helpers.each(this.active, function(element, index){ @@ -237,33 +229,22 @@ } }, this); - // If different element - if(this.lastActive.length && this.active.length && changed){ - console.log('changing'); - this.tooltip.pivot(); - this.stop(); - this.render(false, this.options.hoverAnimationDuration); - } + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length)|| + (this.lastActive.length && this.active.length && changed)){ - // if Leaving - if (this.lastActive.length && !this.active.length){ - console.log('leaving'); this.tooltip.pivot(); - this.stop(); - this.render(false, this.options.hoverAnimationDuration); + this.render(this.options.hoverAnimationDuration); } - } // Remember Last Active - this.lastActive = this.active; + return this; }, // Calculate the base point for the bar. - // If the scale has a 0 point, use that as the base - // If the scale min and max are both positive, use the bottom as a base - // If the scale min and max are both negative, use the top as a base - calculateBarBase: function() { + calculateBaseY: function() { var base = this.scale.endPoint; if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) @@ -283,7 +264,7 @@ this.scale.update(); - this.eachBars(function(bar, index, datasetIndex){ + this.eachElement(function(bar, index, datasetIndex){ helpers.extend(bar, { width : this.scale.calculateBarWidth(this.data.datasets.length), x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), @@ -302,51 +283,6 @@ this.render(); }, - eachBars : function(callback){ - helpers.each(this.data.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.metaData, callback, this, datasetIndex); - },this); - }, - eachValue : function(callback){ - helpers.each(this.data.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.data, callback, this, datasetIndex); - },this); - }, - getBarsAtEvent : function(e){ - var barsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset){ - barsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x,eventPosition.y)){ - helpers.each(this.data.datasets, datasetIterator); - } - } - } - - return barsArray.length ? barsArray : []; - }, - // Get the single bar that was clicked on - // @return : An object containing the dataset index and bar index of the matching bar. Also contains the rectangle that was drawn - getBarAtEvent : function(e) { - var bar = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - bar.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return bar; - } - } - } - - return []; - }, buildScale : function(labels){ var self = this; @@ -406,17 +342,16 @@ this.scale = new this.ScaleClass(scaleOptions); }, // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function - /*reflow : function(){ - helpers.extend(this.BarClass.prototype,{ - y: this.calculateBarBase(), // so that we animate from the baseline - base : this.calculateBarBase() - }); - var newScaleProps = helpers.extend({ - height : this.chart.height, - width : this.chart.width + redraw : function(){ + var base = this.calculateBaseY(); + this.eachElement(function(element, index, datasetIndex){ + helpers.extend(element,{ + y: base, + base : base + }); }); - this.scale.update(newScaleProps); - },*/ + render(); + }, draw : function(ease){ var easingDecimal = ease || 1; @@ -425,10 +360,10 @@ this.scale.draw(easingDecimal); //Draw all the bars for each dataset - this.eachBars(function(bar, index, datasetIndex){ + this.eachElement(function(bar, index, datasetIndex){ if (bar.hasValue()){ // Update the bar basepoint - bar.base = this.calculateBarBase(); + bar.base = this.calculateBaseY(); //Transition bar.transition(easingDecimal).draw(); } diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 6c5c4f28517..a038299ad5c 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -945,15 +945,12 @@ } return this; }, - reflow : noop, - render : function(reflow, customDuration){ - if (reflow){ - this.reflow(); - } + redraw : noop, + render : function(duration){ - if (this.options.animation && !reflow){ + if (this.options.animation){ var animation = new Chart.Animation(); - animation.numSteps = (customDuration || this.options.animationDuration) / 16.66; //60 fps + animation.numSteps = (duration || this.options.animationDuration) / 16.66; //60 fps animation.easing = this.options.animationEasing; // render function @@ -969,7 +966,7 @@ animation.onAnimationProgress = this.options.onAnimationProgress; animation.onAnimationComplete = this.options.onAnimationComplete; - Chart.animationService.addAnimation(this, animation, customDuration); + Chart.animationService.addAnimation(this, animation, duration); } else{ this.draw(); @@ -977,6 +974,51 @@ } return this; }, + eachElement : function(callback){ + helpers.each(this.data.datasets,function(dataset, datasetIndex){ + helpers.each(dataset.metaData, callback, this, datasetIndex); + },this); + }, + eachValue : function(callback){ + helpers.each(this.data.datasets,function(dataset, datasetIndex){ + helpers.each(dataset.data, callback, this, datasetIndex); + },this); + }, + getElementsAtEvent : function(e){ + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset){ + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x,eventPosition.y)){ + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent : function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, generateLegend : function(){ return template(this.options.legendTemplate,this); }, @@ -1337,10 +1379,10 @@ switch(this._options.hoverMode){ case 'single': helpers.extend(this, { - text: template(this._options.tooltipTemplate, this._active), + text: template(this._options.tooltipTemplate, this._active[0]), }); var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this.tooltip, { + helpers.extend(this, { x: Math.round(tooltipPosition.x), y: Math.round(tooltipPosition.y), }); @@ -2116,9 +2158,9 @@ frameDuration: 17, animations: [], dropFrames: 0, - addAnimation: function(chartInstance, animationObject, customDuration) { + addAnimation: function(chartInstance, animationObject, duration) { - if(!customDuration){ + if(!duration){ chartInstance.animating = true; } From fb580a6e48c2b1db78b4dac37779d7a3dc8dec39 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 15 May 2015 16:40:01 -0600 Subject: [PATCH 023/424] lineChart single hoverMode tooltips, fallbackColor global --- samples/line.html | 35 ++- src/Chart.Bar.js | 19 +- src/Chart.Core.js | 136 ++++++++---- src/Chart.Line.js | 532 ++++++++++++++++++++++++---------------------- 4 files changed, 390 insertions(+), 332 deletions(-) diff --git a/samples/line.html b/samples/line.html index 32ce4124185..8e5968c4873 100644 --- a/samples/line.html +++ b/samples/line.html @@ -6,7 +6,7 @@ -
    +
    @@ -15,48 +15,45 @@ @@ -12,8 +13,8 @@
    + diff --git a/samples/doughnut.html b/samples/doughnut.html index 879f72f6894..125beaf4653 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -1,80 +1,79 @@ - - Doughnut Chart - - - - - -
    - -
    - + + Doughnut Chart + + + + - + - $('#randomizeData').click(function(){ - $.each(doughnutData, function(i, piece){ - doughnutData[i].value = randomScalingFactor(); - doughnutData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; - }); - window.myDoughnut.update(); - }); - - - - - diff --git a/samples/line.html b/samples/line.html index b3d6c85343f..b6c2ae8e782 100644 --- a/samples/line.html +++ b/samples/line.html @@ -1,66 +1,64 @@ - - Line Chart - - - - -
    -
    - -
    -
    - + + Line Chart + + + - + - - - diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 71b6451f500..8eb436a4db2 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -1,369 +1,365 @@ -(function(){ - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - - var defaultConfig = { - //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 - Whether to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, - - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, - - //Number - Pixel width of the bar border - barBorderWidth : 2, - - //Number - Spacing between each of the X value sets - barValueSpacing : 5, - - //Number - Spacing between data sets within X values - barDatasetSpacing : 1, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - - }; - - - Chart.Type.extend({ - name: "Bar", - defaults : defaultConfig, - initialize: function(data){ - - // Save data as a source for updating of values & methods - this.data = data; - - var options = this.options; - - // Custom Scale Methods and Options - this.ScaleClass = Chart.Scale.extend({ - offsetGridLines : true, - calculateBarX : function(datasetCount, datasetIndex, elementIndex){ - //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.calculateX(elementIndex) - (xWidth/2), - barWidth = this.calculateBarWidth(datasetCount); - - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth/2; - }, - calculateBaseWidth : function(){ - return (this.calculateX(1) - this.calculateX(0)) - (2*options.barValueSpacing); - }, - calculateBarWidth : function(datasetCount){ - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); - - return (baseWidth / datasetCount); - } - }); - - // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); - - //Declare the extension of the default point, to cater for the options passed in to the constructor - this.BarClass = Chart.Rectangle.extend({ - ctx : this.chart.ctx, - }); - - // Build Scale - this.buildScale(this.data.labels); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets,function(dataset,datasetIndex){ - dataset.metaData = []; - helpers.each(dataset.data,function(dataPoint,index){ - dataset.metaData.push(new this.BarClass()); - },this); - },this); - - // Set defaults for bars - this.eachElement(function(bar, index, datasetIndex){ - helpers.extend(bar, { - width : this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.calculateBaseY(), - _datasetIndex: datasetIndex, - _index: index, - }); - // Copy to view model - bar.save(); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Update the chart with the latest data. - this.update(); - }, - onHover: function(e){ - - - // If exiting chart - if(e.type == 'mouseout'){ - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function(){ - switch(this.options.hoverMode){ - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if(this.options.onHover){ - this.options.onHover.call(this, this.active); - } - - // Remove styling for last active (even if it may still be active) - if(this.lastActive.length){ - switch(this.options.hoverMode){ - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if(this.active.length && this.options.hoverMode){ - switch(this.options.hoverMode){ - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if(this.options.showTooltips){ - - // The usual updates - this.tooltip.initialize(); - - // Active - if(this.active.length){ - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, - }); - - this.tooltip.update(); - } - else{ - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); - } - } - - - this.tooltip.pivot(); - - // Hover animations - if(!this.animating){ - var changed; - - helpers.each(this.active, function(element, index){ - if (element !== this.lastActive[index]){ - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length)|| - (this.lastActive.length && this.active.length && changed)){ - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - // Calculate the base point for the bar. - calculateBaseY: function() { - var base = this.scale.endPoint; - - if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) - { - base = this.scale.calculateY(0); - base += this.options.scaleGridLineWidth; - } - else if (this.scale.min < 0 && this.scale.max < 0) - { - // All values are negative. Use the top as the base - base = this.scale.startPoint; - } - - return base; - }, - update : function(){ - - this.scale.update(); - - this.eachElement(function(bar, index, dataset, datasetIndex){ - helpers.extend(bar, { - width : this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), - value : this.data.datasets[datasetIndex].data[index], - label : this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - borderColor : this.data.datasets[datasetIndex].borderColor, - borderWidth : this.data.datasets[datasetIndex].borderWidth, - backgroundColor : this.data.datasets[datasetIndex].backgroundColor, - _datasetIndex: datasetIndex, - _index: index, - }); - bar.pivot(); - }, this); - - this.render(); - }, - buildScale : function(labels){ - var self = this; - - var dataTotal = function(){ - var values = []; - self.eachValue(function(value){ - values.push(value); - }); - return values; - }; - - var scaleOptions = { - 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 : labels.length, - beginAtZero : this.options.scaleBeginAtZero, - integersOnly : this.options.scaleIntegersOnly, - calculateYRange: function(currentHeight){ - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); - }, - xLabels : labels, - font : helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth : this.options.scaleLineWidth, - lineColor : this.options.scaleLineColor, - showHorizontalLines : this.options.scaleShowHorizontalLines, - showVerticalLines : this.options.scaleShowVerticalLines, - 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.borderWidth, - showLabels : this.options.scaleShowLabels, - display : this.options.showScale - }; - - if (this.options.scaleOverride){ - helpers.extend(scaleOptions, { - calculateYRange: helpers.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(scaleOptions); - }, - // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function - redraw : function(){ - var base = this.calculateBaseY(); - this.eachElement(function(element, index, datasetIndex){ - helpers.extend(element,{ - y: base, - base : base - }); - }); - this.render(); - }, - draw : function(ease){ - - var easingDecimal = ease || 1; - this.clear(); - - this.scale.draw(easingDecimal); - - //Draw all the bars for each dataset - this.eachElement(function(bar, index, datasetIndex){ - if (bar.hasValue()){ - // Update the bar basepoint - bar.base = this.calculateBaseY(); - //Transition - bar.transition(easingDecimal).draw(); - } - }, this); - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - } - }); +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + + var defaultConfig = { + //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 - Whether to show horizontal lines (except X axis) + scaleShowHorizontalLines: true, + + //Boolean - Whether to show vertical lines (except Y axis) + scaleShowVerticalLines: true, + + //Number - Pixel width of the bar border + barBorderWidth: 2, + + //Number - Spacing between each of the X value sets + barValueSpacing: 5, + + //Number - Spacing between data sets within X values + barDatasetSpacing: 1, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + + }; + + + Chart.Type.extend({ + name: "Bar", + defaults: defaultConfig, + initialize: function(data) { + + // Save data as a source for updating of values & methods + this.data = data; + + var options = this.options; + + // Custom Scale Methods and Options + this.ScaleClass = Chart.Scale.extend({ + offsetGridLines: true, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.calculateX(elementIndex) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth / 2; + }, + calculateBaseWidth: function() { + return (this.calculateX(1) - this.calculateX(0)) - (2 * options.barValueSpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); + + return (baseWidth / datasetCount); + } + }); + + // Events + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + + //Declare the extension of the default point, to cater for the options passed in to the constructor + this.BarClass = Chart.Rectangle.extend({ + ctx: this.chart.ctx, + }); + + // Build Scale + this.buildScale(this.data.labels); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new this.BarClass()); + }, this); + }, this); + + // Set defaults for bars + this.eachElement(function(bar, index, datasetIndex) { + helpers.extend(bar, { + width: this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.calculateBaseY(), + _datasetIndex: datasetIndex, + _index: index, + }); + // Copy to view model + bar.save(); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Update the chart with the latest data. + this.update(); + }, + onHover: function(e) { + + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; + this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; + this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + this.tooltip.pivot(); + + // Hover animations + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + // Calculate the base point for the bar. + calculateBaseY: function() { + var base = this.scale.endPoint; + + if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) { + base = this.scale.calculateY(0); + base += this.options.scaleGridLineWidth; + } else if (this.scale.min < 0 && this.scale.max < 0) { + // All values are negative. Use the top as the base + base = this.scale.startPoint; + } + + return base; + }, + update: function() { + + this.scale.update(); + + this.eachElement(function(bar, index, dataset, datasetIndex) { + helpers.extend(bar, { + width: this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), + value: this.data.datasets[datasetIndex].data[index], + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + borderColor: this.data.datasets[datasetIndex].borderColor, + borderWidth: this.data.datasets[datasetIndex].borderWidth, + backgroundColor: this.data.datasets[datasetIndex].backgroundColor, + _datasetIndex: datasetIndex, + _index: index, + }); + bar.pivot(); + }, this); + + this.render(); + }, + buildScale: function(labels) { + var self = this; + + var dataTotal = function() { + var values = []; + self.eachValue(function(value) { + values.push(value); + }); + return values; + }; + + var scaleOptions = { + 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: labels.length, + beginAtZero: this.options.scaleBeginAtZero, + integersOnly: this.options.scaleIntegersOnly, + calculateYRange: function(currentHeight) { + var updatedRanges = helpers.calculateScaleRange( + dataTotal(), + currentHeight, + this.fontSize, + this.beginAtZero, + this.integersOnly + ); + helpers.extend(this, updatedRanges); + }, + xLabels: labels, + font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), + lineWidth: this.options.scaleLineWidth, + lineColor: this.options.scaleLineColor, + showHorizontalLines: this.options.scaleShowHorizontalLines, + showVerticalLines: this.options.scaleShowVerticalLines, + 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.borderWidth, + showLabels: this.options.scaleShowLabels, + display: this.options.showScale + }; + + if (this.options.scaleOverride) { + helpers.extend(scaleOptions, { + calculateYRange: helpers.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(scaleOptions); + }, + // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function + redraw: function() { + var base = this.calculateBaseY(); + this.eachElement(function(element, index, datasetIndex) { + helpers.extend(element, { + y: base, + base: base + }); + }); + this.render(); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + this.scale.draw(easingDecimal); + + //Draw all the bars for each dataset + this.eachElement(function(bar, index, datasetIndex) { + if (bar.hasValue()) { + // Update the bar basepoint + bar.base = this.calculateBaseY(); + //Transition + bar.transition(easingDecimal).draw(); + } + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + } + }); }).call(this); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 0fa13465d47..1d6651ab706 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -9,1724 +9,1720 @@ */ -(function(){ +(function() { - "use strict"; + "use strict"; - //Declare root variable - window in the browser, global on the server - var root = this, - previous = root.Chart; + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart; - //Occupy the global variable of Chart, and create a simple base class - var Chart = function(context){ - var chart = this; - this.canvas = context.canvas; + //Occupy the global variable of Chart, and create a simple base class + var Chart = function(context) { + var chart = this; + this.canvas = context.canvas; - this.ctx = context; + this.ctx = context; - //Variables global to the chart - var computeDimension = function(element,dimension) - { - if (element['offset'+dimension]) - { - return element['offset'+dimension]; - } - else - { - return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); - } - }; + //Variables global to the chart + var computeDimension = function(element, dimension) { + if (element['offset' + dimension]) { + return element['offset' + dimension]; + } else { + return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); + } + }; - var width = this.width = computeDimension(context.canvas,'Width') || context.canvas.width; - var height = this.height = computeDimension(context.canvas,'Height') || context.canvas.height; + var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; + var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; - // Firefox requires this to work correctly - context.canvas.width = width; - context.canvas.height = height; + // Firefox requires this to work correctly + context.canvas.width = width; + context.canvas.height = height; - width = this.width = context.canvas.width; - height = this.height = context.canvas.height; - this.aspectRatio = this.width / this.height; - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. - helpers.retinaScale(this); + width = this.width = context.canvas.width; + height = this.height = context.canvas.height; + this.aspectRatio = this.width / this.height; + //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. + helpers.retinaScale(this); - return this; - }; - //Globally expose the defaults to allow for user updating/changing - Chart.defaults = { - global: { - // Boolean - Whether to animate the chart - animation: true, + return this; + }; + //Globally expose the defaults to allow for user updating/changing + Chart.defaults = { + global: { + // Boolean - Whether to animate the chart + animation: true, - // Number - Number of animation steps - animationDuration: 1000, + // Number - Number of animation steps + animationDuration: 1000, - // String - Animation easing effect - animationEasing: "easeOutQuart", + // String - Animation easing effect + animationEasing: "easeOutQuart", - // Boolean - If we should show the scale at all - showScale: true, + // Boolean - If we should show the scale at all + showScale: true, - // Boolean - If we want to override with a hard coded scale - scaleOverride: false, + // 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, + // ** 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)", + // String - Colour of the scale line + scaleLineColor: "rgba(0,0,0,.1)", - // Number - Pixel width of the scale line - scaleLineWidth: 1, + // Number - Pixel width of the scale line + scaleLineWidth: 1, - // Boolean - Whether to show labels on the scale - scaleShowLabels: true, + // Boolean - Whether to show labels on the scale + scaleShowLabels: true, - // Interpolated JS string - can access value - scaleLabel: "<%=value%>", + // Interpolated JS string - can access value + scaleLabel: "<%=value%>", - // Boolean - Whether the scale should stick to integers, and not show any floats even if drawing space is there - scaleIntegersOnly: true, + // Boolean - Whether the scale should stick to integers, and not show any 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, + // 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", + // 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, + // Number - Scale label font size in pixels + scaleFontSize: 12, - // String - Scale label font weight style - scaleFontStyle: "normal", + // String - Scale label font weight style + scaleFontStyle: "normal", - // String - Scale label font colour - scaleFontColor: "#666", + // 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 - 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, - //String / Boolean - Hover mode for events. - hoverMode : 'single', // 'label', 'dataset', 'false' + //String / Boolean - Hover mode for events. + hoverMode: 'single', // 'label', 'dataset', 'false' - //Function - Custom hover handler - onHover : null, + //Function - Custom hover handler + onHover: null, - //Function - Custom hover handler - hoverAnimationDuration : 400, + //Function - Custom hover handler + hoverAnimationDuration: 400, - // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove - showTooltips: true, + // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove + showTooltips: true, - // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function - customTooltips: false, + // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function + customTooltips: false, - // Array - Array of string names to attach tooltip events - tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], + // Array - Array of string names to attach tooltip events + tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], - // String - Tooltip background colour - tooltipBackgroundColor: "rgba(0,0,0,0.8)", + // String - Tooltip background colour + tooltipBackgroundColor: "rgba(0,0,0,0.8)", - // String - Tooltip label font declaration for the scale label - tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + // 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, - - // String - Template string for single tooltips - tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", - - // String - Template string for single tooltips - multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", - - // String - Colour behind the legend colour block - multiTooltipKeyBackground: '#fff', - - // Function - Will fire on animation progression. - onAnimationProgress: function(){}, - - // Function - Will fire on animation completion. - onAnimationComplete: function(){}, - - // Color String - Used for undefined Colros - colorFallback: 'rgba(0,0,0,0.1)', - - } - }; - - //Create a dictionary of chart types, to allow for extension of existing types - Chart.types = {}; - - //Global Chart helpers object for utility methods and classes - var helpers = Chart.helpers = {}; - - //-- Basic js utility methods - var each = helpers.each = function(loopable,callback,self){ - var additionalArgs = Array.prototype.slice.call(arguments, 3); - // Check to see if null or undefined firstly. - if (loopable){ - if (loopable.length === +loopable.length){ - var i; - for (i=0; i= 0; i--) { - var currentItem = arrayToSearch[i]; - if (filterCallback(currentItem)){ - return currentItem; - } - } - }, - inherits = helpers.inherits = function(extensions){ - //Basic javascript inheritance based on the model created in Backbone.js - var parent = this; - var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function(){ return parent.apply(this, arguments); }; - - var Surrogate = function(){ this.constructor = ChartElement;}; - Surrogate.prototype = parent.prototype; - ChartElement.prototype = new Surrogate(); - - ChartElement.extend = inherits; - - if (extensions) extend(ChartElement.prototype, extensions); - - ChartElement.__super__ = parent.prototype; - - return ChartElement; - }, - noop = helpers.noop = function(){}, - uid = helpers.uid = (function(){ - var id=0; - return function(){ - return "chart-" + id++; - }; - })(), - warn = helpers.warn = function(str){ - //Method for warning of errors - if (window.console && typeof window.console.warn === "function") console.warn(str); - }, - amd = helpers.amd = (typeof define === 'function' && define.amd), - //-- Math methods - isNumber = helpers.isNumber = function(n){ - return !isNaN(parseFloat(n)) && isFinite(n); - }, - max = helpers.max = function(array){ - return Math.max.apply( Math, array ); - }, - min = helpers.min = function(array){ - return Math.min.apply( Math, array ); - }, - cap = helpers.cap = function(valueToCap,maxValue,minValue){ - if(isNumber(maxValue)) { - if( valueToCap > maxValue ) { - return maxValue; - } - } - else if(isNumber(minValue)){ - if ( valueToCap < minValue ){ - return minValue; - } - } - return valueToCap; - }, - getDecimalPlaces = helpers.getDecimalPlaces = function(num){ - if (num%1!==0 && isNumber(num)){ - var s = num.toString(); - if(s.indexOf("e-") < 0){ - // no exponent, e.g. 0.01 - return s.split(".")[1].length; - } - else if(s.indexOf(".") < 0) { - // no decimal point, e.g. 1e-9 - return parseInt(s.split("e-")[1]); - } - else { - // exponent and decimal point, e.g. 1.23e-9 - var parts = s.split(".")[1].split("e-"); - return parts[0].length + parseInt(parts[1]); - } - } - else { - return 0; - } - }, - toRadians = helpers.radians = function(degrees){ - return degrees * (Math.PI/180); - }, - // Gets the angle from vertical upright to the point about a centre. - getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint){ - var distanceFromXCenter = anglePoint.x - centrePoint.x, - distanceFromYCenter = anglePoint.y - centrePoint.y, - radialDistanceFromCenter = Math.sqrt( distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); - - - var angle = Math.PI * 2 + Math.atan2(distanceFromYCenter, distanceFromXCenter); - - //If the segment is in the top left quadrant, we need to add another rotation to the angle - if (distanceFromXCenter < 0 && distanceFromYCenter < 0){ - angle += Math.PI*2; - } - - return { - angle: angle, - distance: radialDistanceFromCenter - }; - }, - aliasPixel = helpers.aliasPixel = function(pixelWidth){ - return (pixelWidth % 2 === 0) ? 0 : 0.5; - }, - splineCurve = helpers.splineCurve = function(FirstPoint,MiddlePoint,AfterPoint,t){ - //Props to Rob Spencer at scaled innovation for his post on splining between points - //http://scaledinnovation.com/analytics/splines/aboutSplines.html - var d01=Math.sqrt(Math.pow(MiddlePoint.x-FirstPoint.x,2)+Math.pow(MiddlePoint.y-FirstPoint.y,2)), - d12=Math.sqrt(Math.pow(AfterPoint.x-MiddlePoint.x,2)+Math.pow(AfterPoint.y-MiddlePoint.y,2)), - fa=t*d01/(d01+d12),// scaling factor for triangle Ta - fb=t*d12/(d01+d12); - return { - next : { - x : MiddlePoint.x-fa*(AfterPoint.x-FirstPoint.x), - y : MiddlePoint.y-fa*(AfterPoint.y-FirstPoint.y) - }, - previous : { - x: MiddlePoint.x+fb*(AfterPoint.x-FirstPoint.x), - y : MiddlePoint.y+fb*(AfterPoint.y-FirstPoint.y) - } - }; - }, - calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val){ - return Math.floor(Math.log(val) / Math.LN10); - }, - calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly){ - - //Set a minimum step of two - a point at the top of the graph, and a point at the base - var minSteps = 2, - maxSteps = Math.floor(drawingSize/(textSize * 1.5)), - skipFitting = (minSteps >= maxSteps); - - var maxValue = max(valuesArray), - minValue = min(valuesArray); - - // We need some degree of seperation here to calculate the scales if all the values are the same - // Adding/minusing 0.5 will give us a range of 1. - if (maxValue === minValue){ - maxValue += 0.5; - // So we don't end up with a graph with a negative start value if we've said always start from zero - if (minValue >= 0.5 && !startFromZero){ - minValue -= 0.5; - } - else{ - // Make up a whole number above the values - maxValue += 0.5; - } - } - - var valueRange = Math.abs(maxValue - minValue), - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphRange = graphMax - graphMin, - stepValue = Math.pow(10, rangeOrderOfMagnitude), - numberOfSteps = Math.round(graphRange / stepValue); - - //If we have more space on the graph we'll use it to give more definition to the data - while((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { - if(numberOfSteps > maxSteps){ - stepValue *=2; - numberOfSteps = Math.round(graphRange/stepValue); - // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. - if (numberOfSteps % 1 !== 0){ - skipFitting = true; - } - } - //We can fit in double the amount of scale points on the scale - else{ - //If user has declared ints only, and the step value isn't a decimal - if (integersOnly && rangeOrderOfMagnitude >= 0){ - //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float - if(stepValue/2 % 1 === 0){ - stepValue /=2; - numberOfSteps = Math.round(graphRange/stepValue); - } - //If it would make it a float break out of the loop - else{ - break; - } - } - //If the scale doesn't have to be an int, make the scale more granular anyway. - else{ - stepValue /=2; - numberOfSteps = Math.round(graphRange/stepValue); - } - - } - } - - if (skipFitting){ - numberOfSteps = minSteps; - stepValue = graphRange / numberOfSteps; - } - return { - steps : numberOfSteps, - stepValue : stepValue, - min : graphMin, - max : graphMin + (numberOfSteps * stepValue) - }; - - }, - /* jshint ignore:start */ - // Blows up jshint errors based on the new Function constructor - //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 instanceof Function){ - return templateString(valuesObject); - } - - var cache = {}; - function tmpl(str, data){ - // Figure out if we're getting a template, or if we need to - // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] : - - // Generate a reusable function that will serve as a template - // generator (and which will be cached). - new Function("obj", - "var p=[],print=function(){p.push.apply(p,arguments);};" + - - // Introduce the data as local variables using with(){} - "with(obj){p.push('" + - - // Convert the template into pure JavaScript - str - .replace(/[\r\t\n]/g, " ") - .split("<%").join("\t") - .replace(/((^|%>)[^\t]*)'/g, "$1\r") - .replace(/\t=(.*?)%>/g, "',$1,'") - .split("\t").join("');") - .split("%>").join("p.push('") - .split("\r").join("\\'") + - "');}return p.join('');" - ); - - // Provide some basic currying to the user - return data ? fn( data ) : fn; - } - return tmpl(templateString,valuesObject); - }, - /* jshint ignore:end */ - generateLabels = helpers.generateLabels = function(templateString,numberOfSteps,graphMin,stepValue){ - var labelsArray = new Array(numberOfSteps); - if (templateString){ - each(labelsArray,function(val,index){ - labelsArray[index] = template(templateString,{value: (graphMin + (stepValue*(index+1)))}); - }); - } - return labelsArray; - }, - //--Animation methods - //Easing functions adapted from Robert Penner's easing equations - //http://www.robertpenner.com/easing/ - easingEffects = helpers.easingEffects = { - linear: function (t) { - return t; - }, - easeInQuad: function (t) { - return t * t; - }, - easeOutQuad: function (t) { - return -1 * t * (t - 2); - }, - easeInOutQuad: function (t) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t; - } - return -1 / 2 * ((--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) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t * t; - } - return 1 / 2 * ((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) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t * t * t; - } - return -1 / 2 * ((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) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t * t * t * t; - } - return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); - }, - easeInExpo: function (t) { - return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); - }, - easeOutExpo: function (t) { - return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); - }, - easeInOutExpo: function (t) { - if (t === 0){ - return 0; - } - if (t === 1){ - return 1; - } - if ((t /= 1 / 2) < 1){ - return 1 / 2 * Math.pow(2, 10 * (t - 1)); - } - return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); - }, - easeInCirc: function (t) { - if (t >= 1){ - return t; - } - return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); - }, - easeOutCirc: function (t) { - return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); - }, - easeInOutCirc: function (t) { - if ((t /= 1 / 2) < 1){ - return -1 / 2 * (Math.sqrt(1 - t * t) - 1); - } - return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); - }, - easeInElastic: function (t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0){ - return 0; - } - if ((t /= 1) == 1){ - return 1; - } - if (!p){ - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else{ - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); - }, - easeOutElastic: function (t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0){ - return 0; - } - if ((t /= 1) == 1){ - return 1; - } - if (!p){ - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else{ - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; - }, - easeInOutElastic: function (t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0){ - return 0; - } - if ((t /= 1 / 2) == 2){ - return 1; - } - if (!p){ - p = 1 * (0.3 * 1.5); - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - if (t < 1){ - return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));} - return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; - }, - easeInBack: function (t) { - var s = 1.70158; - return 1 * (t /= 1) * t * ((s + 1) * t - s); - }, - easeOutBack: function (t) { - var s = 1.70158; - return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); - }, - easeInOutBack: function (t) { - var s = 1.70158; - if ((t /= 1 / 2) < 1){ - return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); - } - return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); - }, - easeInBounce: function (t) { - return 1 - easingEffects.easeOutBounce(1 - t); - }, - easeOutBounce: function (t) { - if ((t /= 1) < (1 / 2.75)) { - return 1 * (7.5625 * t * t); - } else if (t < (2 / 2.75)) { - return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); - } else if (t < (2.5 / 2.75)) { - return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); - } else { - return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); - } - }, - easeInOutBounce: function (t) { - if (t < 1 / 2){ - return easingEffects.easeInBounce(t * 2) * 0.5; - } - return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; - } - }, - //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ - requestAnimFrame = helpers.requestAnimFrame = (function(){ - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - return window.setTimeout(callback, 1000 / 60); - }; - })(), - cancelAnimFrame = helpers.cancelAnimFrame = (function(){ - return window.cancelAnimationFrame || - window.webkitCancelAnimationFrame || - window.mozCancelAnimationFrame || - window.oCancelAnimationFrame || - window.msCancelAnimationFrame || - function(callback) { - return window.clearTimeout(callback, 1000 / 60); - }; - })(), - animationLoop = helpers.animationLoop = function(callback,totalSteps,easingString,onProgress,onComplete,chartInstance){ - - var currentStep = 0, - easingFunction = easingEffects[easingString] || easingEffects.linear; - - var animationFrame = function(){ - currentStep++; - var stepDecimal = currentStep/totalSteps; - var easeDecimal = easingFunction(stepDecimal); - - callback.call(chartInstance,easeDecimal,stepDecimal, currentStep); - onProgress.call(chartInstance,easeDecimal,stepDecimal); - if (currentStep < totalSteps){ - chartInstance.animationFrame = requestAnimFrame(animationFrame); - } else{ - onComplete.apply(chartInstance); - } - }; - requestAnimFrame(animationFrame); - }, - //-- DOM methods - getRelativePosition = helpers.getRelativePosition = function(evt){ - var mouseX, mouseY; - var e = evt.originalEvent || evt, - canvas = evt.currentTarget || evt.srcElement, - boundingRect = canvas.getBoundingClientRect(); - - if (e.touches){ - mouseX = e.touches[0].clientX - boundingRect.left; - mouseY = e.touches[0].clientY - boundingRect.top; - - } - else{ - mouseX = e.clientX - boundingRect.left; - mouseY = e.clientY - boundingRect.top; - } - - return { - x : mouseX, - y : mouseY - }; - - }, - addEvent = helpers.addEvent = function(node,eventType,method){ - if (node.addEventListener){ - node.addEventListener(eventType,method); - } else if (node.attachEvent){ - node.attachEvent("on"+eventType, method); - } else { - node["on"+eventType] = method; - } - }, - removeEvent = helpers.removeEvent = function(node, eventType, handler){ - if (node.removeEventListener){ - node.removeEventListener(eventType, handler, false); - } else if (node.detachEvent){ - node.detachEvent("on"+eventType,handler); - } else{ - node["on" + eventType] = noop; - } - }, - bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler){ - // Create the events object if it's not already present - if (!chartInstance.events) chartInstance.events = {}; - - each(arrayOfEvents,function(eventName){ - chartInstance.events[eventName] = function(){ - handler.apply(chartInstance, arguments); - }; - addEvent(chartInstance.chart.canvas,eventName,chartInstance.events[eventName]); - }); - }, - unbindEvents = helpers.unbindEvents = function (chartInstance, arrayOfEvents) { - each(arrayOfEvents, function(handler,eventName){ - removeEvent(chartInstance.chart.canvas, eventName, handler); - }); - }, - getMaximumWidth = helpers.getMaximumWidth = function(domNode){ - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); - // TODO = check cross browser stuff with this. - return container.clientWidth - padding; - }, - getMaximumHeight = helpers.getMaximumHeight = function(domNode){ - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); - // TODO = check cross browser stuff with this. - return container.clientHeight - padding; - }, - getStyle = helpers.getStyle = function (el, property) { - return el.currentStyle ? - el.currentStyle[property] : - document.defaultView.getComputedStyle(el, null).getPropertyValue(property); - }, - getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support - retinaScale = helpers.retinaScale = function(chart){ - var ctx = chart.ctx, - width = chart.canvas.width, - height = chart.canvas.height; - - if (window.devicePixelRatio) { - ctx.canvas.style.width = width + "px"; - ctx.canvas.style.height = height + "px"; - ctx.canvas.height = height * window.devicePixelRatio; - ctx.canvas.width = width * window.devicePixelRatio; - ctx.scale(window.devicePixelRatio, window.devicePixelRatio); - } - }, - //-- Canvas methods - clear = helpers.clear = function(chart){ - chart.ctx.clearRect(0,0,chart.width,chart.height); - }, - fontString = helpers.fontString = function(pixelSize,fontStyle,fontFamily){ - return fontStyle + " " + pixelSize+"px " + fontFamily; - }, - longestText = helpers.longestText = function(ctx,font,arrayOfStrings){ - ctx.font = font; - var longest = 0; - each(arrayOfStrings,function(string){ - var textWidth = ctx.measureText(string).width; - longest = (textWidth > longest) ? textWidth : longest; - }); - return longest; - }, - drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx,x,y,width,height,radius){ - ctx.beginPath(); - ctx.moveTo(x + radius, y); - ctx.lineTo(x + width - radius, y); - ctx.quadraticCurveTo(x + width, y, x + width, y + radius); - ctx.lineTo(x + width, y + height - radius); - ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); - ctx.lineTo(x + radius, y + height); - ctx.quadraticCurveTo(x, y + height, x, y + height - radius); - ctx.lineTo(x, y + radius); - ctx.quadraticCurveTo(x, y, x + radius, y); - ctx.closePath(); - }, - color = helpers.color = function(color){ - if(!window.Color){ - console.log('Color.js not found!'); - return color; - } - return window.Color(color); - }, - isArray = helpers.isArray = function(obj){ - if (!Array.isArray) { - return Object.prototype.toString.call(arg) === '[object Array]'; - } - return Array.isArray(obj); - }; - - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. - //Destroy method on the chart will remove the instance of the chart from this reference. - Chart.instances = {}; - - Chart.Type = function(data,options,chart){ - this.options = options; - this.chart = chart; - this.id = uid(); - //Add the chart instance to the global namespace - Chart.instances[this.id] = this; - - // Initialize is always called when a chart type is created - // By default it is a no op, but it should be extended - if (options.responsive){ - this.resize(); - } - this.initialize.call(this,data); - }; - - //Core methods that'll be a part of every chart type - extend(Chart.Type.prototype,{ - initialize : function(){return this;}, - clear : function(){ - clear(this.chart); - return this; - }, - stop : function(){ - // Stops any current animation loop occuring - Chart.animationService.cancelAnimation(this); - return this; - }, - resize : function(callback){ - this.stop(); - var canvas = this.chart.canvas, - newWidth = getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); - - canvas.width = this.chart.width = newWidth; - canvas.height = this.chart.height = newHeight; - - retinaScale(this.chart); - - if (typeof callback === "function"){ - callback.apply(this, Array.prototype.slice.call(arguments, 1)); - } - return this; - }, - redraw : noop, - render : function(duration){ - - if (this.options.animation){ - var animation = new Chart.Animation(); - animation.numSteps = (duration || this.options.animationDuration) / 16.66; //60 fps - animation.easing = this.options.animationEasing; - - // render function - animation.render = function(chartInstance, animationObject) { - var easingFunction = helpers.easingEffects[animationObject.easing]; - var stepDecimal = animationObject.currentStep / animationObject.numSteps; - var easeDecimal = easingFunction(stepDecimal); - - chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); - }; - - // user events - animation.onAnimationProgress = this.options.onAnimationProgress; - animation.onAnimationComplete = this.options.onAnimationComplete; - - Chart.animationService.addAnimation(this, animation, duration); - } - else{ - this.draw(); - this.options.onAnimationComplete.call(this); - } - return this; - }, - eachElement : function(callback){ - helpers.each(this.data.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - },this); - }, - eachValue : function(callback){ - helpers.each(this.data.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.data, callback, this, datasetIndex); - },this); - }, - eachDataset : function(callback){ - helpers.each(this.data.datasets, callback, this); - }, - getElementsAtEvent : function(e){ - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset){ - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x,eventPosition.y)){ - helpers.each(this.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; - }, - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent : function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } - - return []; - }, - generateLegend : function(){ - return template(this.options.legendTemplate,this); - }, - 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]; - }, - toBase64Image : function(){ - return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); - } - }); - - Chart.Type.extend = function(extensions){ - - var parent = this; - - var ChartType = function(){ - return parent.apply(this,arguments); - }; - - //Copy the prototype object of the this class - ChartType.prototype = clone(parent.prototype); - //Now overwrite some of the properties in the base class with the new extensions - extend(ChartType.prototype, extensions); - - ChartType.extend = Chart.Type.extend; - - if (extensions.name || parent.prototype.name){ - - var chartName = extensions.name || parent.prototype.name; - //Assign any potential default values of the new chart type - - //If none are defined, we'll use a clone of the chart type this is being extended from. - //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart - //doesn't define some defaults of their own. - - var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; - - Chart.defaults[chartName] = extend(baseDefaults,extensions.defaults); - - Chart.types[chartName] = ChartType; - - //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(data,options){ - var config = merge(Chart.defaults.global, Chart.defaults[chartName], options || {}); - return new ChartType(data,config,this); - }; - } else{ - warn("Name not provided for this chart, so it hasn't been registered"); - } - return parent; - }; - - Chart.Element = function(configuration){ - extend(this,{ - _vm: {}, - }); - extend(this,configuration); - this.initialize.apply(this,arguments); - }; - extend(Chart.Element.prototype,{ - initialize : function(){}, - save: function(){ - this._vm = clone(this); - delete this._vm._vm; - delete this._vm._start; - return this; - }, - pivot: function(){ - if(this._start){ - this._start = clone(this); - helpers.extend(this._start, this._vm); - } - return this; - }, - transition : function(ease){ - if(!this._start){ - if(!this._vm){ - this.save(); - } - this._start = clone(this._vm); - } - - each(this,function(value, key){ - - if(key[0] === '_' || !this.hasOwnProperty(key)){ - // Only non-underscored properties - } - - // Init if doesn't exist - else if(!this._vm[key]){ - this._vm[key] = value || null; - } - - // No unnecessary computations - else if(this[key] === this._vm[key]){ - // It's the same! Woohoo! - } - - // Color transitions if possible - else if(typeof value === 'string'){ - try{ - var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); - this._vm[key] = color.rgbString(); - } catch(err){ - this._vm[key] = value; - } - } - // Number transitions - else if(typeof value === 'number'){ - - this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; - } - else{ - // Everything else - this._vm[key] = value; - } - - },this); - - if(ease === 1){ - delete this._start; - } - return this; - }, - tooltipPosition : function(){ - return { - x : this.x, - y : this.y - }; - }, - hasValue: function(){ - return isNumber(this.value); - } - }); - - Chart.Element.extend = inherits; - - - Chart.Point = Chart.Element.extend({ - inRange: function(mouseX,mouseY){ - var vm = this._vm; - var hoverRange = vm.hoverRadius + vm.radius; - return ((Math.pow(mouseX - vm.x, 2)+Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange,2)); - }, - inGroupRange: function(mouseX){ - var vm = this._vm; - return (Math.pow(mouseX-vm.x, 2) < Math.pow(vm.radius + this.hoverRadius,2)); - }, - tooltipPosition : function(){ - var vm = this._vm; - return { - x : vm.x, - y : vm.y - }; - }, - draw : function(){ - - var vm = this._vm; - var ctx = this._chart.ctx; - - if (vm.radius > 0 || vm.borderWidth > 0){ - - ctx.beginPath(); - - ctx.arc(vm.x, vm.y, vm.radius, 0, Math.PI*2); - ctx.closePath(); - - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; - - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; - - ctx.fill(); - ctx.stroke(); - } - } - }); - - - Chart.Line = Chart.Element.extend({ - draw : function(){ - - var vm = this._vm; - var ctx = this._chart.ctx; - - //Draw the line between all the points - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; - ctx.beginPath(); - - helpers.each(vm._points, function(point, index){ - if (index === 0){ - ctx.moveTo(point._vm.x, point._vm.y); - } - else{ - if(vm._tension > 0 || 1){ - var previous = this.previousPoint(point, vm._points, index); - - ctx.bezierCurveTo( - previous._vm.controlPointNextX, - previous._vm.controlPointNextY, - point._vm.controlPointPreviousX, - point._vm.controlPointPreviousY, - point._vm.x, - point._vm.y - ); - } - else{ - ctx.lineTo(point._vm.x,point._vm.y); - } - } - }, this); - - ctx.stroke(); - - if (vm._points.length > 0){ - //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleBottom); - ctx.lineTo(vm._points[0].x, vm.scaleBottom); - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; - ctx.closePath(); - ctx.fill(); - } - }, - previousPoint: function(point, collection, index){ - return helpers.findPreviousWhere(collection, function(){return true;}, index) || point; - }, - }); - - Chart.Arc = Chart.Element.extend({ - inRange : function(chartX,chartY){ - - var pointRelativePosition = helpers.getAngleFromPoint(this, { - x: chartX, - y: chartY - }); - - //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle), - withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius); - - return (betweenAngles && withinRadius); - //Ensure within the outside of the arc centre, but inside arc outer - }, - tooltipPosition : function(){ - var centreAngle = this.startAngle + ((this.endAngle - this.startAngle) / 2), - rangeFromCentre = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius; - return { - x : this.x + (Math.cos(centreAngle) * rangeFromCentre), - y : this.y + (Math.sin(centreAngle) * rangeFromCentre) - }; - }, - draw : function(animationPercent){ - - var easingDecimal = animationPercent || 1; - - var ctx = this.ctx; - - ctx.beginPath(); - - ctx.arc(this.x, this.y, this.outerRadius, this.startAngle, this.endAngle); - - ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); - - ctx.closePath(); - ctx.strokeStyle = this.borderColor; - ctx.lineWidth = this.borderWidth; - - ctx.fillStyle = this.backgroundColor; - - ctx.fill(); - ctx.lineJoin = 'bevel'; - - if (this.showBorder){ - ctx.stroke(); - } - } - }); - - Chart.Rectangle = Chart.Element.extend({ - draw : function(){ - - var vm = this._vm; - - var ctx = this.ctx, - halfWidth = vm.width/2, - leftX = vm.x - halfWidth, - rightX = vm.x + halfWidth, - top = vm.base - (vm.base - vm.y), - halfStroke = vm.borderWidth / 2; - - // Canvas doesn't allow us to stroke inside the width so we can - // adjust the sizes to fit if we're setting a stroke on the line - if (vm.borderWidth){ - leftX += halfStroke; - rightX -= halfStroke; - top += halfStroke; - } - - ctx.beginPath(); - - ctx.fillStyle = vm.backgroundColor; - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; - - // It'd be nice to keep this class totally generic to any rectangle - // and simply specify which border to miss out. - ctx.moveTo(leftX, vm.base); - ctx.lineTo(leftX, top); - ctx.lineTo(rightX, top); - ctx.lineTo(rightX, vm.base); - ctx.fill(); - if (vm.borderWidth){ - ctx.stroke(); - } - }, - height : function(){ - var vm = this._vm; - return vm.base - vm.y; - }, - inRange : function(mouseX,mouseY){ - var vm = this._vm; - if (vm.y < vm.base){ - return (mouseX >= vm.x - vm.width/2 && mouseX <= vm.x + vm.width/2) && (mouseY >= vm.y && mouseY <= vm.base); - } else{ - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); - } - }, - inGroupRange: function(mouseX){ - var vm = this._vm; - return (mouseX >= vm.x - vm.width/2 && mouseX <= vm.x + vm.width/2); - }, - tooltipPosition : function(){ - var vm = this._vm; - if (vm.y < vm.base){ - return { - x : vm.x, - y : vm.y - }; - } - else{ - return { - x : vm.x, - y : vm.base - }; - } - }, - }); - - Chart.Animation = Chart.Element.extend({ - currentStep: null, // the current animation step - numSteps: 60, // default number of steps - easing: "", // the easing to use for this animation - render: null, // render function used by the animation service - - onAnimationProgress: null, // user specified callback to fire on each step of the animation - onAnimationComplete: null, // user specified callback to fire when the animation finishes - }); - - Chart.Tooltip = Chart.Element.extend({ - initialize : function(){ - var options = this._options; - extend(this, { - opacity:0, - xPadding: options.tooltipXPadding, - yPadding: options.tooltipYPadding, - xOffset: options.tooltipXOffset, - backgroundColor: options.tooltipBackgroundColor, - textColor: options.tooltipFontColor, - _fontFamily: options.tooltipFontFamily, - _fontStyle: options.tooltipFontStyle, - fontSize: options.tooltipFontSize, - titleTextColor: options.tooltipTitleFontColor, - _titleFontFamily: options.tooltipTitleFontFamily, - _titleFontStyle: options.tooltipTitleFontStyle, - titleFontSize: options.tooltipTitleFontSize, - caretHeight: options.tooltipCaretSize, - cornerRadius: options.tooltipCornerRadius, - legendColorBackground : options.multiTooltipKeyBackground, - labels: [], - colors: [], - }); - }, - update: function(){ - - var ctx = this._chart.ctx; - - switch(this._options.hoverMode){ - case 'single': - helpers.extend(this, { - text: template(this._options.tooltipTemplate, this._active[0]), - }); - var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this, { - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - }); - break; - - case 'label': - - // Tooltip Content - - var dataArray, - dataIndex; - - var labels = [], - colors = []; - - for (var i = this._data.datasets.length - 1; i >= 0; i--) { - dataArray = this._data.datasets[i].metaData; - dataIndex = indexOf(dataArray, this._active[0]); - if (dataIndex !== -1){ - break; - } - } - - var medianPosition = (function(index) { - // Get all the points at that particular index - var elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this._data.datasets, function(dataset){ - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ - elements.push(dataCollection[dataIndex]); - } - }); - - helpers.each(elements, function(element) { - xPositions.push(element._vm.x); - yPositions.push(element._vm.y); - - //Include any colour information about the element - labels.push(helpers.template(this._options.multiTooltipTemplate, element)); - colors.push({ - fill: element._vm.backgroundColor, - stroke: element._vm.borderColor - }); - - }, this); - - yMin = min(yPositions); - yMax = max(yPositions); - - xMin = min(xPositions); - xMax = max(xPositions); - - return { - x: (xMin > this._chart.width/2) ? xMin : xMax, - y: (yMin + yMax)/2, - }; - }).call(this, dataIndex); - - // Apply for now - helpers.extend(this, { - x: medianPosition.x, - y: medianPosition.y, - labels: labels, - title: this._active.length ? this._active[0].label : '', - legendColors: colors, - legendBackgroundColor : this._options.multiTooltipKeyBackground, - }); - - - // Calculate Appearance Tweaks - - this.height = (labels.length * this.fontSize) + ((labels.length-1) * (this.fontSize/2)) + (this.yPadding*2) + this.titleFontSize *1.5; - - var titleWidth = ctx.measureText(this.title).width, - //Label has a legend square as well so account for this. - labelWidth = longestText(ctx,this.font,labels) + this.fontSize + 3, - longestTextWidth = max([labelWidth,titleWidth]); - - this.width = longestTextWidth + (this.xPadding*2); - - - var halfHeight = this.height/2; - - //Check to ensure the height will fit on the canvas - if (this.y - halfHeight < 0 ){ - this.y = halfHeight; - } else if (this.y + halfHeight > this._chart.height){ - this.y = this._chart.height - halfHeight; - } - - //Decide whether to align left or right based on position on canvas - if (this.x > this._chart.width/2){ - this.x -= this.xOffset + this.width; - } else { - this.x += this.xOffset; - } - break; - } - - return this; - }, - draw : function(){ - - var ctx = this._chart.ctx; - var vm = this._vm; - - switch(this._options.hoverMode){ - case 'single': - - ctx.font = fontString(vm.fontSize,vm._fontStyle,vm._fontFamily); - - vm.xAlign = "center"; - vm.yAlign = "above"; - - //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding = 2; - - var tooltipWidth = ctx.measureText(vm.text).width + 2*vm.xPadding, - tooltipRectHeight = vm.fontSize + 2*vm.yPadding, - tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - - if (vm.x + tooltipWidth/2 >this._chart.width){ - vm.xAlign = "left"; - } else if (vm.x - tooltipWidth/2 < 0){ - vm.xAlign = "right"; - } - - if (vm.y - tooltipHeight < 0){ - vm.yAlign = "below"; - } - - var tooltipX = vm.x - tooltipWidth/2, - tooltipY = vm.y - tooltipHeight; - - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - - // Custom Tooltips - if(this._custom){ - this._custom(this._vm); - } - else{ - switch(vm.yAlign){ - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x,vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } - - switch(vm.xAlign){ - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } - - drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,vm.cornerRadius); - - ctx.fill(); - - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); - - } - break; - case 'label': - - drawRoundedRectangle(ctx, vm.x, vm.y - vm.height/2, vm.width, vm.height, vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - ctx.fill(); - ctx.closePath(); - - ctx.textAlign = "left"; - ctx.textBaseline = "middle"; - ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); - ctx.font = fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); - ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); - - ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - helpers.each(vm.labels,function(label,index){ - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.fillText(label,vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); - - //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) - //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); - //Instead we'll make a white filled block to put the legendColour palette over. - - ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); - - ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); - - - },this); - break; - } - }, - getLineHeight : function(index){ - var baseLineHeight = this._vm.y - (this._vm.height/2) + this._vm.yPadding, - afterTitleIndex = index-1; - - //If the index is zero, we're getting the title - if (index === 0){ - return baseLineHeight + this._vm.titleFontSize/2; - } else{ - return baseLineHeight + ((this._vm.fontSize*1.5*afterTitleIndex) + this._vm.fontSize/2) + this._vm.titleFontSize * 1.5; - } - - }, - }); - - Chart.Scale = Chart.Element.extend({ - initialize : function(){ - this.fit(); - }, - buildYLabels : function(){ - this.yLabels = []; - - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); - - 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) + 10 : 0; - }, - addXLabel : function(label){ - this.xLabels.push(label); - this.valuesCount++; - this.fit(); - }, - removeXLabel : function(){ - this.xLabels.shift(); - this.valuesCount--; - this.fit(); - }, - // Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use - fit: function(){ - // First we need the width of the yLabels, assuming the xLabels aren't rotated - - // To do that we need the base line at the top and base of the chart, assuming there is no x label rotation - this.startPoint = (this.display) ? this.fontSize : 0; - this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels - - // Apply padding settings to the start and end point. - this.startPoint += this.padding; - this.endPoint -= this.padding; - - // Cache the starting endpoint, excluding the space for x labels - var cachedEndPoint = this.endPoint; - - // Cache the starting height, so can determine if we need to recalculate the scale yAxis - var cachedHeight = this.endPoint - this.startPoint, - cachedYLabelWidth; - - // Build the current yLabels so we have an idea of what size they'll be to start - /* + // 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, + + // String - Template string for single tooltips + tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", + + // String - Template string for single tooltips + multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", + + // String - Colour behind the legend colour block + multiTooltipKeyBackground: '#fff', + + // Function - Will fire on animation progression. + onAnimationProgress: function() {}, + + // Function - Will fire on animation completion. + onAnimationComplete: function() {}, + + // Color String - Used for undefined Colros + colorFallback: 'rgba(0,0,0,0.1)', + + } + }; + + //Create a dictionary of chart types, to allow for extension of existing types + Chart.types = {}; + + //Global Chart helpers object for utility methods and classes + var helpers = Chart.helpers = {}; + + //-- Basic js utility methods + var each = helpers.each = function(loopable, callback, self) { + var additionalArgs = Array.prototype.slice.call(arguments, 3); + // Check to see if null or undefined firstly. + if (loopable) { + if (loopable.length === +loopable.length) { + var i; + for (i = 0; i < loopable.length; i++) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } + } else { + for (var item in loopable) { + callback.apply(self, [loopable[item], item].concat(additionalArgs)); + } + } + } + }, + clone = helpers.clone = function(obj) { + var objClone = {}; + each(obj, function(value, key) { + if (obj.hasOwnProperty(key)) { + objClone[key] = value; + } + }); + return objClone; + }, + extend = helpers.extend = function(base) { + each(Array.prototype.slice.call(arguments, 1), function(extensionObject) { + each(extensionObject, function(value, key) { + if (extensionObject.hasOwnProperty(key)) { + base[key] = value; + } + }); + }); + return base; + }, + merge = helpers.merge = function(base, master) { + //Merge properties in left object over to a shallow clone of object right. + var args = Array.prototype.slice.call(arguments, 0); + args.unshift({}); + return extend.apply(null, args); + }, + indexOf = helpers.indexOf = function(arrayToSearch, item) { + if (Array.prototype.indexOf) { + return arrayToSearch.indexOf(item); + } else { + for (var i = 0; i < arrayToSearch.length; i++) { + if (arrayToSearch[i] === item) return i; + } + return -1; + } + }, + where = helpers.where = function(collection, filterCallback) { + var filtered = []; + + helpers.each(collection, function(item) { + if (filterCallback(item)) { + filtered.push(item); + } + }); + + return filtered; + }, + findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to start of the array + if (!startIndex) { + startIndex = -1; + } + for (var i = startIndex + 1; i < arrayToSearch.length; i++) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to end of the array + if (!startIndex) { + startIndex = arrayToSearch.length; + } + for (var i = startIndex - 1; i >= 0; i--) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + inherits = helpers.inherits = function(extensions) { + //Basic javascript inheritance based on the model created in Backbone.js + var parent = this; + var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() { + return parent.apply(this, arguments); + }; + + var Surrogate = function() { + this.constructor = ChartElement; + }; + Surrogate.prototype = parent.prototype; + ChartElement.prototype = new Surrogate(); + + ChartElement.extend = inherits; + + if (extensions) extend(ChartElement.prototype, extensions); + + ChartElement.__super__ = parent.prototype; + + return ChartElement; + }, + noop = helpers.noop = function() {}, + uid = helpers.uid = (function() { + var id = 0; + return function() { + return "chart-" + id++; + }; + })(), + warn = helpers.warn = function(str) { + //Method for warning of errors + if (window.console && typeof window.console.warn === "function") console.warn(str); + }, + amd = helpers.amd = (typeof define === 'function' && define.amd), + //-- Math methods + isNumber = helpers.isNumber = function(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + }, + max = helpers.max = function(array) { + return Math.max.apply(Math, array); + }, + min = helpers.min = function(array) { + return Math.min.apply(Math, array); + }, + cap = helpers.cap = function(valueToCap, maxValue, minValue) { + if (isNumber(maxValue)) { + if (valueToCap > maxValue) { + return maxValue; + } + } else if (isNumber(minValue)) { + if (valueToCap < minValue) { + return minValue; + } + } + return valueToCap; + }, + getDecimalPlaces = helpers.getDecimalPlaces = function(num) { + if (num % 1 !== 0 && isNumber(num)) { + var s = num.toString(); + if (s.indexOf("e-") < 0) { + // no exponent, e.g. 0.01 + return s.split(".")[1].length; + } else if (s.indexOf(".") < 0) { + // no decimal point, e.g. 1e-9 + return parseInt(s.split("e-")[1]); + } else { + // exponent and decimal point, e.g. 1.23e-9 + var parts = s.split(".")[1].split("e-"); + return parts[0].length + parseInt(parts[1]); + } + } else { + return 0; + } + }, + toRadians = helpers.radians = function(degrees) { + return degrees * (Math.PI / 180); + }, + // Gets the angle from vertical upright to the point about a centre. + getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { + var distanceFromXCenter = anglePoint.x - centrePoint.x, + distanceFromYCenter = anglePoint.y - centrePoint.y, + radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + + + var angle = Math.PI * 2 + Math.atan2(distanceFromYCenter, distanceFromXCenter); + + //If the segment is in the top left quadrant, we need to add another rotation to the angle + if (distanceFromXCenter < 0 && distanceFromYCenter < 0) { + angle += Math.PI * 2; + } + + return { + angle: angle, + distance: radialDistanceFromCenter + }; + }, + aliasPixel = helpers.aliasPixel = function(pixelWidth) { + return (pixelWidth % 2 === 0) ? 0 : 0.5; + }, + splineCurve = helpers.splineCurve = function(FirstPoint, MiddlePoint, AfterPoint, t) { + //Props to Rob Spencer at scaled innovation for his post on splining between points + //http://scaledinnovation.com/analytics/splines/aboutSplines.html + var d01 = Math.sqrt(Math.pow(MiddlePoint.x - FirstPoint.x, 2) + Math.pow(MiddlePoint.y - FirstPoint.y, 2)), + d12 = Math.sqrt(Math.pow(AfterPoint.x - MiddlePoint.x, 2) + Math.pow(AfterPoint.y - MiddlePoint.y, 2)), + fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta + fb = t * d12 / (d01 + d12); + return { + next: { + x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) + }, + previous: { + x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) + } + }; + }, + calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { + return Math.floor(Math.log(val) / Math.LN10); + }, + calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { + + //Set a minimum step of two - a point at the top of the graph, and a point at the base + var minSteps = 2, + maxSteps = Math.floor(drawingSize / (textSize * 1.5)), + skipFitting = (minSteps >= maxSteps); + + var maxValue = max(valuesArray), + minValue = min(valuesArray); + + // We need some degree of seperation here to calculate the scales if all the values are the same + // Adding/minusing 0.5 will give us a range of 1. + if (maxValue === minValue) { + maxValue += 0.5; + // So we don't end up with a graph with a negative start value if we've said always start from zero + if (minValue >= 0.5 && !startFromZero) { + minValue -= 0.5; + } else { + // Make up a whole number above the values + maxValue += 0.5; + } + } + + var valueRange = Math.abs(maxValue - minValue), + rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), + graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphRange = graphMax - graphMin, + stepValue = Math.pow(10, rangeOrderOfMagnitude), + numberOfSteps = Math.round(graphRange / stepValue); + + //If we have more space on the graph we'll use it to give more definition to the data + while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { + if (numberOfSteps > maxSteps) { + stepValue *= 2; + numberOfSteps = Math.round(graphRange / stepValue); + // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. + if (numberOfSteps % 1 !== 0) { + skipFitting = true; + } + } + //We can fit in double the amount of scale points on the scale + else { + //If user has declared ints only, and the step value isn't a decimal + if (integersOnly && rangeOrderOfMagnitude >= 0) { + //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float + if (stepValue / 2 % 1 === 0) { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + //If it would make it a float break out of the loop + else { + break; + } + } + //If the scale doesn't have to be an int, make the scale more granular anyway. + else { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + + } + } + + if (skipFitting) { + numberOfSteps = minSteps; + stepValue = graphRange / numberOfSteps; + } + return { + steps: numberOfSteps, + stepValue: stepValue, + min: graphMin, + max: graphMin + (numberOfSteps * stepValue) + }; + + }, + /* jshint ignore:start */ + // Blows up jshint errors based on the new Function constructor + //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 instanceof Function) { + return templateString(valuesObject); + } + + var cache = {}; + + function tmpl(str, data) { + // Figure out if we're getting a template, or if we need to + // load the template - and be sure to cache the result. + var fn = !/\W/.test(str) ? + cache[str] = cache[str] : + + // Generate a reusable function that will serve as a template + // generator (and which will be cached). + new Function("obj", + "var p=[],print=function(){p.push.apply(p,arguments);};" + + + // Introduce the data as local variables using with(){} + "with(obj){p.push('" + + + // Convert the template into pure JavaScript + str + .replace(/[\r\t\n]/g, " ") + .split("<%").join("\t") + .replace(/((^|%>)[^\t]*)'/g, "$1\r") + .replace(/\t=(.*?)%>/g, "',$1,'") + .split("\t").join("');") + .split("%>").join("p.push('") + .split("\r").join("\\'") + + "');}return p.join('');" + ); + + // Provide some basic currying to the user + return data ? fn(data) : fn; + } + return tmpl(templateString, valuesObject); + }, + /* jshint ignore:end */ + generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { + var labelsArray = new Array(numberOfSteps); + if (templateString) { + each(labelsArray, function(val, index) { + labelsArray[index] = template(templateString, { + value: (graphMin + (stepValue * (index + 1))) + }); + }); + } + return labelsArray; + }, + //--Animation methods + //Easing functions adapted from Robert Penner's easing equations + //http://www.robertpenner.com/easing/ + easingEffects = helpers.easingEffects = { + linear: function(t) { + return t; + }, + easeInQuad: function(t) { + return t * t; + }, + easeOutQuad: function(t) { + return -1 * t * (t - 2); + }, + easeInOutQuad: function(t) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t; + } + return -1 / 2 * ((--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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t; + } + return 1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t; + } + return -1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t * t; + } + return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); + }, + easeInExpo: function(t) { + return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); + }, + easeOutExpo: function(t) { + return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); + }, + easeInOutExpo: function(t) { + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if ((t /= 1 / 2) < 1) { + return 1 / 2 * Math.pow(2, 10 * (t - 1)); + } + return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); + }, + easeInCirc: function(t) { + if (t >= 1) { + return t; + } + return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); + }, + easeOutCirc: function(t) { + return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); + }, + easeInOutCirc: function(t) { + if ((t /= 1 / 2) < 1) { + return -1 / 2 * (Math.sqrt(1 - t * t) - 1); + } + return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); + }, + easeInElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + }, + easeOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; + }, + easeInOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1 / 2) == 2) { + return 1; + } + if (!p) { + p = 1 * (0.3 * 1.5); + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1) { + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; + }, + easeInBack: function(t) { + var s = 1.70158; + return 1 * (t /= 1) * t * ((s + 1) * t - s); + }, + easeOutBack: function(t) { + var s = 1.70158; + return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); + }, + easeInOutBack: function(t) { + var s = 1.70158; + if ((t /= 1 / 2) < 1) { + return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); + } + return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); + }, + easeInBounce: function(t) { + return 1 - easingEffects.easeOutBounce(1 - t); + }, + easeOutBounce: function(t) { + if ((t /= 1) < (1 / 2.75)) { + return 1 * (7.5625 * t * t); + } else if (t < (2 / 2.75)) { + return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); + } else if (t < (2.5 / 2.75)) { + return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); + } else { + return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); + } + }, + easeInOutBounce: function(t) { + if (t < 1 / 2) { + return easingEffects.easeInBounce(t * 2) * 0.5; + } + return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; + } + }, + //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ + requestAnimFrame = helpers.requestAnimFrame = (function() { + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function(callback) { + return window.setTimeout(callback, 1000 / 60); + }; + })(), + cancelAnimFrame = helpers.cancelAnimFrame = (function() { + return window.cancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.mozCancelAnimationFrame || + window.oCancelAnimationFrame || + window.msCancelAnimationFrame || + function(callback) { + return window.clearTimeout(callback, 1000 / 60); + }; + })(), + animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { + + var currentStep = 0, + easingFunction = easingEffects[easingString] || easingEffects.linear; + + var animationFrame = function() { + currentStep++; + var stepDecimal = currentStep / totalSteps; + var easeDecimal = easingFunction(stepDecimal); + + callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); + onProgress.call(chartInstance, easeDecimal, stepDecimal); + if (currentStep < totalSteps) { + chartInstance.animationFrame = requestAnimFrame(animationFrame); + } else { + onComplete.apply(chartInstance); + } + }; + requestAnimFrame(animationFrame); + }, + //-- DOM methods + getRelativePosition = helpers.getRelativePosition = function(evt) { + var mouseX, mouseY; + var e = evt.originalEvent || evt, + canvas = evt.currentTarget || evt.srcElement, + boundingRect = canvas.getBoundingClientRect(); + + if (e.touches) { + mouseX = e.touches[0].clientX - boundingRect.left; + mouseY = e.touches[0].clientY - boundingRect.top; + + } else { + mouseX = e.clientX - boundingRect.left; + mouseY = e.clientY - boundingRect.top; + } + + return { + x: mouseX, + y: mouseY + }; + + }, + addEvent = helpers.addEvent = function(node, eventType, method) { + if (node.addEventListener) { + node.addEventListener(eventType, method); + } else if (node.attachEvent) { + node.attachEvent("on" + eventType, method); + } else { + node["on" + eventType] = method; + } + }, + removeEvent = helpers.removeEvent = function(node, eventType, handler) { + if (node.removeEventListener) { + node.removeEventListener(eventType, handler, false); + } else if (node.detachEvent) { + node.detachEvent("on" + eventType, handler); + } else { + node["on" + eventType] = noop; + } + }, + bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) { + // Create the events object if it's not already present + if (!chartInstance.events) chartInstance.events = {}; + + each(arrayOfEvents, function(eventName) { + chartInstance.events[eventName] = function() { + handler.apply(chartInstance, arguments); + }; + addEvent(chartInstance.chart.canvas, eventName, chartInstance.events[eventName]); + }); + }, + unbindEvents = helpers.unbindEvents = function(chartInstance, arrayOfEvents) { + each(arrayOfEvents, function(handler, eventName) { + removeEvent(chartInstance.chart.canvas, eventName, handler); + }); + }, + getMaximumWidth = helpers.getMaximumWidth = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); + // TODO = check cross browser stuff with this. + return container.clientWidth - padding; + }, + getMaximumHeight = helpers.getMaximumHeight = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); + // TODO = check cross browser stuff with this. + return container.clientHeight - padding; + }, + getStyle = helpers.getStyle = function(el, property) { + return el.currentStyle ? + el.currentStyle[property] : + document.defaultView.getComputedStyle(el, null).getPropertyValue(property); + }, + getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support + retinaScale = helpers.retinaScale = function(chart) { + var ctx = chart.ctx, + width = chart.canvas.width, + height = chart.canvas.height; + + if (window.devicePixelRatio) { + ctx.canvas.style.width = width + "px"; + ctx.canvas.style.height = height + "px"; + ctx.canvas.height = height * window.devicePixelRatio; + ctx.canvas.width = width * window.devicePixelRatio; + ctx.scale(window.devicePixelRatio, window.devicePixelRatio); + } + }, + //-- Canvas methods + clear = helpers.clear = function(chart) { + chart.ctx.clearRect(0, 0, chart.width, chart.height); + }, + fontString = helpers.fontString = function(pixelSize, fontStyle, fontFamily) { + return fontStyle + " " + pixelSize + "px " + fontFamily; + }, + longestText = helpers.longestText = function(ctx, font, arrayOfStrings) { + ctx.font = font; + var longest = 0; + each(arrayOfStrings, function(string) { + var textWidth = ctx.measureText(string).width; + longest = (textWidth > longest) ? textWidth : longest; + }); + return longest; + }, + drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx, x, y, width, height, radius) { + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + }, + color = helpers.color = function(color) { + if (!window.Color) { + console.log('Color.js not found!'); + return color; + } + return window.Color(color); + }, + isArray = helpers.isArray = function(obj) { + if (!Array.isArray) { + return Object.prototype.toString.call(arg) === '[object Array]'; + } + return Array.isArray(obj); + }; + + //Store a reference to each instance - allowing us to globally resize chart instances on window resize. + //Destroy method on the chart will remove the instance of the chart from this reference. + Chart.instances = {}; + + Chart.Type = function(data, options, chart) { + this.options = options; + this.chart = chart; + this.id = uid(); + //Add the chart instance to the global namespace + Chart.instances[this.id] = this; + + // Initialize is always called when a chart type is created + // By default it is a no op, but it should be extended + if (options.responsive) { + this.resize(); + } + this.initialize.call(this, data); + }; + + //Core methods that'll be a part of every chart type + extend(Chart.Type.prototype, { + initialize: function() { + return this; + }, + clear: function() { + clear(this.chart); + return this; + }, + stop: function() { + // Stops any current animation loop occuring + Chart.animationService.cancelAnimation(this); + return this; + }, + resize: function(callback) { + this.stop(); + var canvas = this.chart.canvas, + newWidth = getMaximumWidth(this.chart.canvas), + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + + canvas.width = this.chart.width = newWidth; + canvas.height = this.chart.height = newHeight; + + retinaScale(this.chart); + + if (typeof callback === "function") { + callback.apply(this, Array.prototype.slice.call(arguments, 1)); + } + return this; + }, + redraw: noop, + render: function(duration) { + + if (this.options.animation) { + var animation = new Chart.Animation(); + animation.numSteps = (duration || this.options.animationDuration) / 16.66; //60 fps + animation.easing = this.options.animationEasing; + + // render function + animation.render = function(chartInstance, animationObject) { + var easingFunction = helpers.easingEffects[animationObject.easing]; + var stepDecimal = animationObject.currentStep / animationObject.numSteps; + var easeDecimal = easingFunction(stepDecimal); + + chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); + }; + + // user events + animation.onAnimationProgress = this.options.onAnimationProgress; + animation.onAnimationComplete = this.options.onAnimationComplete; + + Chart.animationService.addAnimation(this, animation, duration); + } else { + this.draw(); + this.options.onAnimationComplete.call(this); + } + return this; + }, + eachElement: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }, + eachValue: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.data, callback, this, datasetIndex); + }, this); + }, + eachDataset: function(callback) { + helpers.each(this.data.datasets, callback, this); + }, + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + generateLegend: function() { + return template(this.options.legendTemplate, this); + }, + 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]; + }, + toBase64Image: function() { + return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); + } + }); + + Chart.Type.extend = function(extensions) { + + var parent = this; + + var ChartType = function() { + return parent.apply(this, arguments); + }; + + //Copy the prototype object of the this class + ChartType.prototype = clone(parent.prototype); + //Now overwrite some of the properties in the base class with the new extensions + extend(ChartType.prototype, extensions); + + ChartType.extend = Chart.Type.extend; + + if (extensions.name || parent.prototype.name) { + + var chartName = extensions.name || parent.prototype.name; + //Assign any potential default values of the new chart type + + //If none are defined, we'll use a clone of the chart type this is being extended from. + //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart + //doesn't define some defaults of their own. + + var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; + + Chart.defaults[chartName] = extend(baseDefaults, extensions.defaults); + + Chart.types[chartName] = ChartType; + + //Register this new chart type in the Chart prototype + Chart.prototype[chartName] = function(data, options) { + var config = merge(Chart.defaults.global, Chart.defaults[chartName], options || {}); + return new ChartType(data, config, this); + }; + } else { + warn("Name not provided for this chart, so it hasn't been registered"); + } + return parent; + }; + + Chart.Element = function(configuration) { + extend(this, { + _vm: {}, + }); + extend(this, configuration); + this.initialize.apply(this, arguments); + }; + extend(Chart.Element.prototype, { + initialize: function() {}, + save: function() { + this._vm = clone(this); + delete this._vm._vm; + delete this._vm._start; + return this; + }, + pivot: function() { + if (this._start) { + this._start = clone(this); + helpers.extend(this._start, this._vm); + } + return this; + }, + transition: function(ease) { + if (!this._start) { + if (!this._vm) { + this.save(); + } + this._start = clone(this._vm); + } + + each(this, function(value, key) { + + if (key[0] === '_' || !this.hasOwnProperty(key)) { + // Only non-underscored properties + } + + // Init if doesn't exist + else if (!this._vm[key]) { + this._vm[key] = value || null; + } + + // No unnecessary computations + else if (this[key] === this._vm[key]) { + // It's the same! Woohoo! + } + + // Color transitions if possible + else if (typeof value === 'string') { + try { + var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); + this._vm[key] = color.rgbString(); + } catch (err) { + this._vm[key] = value; + } + } + // Number transitions + else if (typeof value === 'number') { + + this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; + } else { + // Everything else + this._vm[key] = value; + } + + }, this); + + if (ease === 1) { + delete this._start; + } + return this; + }, + tooltipPosition: function() { + return { + x: this.x, + y: this.y + }; + }, + hasValue: function() { + return isNumber(this.value); + } + }); + + Chart.Element.extend = inherits; + + + Chart.Point = Chart.Element.extend({ + inRange: function(mouseX, mouseY) { + var vm = this._vm; + var hoverRange = vm.hoverRadius + vm.radius; + return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + }, + inGroupRange: function(mouseX) { + var vm = this._vm; + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + this.hoverRadius, 2)); + }, + tooltipPosition: function() { + var vm = this._vm; + return { + x: vm.x, + y: vm.y + }; + }, + draw: function() { + + var vm = this._vm; + var ctx = this._chart.ctx; + + if (vm.radius > 0 || vm.borderWidth > 0) { + + ctx.beginPath(); + + ctx.arc(vm.x, vm.y, vm.radius, 0, Math.PI * 2); + ctx.closePath(); + + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; + + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + + ctx.fill(); + ctx.stroke(); + } + } + }); + + + Chart.Line = Chart.Element.extend({ + draw: function() { + + var vm = this._vm; + var ctx = this._chart.ctx; + + //Draw the line between all the points + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; + ctx.beginPath(); + + helpers.each(vm._points, function(point, index) { + if (index === 0) { + ctx.moveTo(point._vm.x, point._vm.y); + } else { + if (vm._tension > 0 || 1) { + var previous = this.previousPoint(point, vm._points, index); + + ctx.bezierCurveTo( + previous._vm.controlPointNextX, + previous._vm.controlPointNextY, + point._vm.controlPointPreviousX, + point._vm.controlPointPreviousY, + point._vm.x, + point._vm.y + ); + } else { + ctx.lineTo(point._vm.x, point._vm.y); + } + } + }, this); + + ctx.stroke(); + + if (vm._points.length > 0) { + //Round off the line by going to the base of the chart, back to the start, then fill. + ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleBottom); + ctx.lineTo(vm._points[0].x, vm.scaleBottom); + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + ctx.closePath(); + ctx.fill(); + } + }, + previousPoint: function(point, collection, index) { + return helpers.findPreviousWhere(collection, function() { + return true; + }, index) || point; + }, + }); + + Chart.Arc = Chart.Element.extend({ + inRange: function(chartX, chartY) { + + var pointRelativePosition = helpers.getAngleFromPoint(this, { + x: chartX, + y: chartY + }); + + //Check if within the range of the open/close angle + var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle), + withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius); + + return (betweenAngles && withinRadius); + //Ensure within the outside of the arc centre, but inside arc outer + }, + tooltipPosition: function() { + var centreAngle = this.startAngle + ((this.endAngle - this.startAngle) / 2), + rangeFromCentre = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius; + return { + x: this.x + (Math.cos(centreAngle) * rangeFromCentre), + y: this.y + (Math.sin(centreAngle) * rangeFromCentre) + }; + }, + draw: function(animationPercent) { + + var easingDecimal = animationPercent || 1; + + var ctx = this.ctx; + + ctx.beginPath(); + + ctx.arc(this.x, this.y, this.outerRadius, this.startAngle, this.endAngle); + + ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); + + ctx.closePath(); + ctx.strokeStyle = this.borderColor; + ctx.lineWidth = this.borderWidth; + + ctx.fillStyle = this.backgroundColor; + + ctx.fill(); + ctx.lineJoin = 'bevel'; + + if (this.showBorder) { + ctx.stroke(); + } + } + }); + + Chart.Rectangle = Chart.Element.extend({ + draw: function() { + + var vm = this._vm; + + var ctx = this.ctx, + halfWidth = vm.width / 2, + leftX = vm.x - halfWidth, + rightX = vm.x + halfWidth, + top = vm.base - (vm.base - vm.y), + halfStroke = vm.borderWidth / 2; + + // Canvas doesn't allow us to stroke inside the width so we can + // adjust the sizes to fit if we're setting a stroke on the line + if (vm.borderWidth) { + leftX += halfStroke; + rightX -= halfStroke; + top += halfStroke; + } + + ctx.beginPath(); + + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; + + // It'd be nice to keep this class totally generic to any rectangle + // and simply specify which border to miss out. + ctx.moveTo(leftX, vm.base); + ctx.lineTo(leftX, top); + ctx.lineTo(rightX, top); + ctx.lineTo(rightX, vm.base); + ctx.fill(); + if (vm.borderWidth) { + ctx.stroke(); + } + }, + height: function() { + var vm = this._vm; + return vm.base - vm.y; + }, + inRange: function(mouseX, mouseY) { + var vm = this._vm; + if (vm.y < vm.base) { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); + } else { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); + } + }, + inGroupRange: function(mouseX) { + var vm = this._vm; + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + }, + tooltipPosition: function() { + var vm = this._vm; + if (vm.y < vm.base) { + return { + x: vm.x, + y: vm.y + }; + } else { + return { + x: vm.x, + y: vm.base + }; + } + }, + }); + + Chart.Animation = Chart.Element.extend({ + currentStep: null, // the current animation step + numSteps: 60, // default number of steps + easing: "", // the easing to use for this animation + render: null, // render function used by the animation service + + onAnimationProgress: null, // user specified callback to fire on each step of the animation + onAnimationComplete: null, // user specified callback to fire when the animation finishes + }); + + Chart.Tooltip = Chart.Element.extend({ + initialize: function() { + var options = this._options; + extend(this, { + opacity: 0, + xPadding: options.tooltipXPadding, + yPadding: options.tooltipYPadding, + xOffset: options.tooltipXOffset, + backgroundColor: options.tooltipBackgroundColor, + textColor: options.tooltipFontColor, + _fontFamily: options.tooltipFontFamily, + _fontStyle: options.tooltipFontStyle, + fontSize: options.tooltipFontSize, + titleTextColor: options.tooltipTitleFontColor, + _titleFontFamily: options.tooltipTitleFontFamily, + _titleFontStyle: options.tooltipTitleFontStyle, + titleFontSize: options.tooltipTitleFontSize, + caretHeight: options.tooltipCaretSize, + cornerRadius: options.tooltipCornerRadius, + legendColorBackground: options.multiTooltipKeyBackground, + labels: [], + colors: [], + }); + }, + update: function() { + + var ctx = this._chart.ctx; + + switch (this._options.hoverMode) { + case 'single': + helpers.extend(this, { + text: template(this._options.tooltipTemplate, this._active[0]), + }); + var tooltipPosition = this._active[0].tooltipPosition(); + helpers.extend(this, { + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + }); + break; + + case 'label': + + // Tooltip Content + + var dataArray, + dataIndex; + + var labels = [], + colors = []; + + for (var i = this._data.datasets.length - 1; i >= 0; i--) { + dataArray = this._data.datasets[i].metaData; + dataIndex = indexOf(dataArray, this._active[0]); + if (dataIndex !== -1) { + break; + } + } + + var medianPosition = (function(index) { + // Get all the points at that particular index + var elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this._data.datasets, function(dataset) { + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { + elements.push(dataCollection[dataIndex]); + } + }); + + helpers.each(elements, function(element) { + xPositions.push(element._vm.x); + yPositions.push(element._vm.y); + + //Include any colour information about the element + labels.push(helpers.template(this._options.multiTooltipTemplate, element)); + colors.push({ + fill: element._vm.backgroundColor, + stroke: element._vm.borderColor + }); + + }, this); + + yMin = min(yPositions); + yMax = max(yPositions); + + xMin = min(xPositions); + xMax = max(xPositions); + + return { + x: (xMin > this._chart.width / 2) ? xMin : xMax, + y: (yMin + yMax) / 2, + }; + }).call(this, dataIndex); + + // Apply for now + helpers.extend(this, { + x: medianPosition.x, + y: medianPosition.y, + labels: labels, + title: this._active.length ? this._active[0].label : '', + legendColors: colors, + legendBackgroundColor: this._options.multiTooltipKeyBackground, + }); + + + // Calculate Appearance Tweaks + + this.height = (labels.length * this.fontSize) + ((labels.length - 1) * (this.fontSize / 2)) + (this.yPadding * 2) + this.titleFontSize * 1.5; + + var titleWidth = ctx.measureText(this.title).width, + //Label has a legend square as well so account for this. + labelWidth = longestText(ctx, this.font, labels) + this.fontSize + 3, + longestTextWidth = max([labelWidth, titleWidth]); + + this.width = longestTextWidth + (this.xPadding * 2); + + + var halfHeight = this.height / 2; + + //Check to ensure the height will fit on the canvas + if (this.y - halfHeight < 0) { + this.y = halfHeight; + } else if (this.y + halfHeight > this._chart.height) { + this.y = this._chart.height - halfHeight; + } + + //Decide whether to align left or right based on position on canvas + if (this.x > this._chart.width / 2) { + this.x -= this.xOffset + this.width; + } else { + this.x += this.xOffset; + } + break; + } + + return this; + }, + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._vm; + + switch (this._options.hoverMode) { + case 'single': + + ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + + vm.xAlign = "center"; + vm.yAlign = "above"; + + //Distance between the actual element.y position and the start of the tooltip caret + var caretPadding = vm.caretPadding = 2; + + var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, + tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; + + if (vm.x + tooltipWidth / 2 > this._chart.width) { + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth / 2 < 0) { + vm.xAlign = "right"; + } + + if (vm.y - tooltipHeight < 0) { + vm.yAlign = "below"; + } + + var tooltipX = vm.x - tooltipWidth / 2, + tooltipY = vm.y - tooltipHeight; + + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + + // Custom Tooltips + if (this._custom) { + this._custom(this._vm); + } else { + switch (vm.yAlign) { + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } + + switch (vm.xAlign) { + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } + + drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); + + ctx.fill(); + + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); + + } + break; + case 'label': + + drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + ctx.fill(); + ctx.closePath(); + + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); + ctx.font = fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); + ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); + + ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + helpers.each(vm.labels, function(label, index) { + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); + + //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) + //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + //Instead we'll make a white filled block to put the legendColour palette over. + + ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + + }, this); + break; + } + }, + getLineHeight: function(index) { + var baseLineHeight = this._vm.y - (this._vm.height / 2) + this._vm.yPadding, + afterTitleIndex = index - 1; + + //If the index is zero, we're getting the title + if (index === 0) { + return baseLineHeight + this._vm.titleFontSize / 2; + } else { + return baseLineHeight + ((this._vm.fontSize * 1.5 * afterTitleIndex) + this._vm.fontSize / 2) + this._vm.titleFontSize * 1.5; + } + + }, + }); + + Chart.Scale = Chart.Element.extend({ + initialize: function() { + this.fit(); + }, + buildYLabels: function() { + this.yLabels = []; + + var stepDecimalPlaces = getDecimalPlaces(this.stepValue); + + 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) + 10 : 0; + }, + addXLabel: function(label) { + this.xLabels.push(label); + this.valuesCount++; + this.fit(); + }, + removeXLabel: function() { + this.xLabels.shift(); + this.valuesCount--; + this.fit(); + }, + // Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use + fit: function() { + // First we need the width of the yLabels, assuming the xLabels aren't rotated + + // To do that we need the base line at the top and base of the chart, assuming there is no x label rotation + this.startPoint = (this.display) ? this.fontSize : 0; + this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels + + // Apply padding settings to the start and end point. + this.startPoint += this.padding; + this.endPoint -= this.padding; + + // Cache the starting endpoint, excluding the space for x labels + var cachedEndPoint = this.endPoint; + + // Cache the starting height, so can determine if we need to recalculate the scale yAxis + var cachedHeight = this.endPoint - this.startPoint, + cachedYLabelWidth; + + // Build the current yLabels so we have an idea of what size they'll be to start + /* * This sets what is returned from calculateScaleRange as static properties of this class: * this.steps; @@ -1735,609 +1731,609 @@ this.max; * */ - this.calculateYRange(cachedHeight); - - // With these properties set we can now build the array of yLabels - // and also the width of the largest yLabel - this.buildYLabels(); - - this.calculateXLabelRotation(); - - while((cachedHeight > this.endPoint - this.startPoint)){ - cachedHeight = this.endPoint - this.startPoint; - cachedYLabelWidth = this.yLabelWidth; - - this.calculateYRange(cachedHeight); - this.buildYLabels(); - - // Only go through the xLabel loop again if the yLabel width has changed - if (cachedYLabelWidth < this.yLabelWidth){ - this.endPoint = cachedEndPoint; - this.calculateXLabelRotation(); - } - } - - }, - calculateXLabelRotation : function(){ - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - - this.ctx.font = this.font; - - var firstWidth = this.ctx.measureText(this.xLabels[0]).width, - lastWidth = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width, - firstRotated, - lastRotated; - - - this.xScalePaddingRight = lastWidth/2 + 3; - this.xScalePaddingLeft = (firstWidth/2 > this.yLabelWidth) ? firstWidth/2 : this.yLabelWidth; - - this.xLabelRotation = 0; - if (this.display){ - var originalLabelWidth = longestText(this.ctx,this.font,this.xLabels), - cosRotation, - firstRotatedWidth; - this.xLabelWidth = originalLabelWidth; - //Allow 3 pixels x2 padding either side for label readability - var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; - - //Max label rotate should be 90 - also act as a loop counter - while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)){ - cosRotation = Math.cos(toRadians(this.xLabelRotation)); - - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; - - // We're right aligning the text now. - if (firstRotated + this.fontSize / 2 > this.yLabelWidth){ - this.xScalePaddingLeft = firstRotated + this.fontSize / 2; - } - this.xScalePaddingRight = this.fontSize/2; - - - this.xLabelRotation++; - this.xLabelWidth = cosRotation * originalLabelWidth; - - } - if (this.xLabelRotation > 0){ - this.endPoint -= Math.sin(toRadians(this.xLabelRotation))*originalLabelWidth + 3; - } - } - else{ - this.xLabelWidth = 0; - this.xScalePaddingRight = this.padding; - this.xScalePaddingLeft = this.padding; - } - - }, - // Needs to be overidden in each Chart type - // Otherwise we need to pass all the data into the scale class - calculateYRange: noop, - drawingArea: function(){ - return this.startPoint - this.endPoint; - }, - calculateY : function(value){ - var scalingFactor = this.drawingArea() / (this.min - this.max); - return this.endPoint - (scalingFactor * (value - this.min)); - }, - calculateX : function(index){ - var isRotated = (this.xLabelRotation > 0), - // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding, - innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight), - valueWidth = innerWidth/Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1), - valueOffset = (valueWidth * index) + this.xScalePaddingLeft; - - if (this.offsetGridLines){ - valueOffset += (valueWidth/2); - } - - return Math.round(valueOffset); - }, - update : function(newProps){ - helpers.extend(this, newProps); - this.fit(); - }, - draw : function(){ - var ctx = this.ctx, - yLabelGap = (this.endPoint - this.startPoint) / this.steps, - xStart = Math.round(this.xScalePaddingLeft); - if (this.display){ - ctx.fillStyle = this.textColor; - ctx.font = this.font; - each(this.yLabels,function(labelString,index){ - var yLabelCenter = this.endPoint - (yLabelGap * index), - linePositionY = Math.round(yLabelCenter), - drawHorizontalLine = this.showHorizontalLines; - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - if (this.showLabels){ - ctx.fillText(labelString,xStart - 10,yLabelCenter); - } - - // This is X axis, so draw it - if (index === 0 && !drawHorizontalLine){ - drawHorizontalLine = true; - } - - if (drawHorizontalLine){ - ctx.beginPath(); - } - - if (index > 0){ - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } - - linePositionY += helpers.aliasPixel(ctx.lineWidth); - - if(drawHorizontalLine){ - ctx.moveTo(xStart, linePositionY); - ctx.lineTo(this.width, linePositionY); - ctx.stroke(); - ctx.closePath(); - } - - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - ctx.beginPath(); - ctx.moveTo(xStart - 5, linePositionY); - ctx.lineTo(xStart, linePositionY); - ctx.stroke(); - ctx.closePath(); - - },this); - - each(this.xLabels,function(label,index){ - var xPos = this.calculateX(index) + aliasPixel(this.lineWidth), - // Check to see if line/bar here and decide where to place the line - linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth), - isRotated = (this.xLabelRotation > 0), - drawVerticalLine = this.showVerticalLines; - - // This is Y axis, so draw it - if (index === 0 && !drawVerticalLine){ - drawVerticalLine = true; - } - - if (drawVerticalLine){ - ctx.beginPath(); - } - - if (index > 0){ - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } - - if (drawVerticalLine){ - ctx.moveTo(linePos,this.endPoint); - ctx.lineTo(linePos,this.startPoint - 3); - ctx.stroke(); - ctx.closePath(); - } - - - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - - - // Small lines at the bottom of the base grid line - ctx.beginPath(); - ctx.moveTo(linePos,this.endPoint); - ctx.lineTo(linePos,this.endPoint + 5); - ctx.stroke(); - ctx.closePath(); - - ctx.save(); - ctx.translate(xPos,(isRotated) ? this.endPoint + 12 : this.endPoint + 8); - ctx.rotate(toRadians(this.xLabelRotation)*-1); - ctx.font = this.font; - ctx.textAlign = (isRotated) ? "right" : "center"; - ctx.textBaseline = (isRotated) ? "middle" : "top"; - ctx.fillText(label, 0, 0); - ctx.restore(); - },this); - - } - } - - }); - - Chart.RadialScale = Chart.Element.extend({ - initialize: function(){ - this.size = min([this.height, this.width]); - this.drawingArea = (this.display) ? (this.size/2) - (this.fontSize/2 + this.backdropPaddingY) : (this.size/2); - }, - calculateCenterOffset: function(value){ - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); - - return (value - this.min) * scalingFactor; - }, - update : function(){ - if (!this.lineArc){ - this.setScaleSize(); - } else { - this.drawingArea = (this.display) ? (this.size/2) - (this.fontSize/2 + this.backdropPaddingY) : (this.size/2); - } - this.buildYLabels(); - }, - buildYLabels: function(){ - this.yLabels = []; - - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); - - for (var i=0; i<=this.steps; i++){ - this.yLabels.push(template(this.templateString,{value:(this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces)})); - } - }, - getCircumference : function(){ - return ((Math.PI*2) / this.valuesCount); - }, - setScaleSize: function(){ - /* - * Right, this is really confusing and there is a lot of maths going on here - * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 - * - * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif - * - * Solution: - * - * We assume the radius of the polygon is half the size of the canvas at first - * at each index we check if the text overlaps. - * - * Where it does, we store that angle and that index. - * - * After finding the largest index and angle we calculate how much we need to remove - * from the shape radius to move the point inwards by that x. - * - * We average the left and right distances to get the maximum shape radius that can fit in the box - * along with labels. - * - * Once we have that, we can find the centre point for the chart, by taking the x text protrusion - * on each side, removing that from the size, halving it and adding the left x protrusion width. - * - * This will mean we have a shape fitted to the canvas, as large as it can be with the labels - * and position it in the most space efficient manner - * - * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - */ - - - // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points - var largestPossibleRadius = min([(this.height/2 - this.pointLabelFontSize - 5), this.width/2]), - pointPosition, - i, - textWidth, - halfTextWidth, - furthestRight = this.width, - furthestRightIndex, - furthestRightAngle, - furthestLeft = 0, - furthestLeftIndex, - furthestLeftAngle, - xProtrusionLeft, - xProtrusionRight, - radiusReductionRight, - radiusReductionLeft, - maxWidthRadius; - this.ctx.font = fontString(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily); - for (i=0;i furthestRight) { - furthestRight = pointPosition.x + halfTextWidth; - furthestRightIndex = i; - } - if (pointPosition.x - halfTextWidth < furthestLeft) { - furthestLeft = pointPosition.x - halfTextWidth; - furthestLeftIndex = i; - } - } - else if (i < this.valuesCount/2) { - // Less than half the values means we'll left align the text - if (pointPosition.x + textWidth > furthestRight) { - furthestRight = pointPosition.x + textWidth; - furthestRightIndex = i; - } - } - else if (i > this.valuesCount/2){ - // More than half the values means we'll right align the text - if (pointPosition.x - textWidth < furthestLeft) { - furthestLeft = pointPosition.x - textWidth; - furthestLeftIndex = i; - } - } - } - - xProtrusionLeft = furthestLeft; - - xProtrusionRight = Math.ceil(furthestRight - this.width); - - furthestRightAngle = this.getIndexAngle(furthestRightIndex); - - furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); - - radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI/2); - - radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI/2); - - // Ensure we actually need to reduce the size of the chart - radiusReductionRight = (isNumber(radiusReductionRight)) ? radiusReductionRight : 0; - radiusReductionLeft = (isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; - - this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight)/2; - - //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) - this.setCenterPoint(radiusReductionLeft, radiusReductionRight); - - }, - setCenterPoint: function(leftMovement, rightMovement){ - - var maxRight = this.width - rightMovement - this.drawingArea, - maxLeft = leftMovement + this.drawingArea; - - this.xCenter = (maxLeft + maxRight)/2; - // Always vertically in the centre as the text height doesn't change - this.yCenter = (this.height/2); - }, - - getIndexAngle : function(index){ - var angleMultiplier = (Math.PI * 2) / this.valuesCount; - // Start from the top instead of right, so remove a quarter of the circle - - return index * angleMultiplier - (Math.PI/2); - }, - getPointPosition : function(index, distanceFromCenter){ - var thisAngle = this.getIndexAngle(index); - return { - x : (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, - y : (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter - }; - }, - draw: function(){ - if (this.display){ - var ctx = this.ctx; - each(this.yLabels, function(label, index){ - // Don't draw a centre value - if (index > 0){ - var yCenterOffset = index * (this.drawingArea/this.steps), - yHeight = this.yCenter - yCenterOffset, - pointPosition; - - // Draw circular lines around the scale - if (this.lineWidth > 0){ - ctx.strokeStyle = this.lineColor; - ctx.lineWidth = this.lineWidth; - - if(this.lineArc){ - ctx.beginPath(); - ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI*2); - ctx.closePath(); - ctx.stroke(); - } else{ - ctx.beginPath(); - for (var i=0;i= 0; i--) { - if (this.angleLineWidth > 0){ - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); - ctx.beginPath(); - ctx.moveTo(this.xCenter, this.yCenter); - ctx.lineTo(outerPosition.x, outerPosition.y); - ctx.stroke(); - ctx.closePath(); - } - // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); - ctx.font = fontString(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily); - ctx.fillStyle = this.pointLabelFontColor; - - var labelsCount = this.labels.length, - halfLabelsCount = this.labels.length/2, - quarterLabelsCount = halfLabelsCount/2, - upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), - exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); - if (i === 0){ - ctx.textAlign = 'center'; - } else if(i === halfLabelsCount){ - ctx.textAlign = 'center'; - } else if (i < halfLabelsCount){ - ctx.textAlign = 'left'; - } else { - ctx.textAlign = 'right'; - } - - // Set the correct text baseline based on outer positioning - if (exactQuarter){ - ctx.textBaseline = 'middle'; - } else if (upperHalf){ - ctx.textBaseline = 'bottom'; - } else { - ctx.textBaseline = 'top'; - } - - ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); - } - } - } - } - }); - - Chart.animationService = { - frameDuration: 17, - animations: [], - dropFrames: 0, - addAnimation: function(chartInstance, animationObject, duration) { - - if(!duration){ - chartInstance.animating = true; - } - - for (var index = 0; index < this.animations.length; ++ index){ - if (this.animations[index].chartInstance === chartInstance){ - // replacing an in progress animation - this.animations[index].animationObject = animationObject; - return; - } - } - - this.animations.push({ - chartInstance: chartInstance, - animationObject: animationObject - }); - - // If there are no animations queued, manually kickstart a digest, for lack of a better word - if (this.animations.length == 1) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - }, - // Cancel the animation for a given chart instance - cancelAnimation: function(chartInstance) { - var index = helpers.findNextWhere(this.animations, function(animationWrapper) { - return animationWrapper.chartInstance === chartInstance; - }); - - if (index){ - this.animations.splice(index, 1); - chartInstance.animating = false; - } - }, - // calls startDigest with the proper context - digestWrapper: function() { - Chart.animationService.startDigest.call(Chart.animationService); - }, - startDigest: function() { - - var startTime = Date.now(); - var framesToDrop = 0; - - if(this.dropFrames > 1){ - framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; - } - - for (var i = 0; i < this.animations.length; i++) { - - if (this.animations[i].animationObject.currentStep === null){ - this.animations[i].animationObject.currentStep = 0; - } - - this.animations[i].animationObject.currentStep += 1 + framesToDrop; - if(this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps){ - this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; - } - - this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); - - if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps){ - // executed the last frame. Remove the animation. - this.animations[i].chartInstance.animating = false; - this.animations.splice(i, 1); - // Keep the index in place to offset the splice - i--; - } - } - - var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; - - if(frameDelay > 1){ - this.dropFrames += frameDelay; - } - - // Do we have more stuff to animate? - if (this.animations.length > 0){ - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - } - }; - - // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function(){ - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function(){ - clearTimeout(timeout); - timeout = setTimeout(function(){ - each(Chart.instances,function(instance){ - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive){ - instance.resize(instance.render, true); - } - }); - }, 50); - }; - })()); - - - if (amd) { - define(function(){ - return Chart; - }); - } else if (typeof module === 'object' && module.exports) { - module.exports = Chart; - } - - root.Chart = Chart; - - Chart.noConflict = function(){ - root.Chart = previous; - return Chart; - }; + this.calculateYRange(cachedHeight); + + // With these properties set we can now build the array of yLabels + // and also the width of the largest yLabel + this.buildYLabels(); + + this.calculateXLabelRotation(); + + while ((cachedHeight > this.endPoint - this.startPoint)) { + cachedHeight = this.endPoint - this.startPoint; + cachedYLabelWidth = this.yLabelWidth; + + this.calculateYRange(cachedHeight); + this.buildYLabels(); + + // Only go through the xLabel loop again if the yLabel width has changed + if (cachedYLabelWidth < this.yLabelWidth) { + this.endPoint = cachedEndPoint; + this.calculateXLabelRotation(); + } + } + + }, + calculateXLabelRotation: function() { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + + this.ctx.font = this.font; + + var firstWidth = this.ctx.measureText(this.xLabels[0]).width, + lastWidth = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width, + firstRotated, + lastRotated; + + + this.xScalePaddingRight = lastWidth / 2 + 3; + this.xScalePaddingLeft = (firstWidth / 2 > this.yLabelWidth) ? firstWidth / 2 : this.yLabelWidth; + + this.xLabelRotation = 0; + if (this.display) { + var originalLabelWidth = longestText(this.ctx, this.font, this.xLabels), + cosRotation, + firstRotatedWidth; + this.xLabelWidth = originalLabelWidth; + //Allow 3 pixels x2 padding either side for label readability + var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; + + //Max label rotate should be 90 - also act as a loop counter + while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)) { + cosRotation = Math.cos(toRadians(this.xLabelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.fontSize / 2 > this.yLabelWidth) { + this.xScalePaddingLeft = firstRotated + this.fontSize / 2; + } + this.xScalePaddingRight = this.fontSize / 2; + + + this.xLabelRotation++; + this.xLabelWidth = cosRotation * originalLabelWidth; + + } + if (this.xLabelRotation > 0) { + this.endPoint -= Math.sin(toRadians(this.xLabelRotation)) * originalLabelWidth + 3; + } + } else { + this.xLabelWidth = 0; + this.xScalePaddingRight = this.padding; + this.xScalePaddingLeft = this.padding; + } + + }, + // Needs to be overidden in each Chart type + // Otherwise we need to pass all the data into the scale class + calculateYRange: noop, + drawingArea: function() { + return this.startPoint - this.endPoint; + }, + calculateY: function(value) { + var scalingFactor = this.drawingArea() / (this.min - this.max); + return this.endPoint - (scalingFactor * (value - this.min)); + }, + calculateX: function(index) { + var isRotated = (this.xLabelRotation > 0), + // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding, + innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight), + valueWidth = innerWidth / Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1), + valueOffset = (valueWidth * index) + this.xScalePaddingLeft; + + if (this.offsetGridLines) { + valueOffset += (valueWidth / 2); + } + + return Math.round(valueOffset); + }, + update: function(newProps) { + helpers.extend(this, newProps); + this.fit(); + }, + draw: function() { + var ctx = this.ctx, + yLabelGap = (this.endPoint - this.startPoint) / this.steps, + xStart = Math.round(this.xScalePaddingLeft); + if (this.display) { + ctx.fillStyle = this.textColor; + ctx.font = this.font; + each(this.yLabels, function(labelString, index) { + var yLabelCenter = this.endPoint - (yLabelGap * index), + linePositionY = Math.round(yLabelCenter), + drawHorizontalLine = this.showHorizontalLines; + + ctx.textAlign = "right"; + ctx.textBaseline = "middle"; + if (this.showLabels) { + ctx.fillText(labelString, xStart - 10, yLabelCenter); + } + + // This is X axis, so draw it + if (index === 0 && !drawHorizontalLine) { + drawHorizontalLine = true; + } + + if (drawHorizontalLine) { + ctx.beginPath(); + } + + if (index > 0) { + // This is a grid line in the centre, so drop that + ctx.lineWidth = this.gridLineWidth; + ctx.strokeStyle = this.gridLineColor; + } else { + // This is the first line on the scale + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + } + + linePositionY += helpers.aliasPixel(ctx.lineWidth); + + if (drawHorizontalLine) { + ctx.moveTo(xStart, linePositionY); + ctx.lineTo(this.width, linePositionY); + ctx.stroke(); + ctx.closePath(); + } + + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + ctx.beginPath(); + ctx.moveTo(xStart - 5, linePositionY); + ctx.lineTo(xStart, linePositionY); + ctx.stroke(); + ctx.closePath(); + + }, this); + + each(this.xLabels, function(label, index) { + var xPos = this.calculateX(index) + aliasPixel(this.lineWidth), + // Check to see if line/bar here and decide where to place the line + linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth), + isRotated = (this.xLabelRotation > 0), + drawVerticalLine = this.showVerticalLines; + + // This is Y axis, so draw it + if (index === 0 && !drawVerticalLine) { + drawVerticalLine = true; + } + + if (drawVerticalLine) { + ctx.beginPath(); + } + + if (index > 0) { + // This is a grid line in the centre, so drop that + ctx.lineWidth = this.gridLineWidth; + ctx.strokeStyle = this.gridLineColor; + } else { + // This is the first line on the scale + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + } + + if (drawVerticalLine) { + ctx.moveTo(linePos, this.endPoint); + ctx.lineTo(linePos, this.startPoint - 3); + ctx.stroke(); + ctx.closePath(); + } + + + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + + + // Small lines at the bottom of the base grid line + ctx.beginPath(); + ctx.moveTo(linePos, this.endPoint); + ctx.lineTo(linePos, this.endPoint + 5); + ctx.stroke(); + ctx.closePath(); + + ctx.save(); + ctx.translate(xPos, (isRotated) ? this.endPoint + 12 : this.endPoint + 8); + ctx.rotate(toRadians(this.xLabelRotation) * -1); + ctx.font = this.font; + ctx.textAlign = (isRotated) ? "right" : "center"; + ctx.textBaseline = (isRotated) ? "middle" : "top"; + ctx.fillText(label, 0, 0); + ctx.restore(); + }, this); + + } + } + + }); + + Chart.RadialScale = Chart.Element.extend({ + initialize: function() { + this.size = min([this.height, this.width]); + this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + }, + calculateCenterOffset: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + + return (value - this.min) * scalingFactor; + }, + update: function() { + if (!this.lineArc) { + this.setScaleSize(); + } else { + this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + } + this.buildYLabels(); + }, + buildYLabels: function() { + this.yLabels = []; + + var stepDecimalPlaces = getDecimalPlaces(this.stepValue); + + for (var i = 0; i <= this.steps; i++) { + this.yLabels.push(template(this.templateString, { + value: (this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces) + })); + } + }, + getCircumference: function() { + return ((Math.PI * 2) / this.valuesCount); + }, + setScaleSize: function() { + /* + * Right, this is really confusing and there is a lot of maths going on here + * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 + * + * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif + * + * Solution: + * + * We assume the radius of the polygon is half the size of the canvas at first + * at each index we check if the text overlaps. + * + * Where it does, we store that angle and that index. + * + * After finding the largest index and angle we calculate how much we need to remove + * from the shape radius to move the point inwards by that x. + * + * We average the left and right distances to get the maximum shape radius that can fit in the box + * along with labels. + * + * Once we have that, we can find the centre point for the chart, by taking the x text protrusion + * on each side, removing that from the size, halving it and adding the left x protrusion width. + * + * This will mean we have a shape fitted to the canvas, as large as it can be with the labels + * and position it in the most space efficient manner + * + * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif + */ + + + // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. + // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points + var largestPossibleRadius = min([(this.height / 2 - this.pointLabelFontSize - 5), this.width / 2]), + pointPosition, + i, + textWidth, + halfTextWidth, + furthestRight = this.width, + furthestRightIndex, + furthestRightAngle, + furthestLeft = 0, + furthestLeftIndex, + furthestLeftAngle, + xProtrusionLeft, + xProtrusionRight, + radiusReductionRight, + radiusReductionLeft, + maxWidthRadius; + this.ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); + for (i = 0; i < this.valuesCount; i++) { + // 5px to space the text slightly out - similar to what we do in the draw function. + pointPosition = this.getPointPosition(i, largestPossibleRadius); + textWidth = this.ctx.measureText(template(this.templateString, { + value: this.labels[i] + })).width + 5; + if (i === 0 || i === this.valuesCount / 2) { + // If we're at index zero, or exactly the middle, we're at exactly the top/bottom + // of the radar chart, so text will be aligned centrally, so we'll half it and compare + // w/left and right text sizes + halfTextWidth = textWidth / 2; + if (pointPosition.x + halfTextWidth > furthestRight) { + furthestRight = pointPosition.x + halfTextWidth; + furthestRightIndex = i; + } + if (pointPosition.x - halfTextWidth < furthestLeft) { + furthestLeft = pointPosition.x - halfTextWidth; + furthestLeftIndex = i; + } + } else if (i < this.valuesCount / 2) { + // Less than half the values means we'll left align the text + if (pointPosition.x + textWidth > furthestRight) { + furthestRight = pointPosition.x + textWidth; + furthestRightIndex = i; + } + } else if (i > this.valuesCount / 2) { + // More than half the values means we'll right align the text + if (pointPosition.x - textWidth < furthestLeft) { + furthestLeft = pointPosition.x - textWidth; + furthestLeftIndex = i; + } + } + } + + xProtrusionLeft = furthestLeft; + + xProtrusionRight = Math.ceil(furthestRight - this.width); + + furthestRightAngle = this.getIndexAngle(furthestRightIndex); + + furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); + + radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); + + radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + + // Ensure we actually need to reduce the size of the chart + radiusReductionRight = (isNumber(radiusReductionRight)) ? radiusReductionRight : 0; + radiusReductionLeft = (isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; + + this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; + + //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) + this.setCenterPoint(radiusReductionLeft, radiusReductionRight); + + }, + setCenterPoint: function(leftMovement, rightMovement) { + + var maxRight = this.width - rightMovement - this.drawingArea, + maxLeft = leftMovement + this.drawingArea; + + this.xCenter = (maxLeft + maxRight) / 2; + // Always vertically in the centre as the text height doesn't change + this.yCenter = (this.height / 2); + }, + + getIndexAngle: function(index) { + var angleMultiplier = (Math.PI * 2) / this.valuesCount; + // Start from the top instead of right, so remove a quarter of the circle + + return index * angleMultiplier - (Math.PI / 2); + }, + getPointPosition: function(index, distanceFromCenter) { + var thisAngle = this.getIndexAngle(index); + return { + x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, + y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter + }; + }, + draw: function() { + if (this.display) { + var ctx = this.ctx; + each(this.yLabels, function(label, index) { + // Don't draw a centre value + if (index > 0) { + var yCenterOffset = index * (this.drawingArea / this.steps), + yHeight = this.yCenter - yCenterOffset, + pointPosition; + + // Draw circular lines around the scale + if (this.lineWidth > 0) { + ctx.strokeStyle = this.lineColor; + ctx.lineWidth = this.lineWidth; + + if (this.lineArc) { + ctx.beginPath(); + ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); + ctx.closePath(); + ctx.stroke(); + } else { + ctx.beginPath(); + for (var i = 0; i < this.valuesCount; i++) { + pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.min + (index * this.stepValue))); + if (i === 0) { + ctx.moveTo(pointPosition.x, pointPosition.y); + } else { + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + } + } + if (this.showLabels) { + ctx.font = fontString(this.fontSize, this._fontStyle, this._fontFamily); + if (this.showLabelBackdrop) { + var labelWidth = ctx.measureText(label).width; + ctx.fillStyle = this.backdropColor; + ctx.fillRect( + this.xCenter - labelWidth / 2 - this.backdropPaddingX, + yHeight - this.fontSize / 2 - this.backdropPaddingY, + labelWidth + this.backdropPaddingX * 2, + this.fontSize + this.backdropPaddingY * 2 + ); + } + ctx.textAlign = 'center'; + ctx.textBaseline = "middle"; + ctx.fillStyle = this.fontColor; + ctx.fillText(label, this.xCenter, yHeight); + } + } + }, this); + + if (!this.lineArc) { + ctx.lineWidth = this.angleLineWidth; + ctx.strokeStyle = this.angleLineColor; + for (var i = this.valuesCount - 1; i >= 0; i--) { + if (this.angleLineWidth > 0) { + var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); + ctx.beginPath(); + ctx.moveTo(this.xCenter, this.yCenter); + ctx.lineTo(outerPosition.x, outerPosition.y); + ctx.stroke(); + ctx.closePath(); + } + // Extra 3px out for some label spacing + var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); + ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); + ctx.fillStyle = this.pointLabelFontColor; + + var labelsCount = this.labels.length, + halfLabelsCount = this.labels.length / 2, + quarterLabelsCount = halfLabelsCount / 2, + upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), + exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); + if (i === 0) { + ctx.textAlign = 'center'; + } else if (i === halfLabelsCount) { + ctx.textAlign = 'center'; + } else if (i < halfLabelsCount) { + ctx.textAlign = 'left'; + } else { + ctx.textAlign = 'right'; + } + + // Set the correct text baseline based on outer positioning + if (exactQuarter) { + ctx.textBaseline = 'middle'; + } else if (upperHalf) { + ctx.textBaseline = 'bottom'; + } else { + ctx.textBaseline = 'top'; + } + + ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + } + } + } + } + }); + + Chart.animationService = { + frameDuration: 17, + animations: [], + dropFrames: 0, + addAnimation: function(chartInstance, animationObject, duration) { + + if (!duration) { + chartInstance.animating = true; + } + + for (var index = 0; index < this.animations.length; ++index) { + if (this.animations[index].chartInstance === chartInstance) { + // replacing an in progress animation + this.animations[index].animationObject = animationObject; + return; + } + } + + this.animations.push({ + chartInstance: chartInstance, + animationObject: animationObject + }); + + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (this.animations.length == 1) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + }, + // Cancel the animation for a given chart instance + cancelAnimation: function(chartInstance) { + var index = helpers.findNextWhere(this.animations, function(animationWrapper) { + return animationWrapper.chartInstance === chartInstance; + }); + + if (index) { + this.animations.splice(index, 1); + chartInstance.animating = false; + } + }, + // calls startDigest with the proper context + digestWrapper: function() { + Chart.animationService.startDigest.call(Chart.animationService); + }, + startDigest: function() { + + var startTime = Date.now(); + var framesToDrop = 0; + + if (this.dropFrames > 1) { + framesToDrop = Math.floor(this.dropFrames); + this.dropFrames -= framesToDrop; + } + + for (var i = 0; i < this.animations.length; i++) { + + if (this.animations[i].animationObject.currentStep === null) { + this.animations[i].animationObject.currentStep = 0; + } + + this.animations[i].animationObject.currentStep += 1 + framesToDrop; + if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { + this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; + } + + this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); + + if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { + // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; + this.animations.splice(i, 1); + // Keep the index in place to offset the splice + i--; + } + } + + var endTime = Date.now(); + var delay = endTime - startTime - this.frameDuration; + var frameDelay = delay / this.frameDuration; + + if (frameDelay > 1) { + this.dropFrames += frameDelay; + } + + // Do we have more stuff to animate? + if (this.animations.length > 0) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + } + }; + + // Attach global event to resize each chart instance when the browser resizes + helpers.addEvent(window, "resize", (function() { + // Basic debounce of resize function so it doesn't hurt performance when resizing browser. + var timeout; + return function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + each(Chart.instances, function(instance) { + // If the responsive flag is set in the chart instance config + // Cascade the resize event down to the chart. + if (instance.options.responsive) { + instance.resize(instance.render, true); + } + }); + }, 50); + }; + })()); + + + if (amd) { + define(function() { + return Chart; + }); + } else if (typeof module === 'object' && module.exports) { + module.exports = Chart; + } + + root.Chart = Chart; + + Chart.noConflict = function() { + root.Chart = previous; + return Chart; + }; }).call(this); diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 90f3d0265fd..b9633aac21a 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -1,212 +1,319 @@ -(function(){ - "use strict"; - - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; - - var defaultConfig = { - //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, - - //The percentage of the chart that we cut out of the middle. - percentageInnerCutout : 50, - - //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, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " - - }; - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults : defaultConfig, - //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){ - - // Save data as a source for updating of values & methods - this.data = data; - - //Declare segments as a static property to prevent inheriting across the Chart type prototype - this.segments = []; - this.outerRadius = (helpers.min([this.chart.width,this.chart.height]) - this.options.segmentStrokeWidth/2)/2; - - this.SegmentArc = Chart.Arc.extend({ - ctx : this.chart.ctx, - x : this.chart.width/2, - y : this.chart.height/2 - }); - - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ - var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : []; - - helpers.each(this.segments,function(segment){ - segment.restore(["fillColor"]); - }); - helpers.each(activeSegments,function(activeSegment){ - activeSegment.fillColor = activeSegment.highlightColor; - }); - this.showTooltip(activeSegments); - }); - } - this.calculateTotal(data); - - helpers.each(data,function(datapoint, index){ - if (!datapoint.color) { - datapoint.color = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; - } - this.addData(datapoint, index, true); - },this); - - this.render(); - }, - getSegmentsAtEvent : function(e){ - var segmentsArray = []; - - var location = helpers.getRelativePosition(e); - - helpers.each(this.segments,function(segment){ - if (segment.inRange(location.x,location.y)) segmentsArray.push(segment); - },this); - return segmentsArray; - }, - addData : function(segment, atIndex, silent){ - var index = atIndex || this.segments.length; - this.segments.splice(index, 0, new this.SegmentArc({ - value : segment.value, - outerRadius : (this.options.animateScale) ? 0 : this.outerRadius, - innerRadius : (this.options.animateScale) ? 0 : (this.outerRadius/100) * this.options.percentageInnerCutout, - fillColor : segment.color, - highlightColor : segment.highlight || segment.color, - showStroke : this.options.segmentShowStroke, - strokeWidth : this.options.segmentStrokeWidth, - strokeColor : this.options.segmentStrokeColor, - startAngle : Math.PI * 1.5, - circumference : (this.options.animateRotate) ? 0 : this.calculateCircumference(segment.value), - label : segment.label - })); - if (!silent){ - this.reflow(); - this.update(); - } - }, - calculateCircumference : function(value) { - if ( this.total > 0 ) { - return (Math.PI*2)*(value / this.total); - } else { - return 0; - } - }, - calculateTotal : function(data){ - this.total = 0; - helpers.each(data,function(segment){ - this.total += Math.abs(segment.value); - },this); - }, - update : function(){ - - // Map new data to data points - if(this.data.length == this.segments.length){ - helpers.each(this.data, function(segment, i){ - helpers.extend(this.segments[i], { - value : segment.value, - fillColor : segment.color, - highlightColor : segment.highlight || segment.color, - showStroke : this.options.segmentShowStroke, - strokeWidth : this.options.segmentStrokeWidth, - strokeColor : this.options.segmentStrokeColor, - label : segment.label - }); - }, this); - } else{ - // Data size changed without properly inserting, just redraw the chart - this.initialize(this.data); - } - - this.calculateTotal(this.segments); - - // Reset any highlight colours before updating. - helpers.each(this.activeElements, function(activeElement){ - activeElement.restore(['fillColor']); - }); - - helpers.each(this.segments,function(segment){ - segment.save(); - }); - this.render(); - }, - - removeData: function(atIndex){ - var indexToDelete = (helpers.isNumber(atIndex)) ? atIndex : this.segments.length-1; - this.segments.splice(indexToDelete, 1); - this.reflow(); - this.update(); - }, - - reflow : function(){ - helpers.extend(this.SegmentArc.prototype,{ - x : this.chart.width/2, - y : this.chart.height/2 - }); - this.outerRadius = (helpers.min([this.chart.width,this.chart.height]) - this.options.segmentStrokeWidth/2)/2; - helpers.each(this.segments, function(segment){ - segment.update({ - outerRadius : this.outerRadius, - innerRadius : (this.outerRadius/100) * this.options.percentageInnerCutout - }); - }, this); - }, - draw : function(easeDecimal){ - var animDecimal = (easeDecimal) ? easeDecimal : 1; - this.clear(); - helpers.each(this.segments,function(segment,index){ - segment.transition({ - circumference : this.calculateCircumference(segment.value), - outerRadius : this.outerRadius, - innerRadius : (this.outerRadius/100) * this.options.percentageInnerCutout - },animDecimal); - - segment.endAngle = segment.startAngle + segment.circumference; - - segment.draw(); - if (index === 0){ - segment.startAngle = Math.PI * 1.5; - } - //Check to see if it's the last segment, if not get the next and update the start angle - if (index < this.segments.length-1){ - this.segments[index+1].startAngle = segment.endAngle; - } - },this); - - } - }); - - Chart.types.Doughnut.extend({ - name : "Pie", - defaults : helpers.merge(defaultConfig,{percentageInnerCutout : 0}) - }); +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; + + var defaultConfig = { + //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, + + //The percentage of the chart that we cut out of the middle. + percentageInnerCutout: 50, + + //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, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " + + }; + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "Doughnut", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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) { + + // Save data as a source for updating of values & methods + this.data = data; + + // Slice Type and defaults + this.Slice = Chart.Arc.extend({ + _chart: this.chart, + x: this.chart.width / 2, + y: this.chart.height / 2 + }); + + //Set up tooltip events on the chart + if (this.options.showTooltips) { + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + } + this.calculateTotal(data); + + // Create new slice for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(slice, index) { + var metaSlice = new this.Slice(); + if (typeof slice == 'number') { + helpers.extend(metaSlice, { + value: slice + }); + } else { + helpers.extend(metaSlice, slice); + } + if (!metaSlice.color) { + slice.color = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; + } + metaSlice.save(); + dataset.metaData.push(metaSlice); + }, this); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.update(); + }, + onHover: function(evt) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + this.lastActive[0].backgroundColor = this.data.datasets[0].backgroundColor; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, + getSegmentsAtEvent: function(e) { + var segmentsArray = []; + + var location = helpers.getRelativePosition(e); + + helpers.each(this.segments, function(segment) { + if (segment.inRange(location.x, location.y)) segmentsArray.push(segment); + }, this); + return segmentsArray; + }, + calculateCircumference: function(value) { + if (this.total > 0) { + return (Math.PI * 2) * (value / this.total); + } else { + return 0; + } + }, + calculateTotal: function(data) { + this.total = 0; + helpers.each(data, function(segment) { + this.total += Math.abs(segment.value); + }, this); + }, + update: function() { + + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2; + + + // Map new data to data points + helpers.each(this.data, function(segment, i) { + helpers.extend(this.segments[i], { + x: this.chart.width / 2, + y: this.chart.height / 2, + value: segment.value, + backgroundColor: segment.color, + hoverBackgroundColor: segment.highlight || segment.color, + borderWidth: this.options.segmentStrokeWidth, + borderColor: this.options.segmentStrokeColor, + label: segment.label, + startAngle: Math.PI * 1.5, + circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(segment.value), + innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, + outerRadius: (this.options.animateScale) ? 0 : this.outerRadius, + }); + }, this); + + this.calculateTotal(this.segments); + + // Reset any highlight colours before updating. + helpers.each(this.activeElements, function(activeElement) { + activeElement.restore(['backgroundColor']); + }); + + helpers.each(this.segments, function(segment) { + segment.save(); + }); + this.render(); + }, + + removeData: function(atIndex) { + var indexToDelete = (helpers.isNumber(atIndex)) ? atIndex : this.segments.length - 1; + this.segments.splice(indexToDelete, 1); + this.reflow(); + this.update(); + }, + + reflow: function() { + helpers.extend(this.Slice.prototype, { + x: this.chart.width / 2, + y: this.chart.height / 2 + }); + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2; + helpers.each(this.segments, function(segment) { + segment.update({ + outerRadius: this.outerRadius, + innerRadius: (this.outerRadius / 100) * this.options.percentageInnerCutout + }); + }, this); + }, + draw: function(easeDecimal) { + var animDecimal = (easeDecimal) ? easeDecimal : 1; + this.clear(); + helpers.each(this.segments, function(segment, index) { + segment.transition({ + circumference: this.calculateCircumference(segment.value), + outerRadius: this.outerRadius, + innerRadius: (this.outerRadius / 100) * this.options.percentageInnerCutout + }, animDecimal); + + segment.endAngle = segment.startAngle + segment.circumference; + + segment.draw(); + if (index === 0) { + segment.startAngle = Math.PI * 1.5; + } + //Check to see if it's the last segment, if not get the next and update the start angle + if (index < this.segments.length - 1) { + this.segments[index + 1].startAngle = segment.endAngle; + } + }, this); + + } + }); + + Chart.types.Doughnut.extend({ + name: "Pie", + defaults: helpers.merge(defaultConfig, { + percentageInnerCutout: 0 + }) + }); }).call(this); diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 568f1097def..e328b0a68be 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -1,427 +1,423 @@ -(function(){ - "use strict"; +(function() { + "use strict"; - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - - ///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 to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, - - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, - - //Number - Tension of the bezier curve between points - tension : 0.4, - - //Number - Radius of each point dot in pixels - pointRadius : 4, - - //Number - Pixel width of point dot border - pointBorderWidth : 1, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHoverRadius : 20, - - //Number - Pixel width of dataset border - borderWidth : 2, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - - //Boolean - Whether to horizontally center the label and point dot inside the grid - offsetGridLines : false - - }; - - - Chart.Type.extend({ - name: "Line", - defaults : defaultConfig, - initialize: function(data){ - // Save data as a source for updating of values & methods - this.data = data; - - //Custom Point Defaults - this.PointClass = Chart.Point.extend({ - _chart: this.chart, - offsetGridLines : this.options.offsetGridLines, - borderWidth : this.options.pointBorderWidth, - radius : this.options.pointRadius, - hoverRadius : this.options.pointHoverRadius, - }); - - // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); - - // Build Scale - this.buildScale(this.data.labels); - - - //Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets,function(dataset,datasetIndex){ - dataset.metaDataset = new Chart.Line(); - dataset.metaData = []; - helpers.each(dataset.data,function(dataPoint,index){ - dataset.metaData.push(new this.PointClass()); - },this); - },this); - - // Set defaults for lines - this.eachDataset(function(dataset, datasetIndex){ - dataset = helpers.merge(this.options, dataset); - helpers.extend(dataset.metaDataset, { - _points: dataset.metaData, - _datasetIndex: datasetIndex, - _chart: this.chart, - }); - // Copy to view model - dataset.metaDataset.save(); - }, this); - - // Set defaults for points - this.eachElement(function(point, index, dataset, datasetIndex){ - helpers.extend(point, { - x: this.scale.calculateX(index), - y: this.scale.endPoint, - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart - }); - - // Default bezier control points - helpers.extend(point, { - controlPointPreviousX: this.previousPoint(dataset, index).x, - controlPointPreviousY: this.nextPoint(dataset, index).y, - controlPointNextX: this.previousPoint(dataset, index).x, - controlPointNextY: this.nextPoint(dataset, index).y, - }); - // Copy to view model - point.save(); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - this.update(); - }, - nextPoint: function(collection, index){ - return collection[index - 1] || collection[index]; - }, - previousPoint: function(collection, index){ - return collection[index + 1] || collection[index]; - }, - onHover: function(e){ - - - // If exiting chart - if(e.type == 'mouseout'){ - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function(){ - switch(this.options.hoverMode){ - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if(this.options.onHover){ - this.options.onHover.call(this, this.active); - } - - // Remove styling for last active (even if it may still be active) - if(this.lastActive.length){ - switch(this.options.hoverMode){ - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; - this.lastActive[0].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBackgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBorderColor; - this.lastActive[i].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if(this.active.length && this.options.hoverMode){ - switch(this.options.hoverMode){ - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderWidth = this.data.datasets[this.active[0]._datasetIndex].borderWidth + 10; - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderWidth = this.data.datasets[this.active[i]._datasetIndex].borderWidth + 2; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if(this.options.showTooltips){ - - // The usual updates - this.tooltip.initialize(); - - // Active - if(this.active.length){ - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, - }); - - this.tooltip.update(); - } - else{ - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); - } - } - - - // Hover animations - this.tooltip.pivot(); - - if(!this.animating){ - var changed; - - helpers.each(this.active, function(element, index){ - if (element !== this.lastActive[index]){ - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length)|| - (this.lastActive.length && this.active.length && changed)){ - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - update : function(){ - - this.scale.update(); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex){ - helpers.extend(dataset.metaDataset, { - backgroundColor: dataset.backgroundColor || this.options.backgroundColor, - borderWidth: dataset.borderWidth || this.options.borderWidth, - borderColor: dataset.borderColor || this.options.borderColor, - tension: dataset.tension || this.options.tension, - scaleTop: this.scale.startPoint, - scaleBottom: this.scale.endPoint, - _points: dataset.metaData, - _datasetIndex: datasetIndex, - }); - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex){ - helpers.extend(point, { - x: this.scale.calculateX(index), - y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), - value : this.data.datasets[datasetIndex].data[index], - label : this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - // Appearance - hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, - hoverBorderColor : this.data.datasets[datasetIndex].pointHoverBorderColor || this.options.pointHoverBorderColor, - hoverRadius : this.data.datasets[datasetIndex].pointHoverRadius || this.options.pointHoverRadius, - radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, - borderColor: this.data.datasets[datasetIndex].pointBorderColor || this.options.pointBorderColor, - backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, - tension: this.data.datasets[datasetIndex].metaDataset.tension, - _datasetIndex: datasetIndex, - _index: index, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex){ - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index), - point, - this.nextPoint(dataset, index), - point.tension - ); - - point.controlPointPreviousX = controlPoints.previous.x; - point.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.scale.endPoint){ - point.controlPointNextY = this.scale.endPoint; - } - else if (controlPoints.next.y < this.scale.startPoint){ - point.controlPointNextY = this.scale.startPoint; - } - else{ - point.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.scale.endPoint){ - point.controlPointPreviousY = this.scale.endPoint; - } - else if (controlPoints.previous.y < this.scale.startPoint){ - point.controlPointPreviousY = this.scale.startPoint; - } - else{ - point.controlPointPreviousY = controlPoints.previous.y; - } - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(); - }, - buildScale : function(labels){ - var self = this; - - var dataTotal = function(){ - var values = []; - self.eachValue(function(value){ - values.push(value); - }); - - return values; - }; - - var scaleOptions = { - templateString : this.options.scaleLabel, - height : this.chart.height, - width : this.chart.width, - ctx : this.chart.ctx, - textColor : this.options.scaleFontColor, - offsetGridLines : this.options.offsetGridLines, - fontSize : this.options.scaleFontSize, - fontStyle : this.options.scaleFontStyle, - fontFamily : this.options.scaleFontFamily, - valuesCount : labels.length, - beginAtZero : this.options.scaleBeginAtZero, - integersOnly : this.options.scaleIntegersOnly, - calculateYRange : function(currentHeight){ - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); - }, - xLabels : this.data.labels, - font : helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth : this.options.scaleLineWidth, - lineColor : this.options.scaleLineColor, - showHorizontalLines : this.options.scaleShowHorizontalLines, - showVerticalLines : this.options.scaleShowVerticalLines, - 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.pointRadius + this.options.pointBorderWidth, - showLabels : this.options.scaleShowLabels, - display : this.options.showScale - }; - - if (this.options.scaleOverride){ - helpers.extend(scaleOptions, { - calculateYRange: helpers.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 Chart.Scale(scaleOptions); - }, - redraw : function(){ - - }, - draw : function(ease){ - - var easingDecimal = ease || 1; - this.clear(); - - this.scale.draw(easingDecimal); - - this.eachDataset(function(dataset, datasetIndex){ - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index){ - point.transition(easingDecimal); - },this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData,function(point){ - point.draw(); - }); - },this); - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - } - }); + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + + ///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 to show horizontal lines (except X axis) + scaleShowHorizontalLines: true, + + //Boolean - Whether to show vertical lines (except Y axis) + scaleShowVerticalLines: true, + + //Number - Tension of the bezier curve between points + tension: 0.4, + + //Number - Radius of each point dot in pixels + pointRadius: 4, + + //Number - Pixel width of point dot border + pointBorderWidth: 1, + + //Number - amount extra to add to the radius to cater for hit detection outside the drawn point + pointHoverRadius: 20, + + //Number - Pixel width of dataset border + borderWidth: 2, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", + + //Boolean - Whether to horizontally center the label and point dot inside the grid + offsetGridLines: false + + }; + + + Chart.Type.extend({ + name: "Line", + defaults: defaultConfig, + initialize: function(data) { + // Save data as a source for updating of values & methods + this.data = data; + + //Custom Point Defaults + this.PointClass = Chart.Point.extend({ + _chart: this.chart, + offsetGridLines: this.options.offsetGridLines, + borderWidth: this.options.pointBorderWidth, + radius: this.options.pointRadius, + hoverRadius: this.options.pointHoverRadius, + }); + + // Events + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + + // Build Scale + this.buildScale(this.data.labels); + + + //Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaDataset = new Chart.Line(); + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new this.PointClass()); + }, this); + }, this); + + // Set defaults for lines + this.eachDataset(function(dataset, datasetIndex) { + dataset = helpers.merge(this.options, dataset); + helpers.extend(dataset.metaDataset, { + _points: dataset.metaData, + _datasetIndex: datasetIndex, + _chart: this.chart, + }); + // Copy to view model + dataset.metaDataset.save(); + }, this); + + // Set defaults for points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + x: this.scale.calculateX(index), + y: this.scale.endPoint, + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart + }); + + // Default bezier control points + helpers.extend(point, { + controlPointPreviousX: this.previousPoint(dataset, index).x, + controlPointPreviousY: this.nextPoint(dataset, index).y, + controlPointNextX: this.previousPoint(dataset, index).x, + controlPointNextY: this.nextPoint(dataset, index).y, + }); + // Copy to view model + point.save(); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index - 1] || collection[index]; + }, + previousPoint: function(collection, index) { + return collection[index + 1] || collection[index]; + }, + onHover: function(e) { + + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; + this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; + this.lastActive[0].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBackgroundColor; + this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBorderColor; + this.lastActive[i].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderWidth = this.data.datasets[this.active[0]._datasetIndex].borderWidth + 10; + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderWidth = this.data.datasets[this.active[i]._datasetIndex].borderWidth + 2; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, + update: function() { + + this.scale.update(); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + helpers.extend(dataset.metaDataset, { + backgroundColor: dataset.backgroundColor || this.options.backgroundColor, + borderWidth: dataset.borderWidth || this.options.borderWidth, + borderColor: dataset.borderColor || this.options.borderColor, + tension: dataset.tension || this.options.tension, + scaleTop: this.scale.startPoint, + scaleBottom: this.scale.endPoint, + _points: dataset.metaData, + _datasetIndex: datasetIndex, + }); + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + x: this.scale.calculateX(index), + y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), + value: this.data.datasets[datasetIndex].data[index], + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + // Appearance + hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, + hoverBorderColor: this.data.datasets[datasetIndex].pointHoverBorderColor || this.options.pointHoverBorderColor, + hoverRadius: this.data.datasets[datasetIndex].pointHoverRadius || this.options.pointHoverRadius, + radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, + borderColor: this.data.datasets[datasetIndex].pointBorderColor || this.options.pointBorderColor, + backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, + tension: this.data.datasets[datasetIndex].metaDataset.tension, + _datasetIndex: datasetIndex, + _index: index, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index), + point, + this.nextPoint(dataset, index), + point.tension + ); + + point.controlPointPreviousX = controlPoints.previous.x; + point.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.scale.endPoint) { + point.controlPointNextY = this.scale.endPoint; + } else if (controlPoints.next.y < this.scale.startPoint) { + point.controlPointNextY = this.scale.startPoint; + } else { + point.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.scale.endPoint) { + point.controlPointPreviousY = this.scale.endPoint; + } else if (controlPoints.previous.y < this.scale.startPoint) { + point.controlPointPreviousY = this.scale.startPoint; + } else { + point.controlPointPreviousY = controlPoints.previous.y; + } + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(); + }, + buildScale: function(labels) { + var self = this; + + var dataTotal = function() { + var values = []; + self.eachValue(function(value) { + values.push(value); + }); + + return values; + }; + + var scaleOptions = { + templateString: this.options.scaleLabel, + height: this.chart.height, + width: this.chart.width, + ctx: this.chart.ctx, + textColor: this.options.scaleFontColor, + offsetGridLines: this.options.offsetGridLines, + fontSize: this.options.scaleFontSize, + fontStyle: this.options.scaleFontStyle, + fontFamily: this.options.scaleFontFamily, + valuesCount: labels.length, + beginAtZero: this.options.scaleBeginAtZero, + integersOnly: this.options.scaleIntegersOnly, + calculateYRange: function(currentHeight) { + var updatedRanges = helpers.calculateScaleRange( + dataTotal(), + currentHeight, + this.fontSize, + this.beginAtZero, + this.integersOnly + ); + helpers.extend(this, updatedRanges); + }, + xLabels: this.data.labels, + font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), + lineWidth: this.options.scaleLineWidth, + lineColor: this.options.scaleLineColor, + showHorizontalLines: this.options.scaleShowHorizontalLines, + showVerticalLines: this.options.scaleShowVerticalLines, + 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.pointRadius + this.options.pointBorderWidth, + showLabels: this.options.scaleShowLabels, + display: this.options.showScale + }; + + if (this.options.scaleOverride) { + helpers.extend(scaleOptions, { + calculateYRange: helpers.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 Chart.Scale(scaleOptions); + }, + redraw: function() { + + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + this.scale.draw(easingDecimal); + + this.eachDataset(function(dataset, datasetIndex) { + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + } + }); }).call(this); From 872c92cd4b3893101d368f845a90b5f31a4bb6d4 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 15 May 2015 22:34:08 -0600 Subject: [PATCH 028/424] Doughnut/Pie Chart refactor --- samples/doughnut.html | 62 +++++++------ src/Chart.Core.js | 19 ++-- src/Chart.Doughnut.js | 208 +++++++++++++++--------------------------- 3 files changed, 115 insertions(+), 174 deletions(-) diff --git a/samples/doughnut.html b/samples/doughnut.html index 125beaf4653..145ff450a1a 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -30,34 +30,36 @@ return Math.round(Math.random() * 255) }; - var doughnutData = [{ - value: randomScalingFactor(), - color: "#F7464A", - highlight: "#FF5A5E", - label: "Red" - }, { - value: randomScalingFactor(), - color: "#46BFBD", - highlight: "#5AD3D1", - label: "Green" - }, { - value: randomScalingFactor(), - color: "#FDB45C", - highlight: "#FFC870", - label: "Yellow" - }, { - value: randomScalingFactor(), - color: "#949FB1", - highlight: "#A8B3C5", - label: "Grey" - }, { - value: randomScalingFactor(), - color: "#4D5360", - highlight: "#616774", - label: "Dark Grey" - } + var doughnutData = { + data: [{ + value: randomScalingFactor(), + backgroundColor: "#F7464A", + hoverBackgroundColor: "#FF5A5E", + label: "Red" + }, { + value: randomScalingFactor(), + backgroundColor: "#46BFBD", + hoverBackgroundColor: "#5AD3D1", + label: "Green" + }, { + value: randomScalingFactor(), + backgroundColor: "#FDB45C", + hoverBackgroundColor: "#FFC870", + label: "Yellow" + }, { + value: randomScalingFactor(), + backgroundColor: "#949FB1", + hoverBackgroundColor: "#A8B3C5", + label: "Grey" + }, { + value: randomScalingFactor(), + backgroundColor: "#4D5360", + hoverBackgroundColor: "#616774", + label: "Dark Grey" + } - ]; + ] + }; window.onload = function() { var ctx = document.getElementById("chart-area").getContext("2d"); @@ -67,9 +69,9 @@ }; $('#randomizeData').click(function() { - $.each(doughnutData, function(i, piece) { - doughnutData[i].value = randomScalingFactor(); - doughnutData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + $.each(doughnutData.data, function(i, datapoint) { + datapoint.value = randomScalingFactor(); + datapoint.backgroundColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; }); window.myDoughnut.update(); }); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 1d6651ab706..fbb6f539758 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1299,28 +1299,27 @@ y: this.y + (Math.sin(centreAngle) * rangeFromCentre) }; }, - draw: function(animationPercent) { - - var easingDecimal = animationPercent || 1; + draw: function() { - var ctx = this.ctx; + var ctx = this._chart.ctx; + var vm = this._vm; ctx.beginPath(); - ctx.arc(this.x, this.y, this.outerRadius, this.startAngle, this.endAngle); + ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); - ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); + ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); ctx.closePath(); - ctx.strokeStyle = this.borderColor; - ctx.lineWidth = this.borderWidth; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; - ctx.fillStyle = this.backgroundColor; + ctx.fillStyle = vm.backgroundColor; ctx.fill(); ctx.lineJoin = 'bevel'; - if (this.showBorder) { + if (vm.borderWidth) { ctx.stroke(); } } diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index b9633aac21a..64e3634ab0a 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -14,16 +14,16 @@ segmentStrokeColor: "#fff", //Number - The width of each segment stroke - segmentStrokeWidth: 2, + borderWidth: 2, //The percentage of the chart that we cut out of the middle. - percentageInnerCutout: 50, + cutoutPercentage: 50, - //Number - Amount of animation steps - animationSteps: 100, + // The duration of animations triggered by hover events + hoverAnimationDuration: 400, //String - Animation easing effect - animationEasing: "easeOutBounce", + animationEasing: "easeOutQuart", //Boolean - Whether we animate the rotation of the Doughnut animateRotate: true, @@ -59,26 +59,29 @@ if (this.options.showTooltips) { helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); } - this.calculateTotal(data); // Create new slice for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(slice, index) { - var metaSlice = new this.Slice(); - if (typeof slice == 'number') { - helpers.extend(metaSlice, { - value: slice - }); - } else { - helpers.extend(metaSlice, slice); - } - if (!metaSlice.color) { - slice.color = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; - } - metaSlice.save(); - dataset.metaData.push(metaSlice); - }, this); + this.data.metaData = []; + helpers.each(this.data.data, function(slice, index) { + var metaSlice = new this.Slice(); + if (typeof slice == 'number') { + helpers.extend(metaSlice, { + value: slice + }); + } else { + helpers.extend(metaSlice, slice); + } + helpers.extend(metaSlice, { + startAngle: Math.PI * 1.5, + circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animateScale) ? 0 : this.outerRadius, + innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, + }); + if (!metaSlice.backgroundColor) { + slice.backgroundColor = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; + } + metaSlice.save(); + this.data.metaData.push(metaSlice); }, this); // Create tooltip instance exclusively for this chart with some defaults. @@ -90,7 +93,7 @@ this.update(); }, - onHover: function(evt) { + onHover: function(e) { // If exiting chart if (e.type == 'mouseout') { @@ -100,18 +103,7 @@ this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hoverMode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + this.active = this.getSliceAtEvent(e); // On Hover hook if (this.options.onHover) { @@ -120,41 +112,14 @@ // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - switch (this.options.hoverMode) { - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[0].backgroundColor; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } + this.lastActive[0].backgroundColor = this.data.data[this.lastActive[0]._index].backgroundColor; } // Built in hover styling if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } + this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); } - // Built in Tooltips if (this.options.showTooltips) { @@ -205,15 +170,15 @@ return this; }, - getSegmentsAtEvent: function(e) { - var segmentsArray = []; + getSliceAtEvent: function(e) { + var elements = []; var location = helpers.getRelativePosition(e); - helpers.each(this.segments, function(segment) { - if (segment.inRange(location.x, location.y)) segmentsArray.push(segment); + helpers.each(this.data.metaData, function(slice, index) { + if (slice.inRange(location.x, location.y)) elements.push(slice); }, this); - return segmentsArray; + return elements; }, calculateCircumference: function(value) { if (this.total > 0) { @@ -222,97 +187,72 @@ return 0; } }, - calculateTotal: function(data) { - this.total = 0; - helpers.each(data, function(segment) { - this.total += Math.abs(segment.value); - }, this); - }, update: function() { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2; + // Calc Total + this.total = 0; + helpers.each(this.data.data, function(slice) { + this.total += Math.abs(slice.value); + }, this); + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.borderWidth / 2) / 2; // Map new data to data points - helpers.each(this.data, function(segment, i) { - helpers.extend(this.segments[i], { + helpers.each(this.data.metaData, function(slice, index) { + + var datapoint = this.data.data[index]; + + helpers.extend(slice, { + _index: index, x: this.chart.width / 2, y: this.chart.height / 2, - value: segment.value, - backgroundColor: segment.color, - hoverBackgroundColor: segment.highlight || segment.color, - borderWidth: this.options.segmentStrokeWidth, + value: datapoint.value, + label: datapoint.label, + circumference: this.calculateCircumference(datapoint.value), + outerRadius: this.outerRadius, + innerRadius: (this.outerRadius / 100) * this.options.cutoutPercentage, + + backgroundColor: datapoint.backgroundColor, + hoverBackgroundColor: datapoint.hoverBackgroundColor || datapoint.backgroundColor, + borderWidth: this.options.borderWidth, borderColor: this.options.segmentStrokeColor, - label: segment.label, - startAngle: Math.PI * 1.5, - circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(segment.value), - innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, - outerRadius: (this.options.animateScale) ? 0 : this.outerRadius, }); - }, this); - this.calculateTotal(this.segments); + helpers.extend(slice, { + endAngle: slice.startAngle + slice.circumference, + }); - // Reset any highlight colours before updating. - helpers.each(this.activeElements, function(activeElement) { - activeElement.restore(['backgroundColor']); - }); + if (index === 0) { + slice.startAngle = Math.PI * 1.5; + } - helpers.each(this.segments, function(segment) { - segment.save(); - }); - this.render(); - }, + //Check to see if it's the last slice, if not get the next and update its start angle + if (index < this.data.data.length - 1) { + this.data.metaData[index + 1].startAngle = slice.endAngle; + } - removeData: function(atIndex) { - var indexToDelete = (helpers.isNumber(atIndex)) ? atIndex : this.segments.length - 1; - this.segments.splice(indexToDelete, 1); - this.reflow(); - this.update(); - }, + slice.pivot(); - reflow: function() { - helpers.extend(this.Slice.prototype, { - x: this.chart.width / 2, - y: this.chart.height / 2 - }); - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2; - helpers.each(this.segments, function(segment) { - segment.update({ - outerRadius: this.outerRadius, - innerRadius: (this.outerRadius / 100) * this.options.percentageInnerCutout - }); }, this); + + this.render(); }, draw: function(easeDecimal) { - var animDecimal = (easeDecimal) ? easeDecimal : 1; + easeDecimal = easeDecimal || 1; this.clear(); - helpers.each(this.segments, function(segment, index) { - segment.transition({ - circumference: this.calculateCircumference(segment.value), - outerRadius: this.outerRadius, - innerRadius: (this.outerRadius / 100) * this.options.percentageInnerCutout - }, animDecimal); - - segment.endAngle = segment.startAngle + segment.circumference; - segment.draw(); - if (index === 0) { - segment.startAngle = Math.PI * 1.5; - } - //Check to see if it's the last segment, if not get the next and update the start angle - if (index < this.segments.length - 1) { - this.segments[index + 1].startAngle = segment.endAngle; - } + helpers.each(this.data.metaData, function(slice, index) { + slice.transition(easeDecimal).draw(); }, this); + this.tooltip.transition(easeDecimal).draw(); } }); Chart.types.Doughnut.extend({ name: "Pie", defaults: helpers.merge(defaultConfig, { - percentageInnerCutout: 0 + cutoutPercentage: 0 }) }); From ad972a0c5ce3ad1bb87ff2d1b26accca04a8d5df Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 15 May 2015 22:45:17 -0600 Subject: [PATCH 029/424] Pie cleanup. --- Chart.js | 6563 +++++++++++++++++++++-------------------- Chart.min.js | 6 +- samples/doughnut.html | 5 - src/Chart.Doughnut.js | 2 +- 4 files changed, 3327 insertions(+), 3249 deletions(-) diff --git a/Chart.js b/Chart.js index acb14e30c2f..5a1408d4fae 100644 --- a/Chart.js +++ b/Chart.js @@ -9,3297 +9,3380 @@ */ -(function(){ - - "use strict"; - - //Declare root variable - window in the browser, global on the server - var root = this, - previous = root.Chart; - - //Occupy the global variable of Chart, and create a simple base class - var Chart = function(context){ - var chart = this; - this.canvas = context.canvas; - - this.ctx = context; - - //Variables global to the chart - var computeDimension = function(element,dimension) - { - if (element['offset'+dimension]) - { - return element['offset'+dimension]; - } - else - { - return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); - } - }; - - var width = this.width = computeDimension(context.canvas,'Width') || context.canvas.width; - var height = this.height = computeDimension(context.canvas,'Height') || context.canvas.height; - - // Firefox requires this to work correctly - context.canvas.width = width; - context.canvas.height = height; - - width = this.width = context.canvas.width; - height = this.height = context.canvas.height; - this.aspectRatio = this.width / this.height; - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. - helpers.retinaScale(this); - - return this; - }; - //Globally expose the defaults to allow for user updating/changing - Chart.defaults = { - global: { - // Boolean - Whether to animate the chart - animation: true, - - // Number - Number of animation steps - animationDuration: 1000, - - // 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, and not show any 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 - 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, - - // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function - customTooltips: false, - - // Array - Array of string names to attach tooltip events - tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], - - // String - Tooltip background colour - tooltipBackgroundColor: "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, - - // String - Template string for single tooltips - tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", - - // String - Template string for single tooltips - multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", - - // String - Colour behind the legend colour block - multiTooltipKeyBackground: '#fff', - - // Function - Will fire on animation progression. - onAnimationProgress: function(){}, - - // Function - Will fire on animation completion. - onAnimationComplete: function(){} - - } - }; - - //Create a dictionary of chart types, to allow for extension of existing types - Chart.types = {}; - - //Global Chart helpers object for utility methods and classes - var helpers = Chart.helpers = {}; - - //-- Basic js utility methods - var each = helpers.each = function(loopable,callback,self){ - var additionalArgs = Array.prototype.slice.call(arguments, 3); - // Check to see if null or undefined firstly. - if (loopable){ - if (loopable.length === +loopable.length){ - var i; - for (i=0; i= 0; i--) { - var currentItem = arrayToSearch[i]; - if (filterCallback(currentItem)){ - return currentItem; - } - } - }, - inherits = helpers.inherits = function(extensions){ - //Basic javascript inheritance based on the model created in Backbone.js - var parent = this; - var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function(){ return parent.apply(this, arguments); }; - - var Surrogate = function(){ this.constructor = ChartElement;}; - Surrogate.prototype = parent.prototype; - ChartElement.prototype = new Surrogate(); - - ChartElement.extend = inherits; - - if (extensions) extend(ChartElement.prototype, extensions); - - ChartElement.__super__ = parent.prototype; - - return ChartElement; - }, - noop = helpers.noop = function(){}, - uid = helpers.uid = (function(){ - var id=0; - return function(){ - return "chart-" + id++; - }; - })(), - warn = helpers.warn = function(str){ - //Method for warning of errors - if (window.console && typeof window.console.warn === "function") console.warn(str); - }, - amd = helpers.amd = (typeof define === 'function' && define.amd), - //-- Math methods - isNumber = helpers.isNumber = function(n){ - return !isNaN(parseFloat(n)) && isFinite(n); - }, - max = helpers.max = function(array){ - return Math.max.apply( Math, array ); - }, - min = helpers.min = function(array){ - return Math.min.apply( Math, array ); - }, - cap = helpers.cap = function(valueToCap,maxValue,minValue){ - if(isNumber(maxValue)) { - if( valueToCap > maxValue ) { - return maxValue; - } - } - else if(isNumber(minValue)){ - if ( valueToCap < minValue ){ - return minValue; - } - } - return valueToCap; - }, - getDecimalPlaces = helpers.getDecimalPlaces = function(num){ - if (num%1!==0 && isNumber(num)){ - var s = num.toString(); - if(s.indexOf("e-") < 0){ - // no exponent, e.g. 0.01 - return s.split(".")[1].length; - } - else if(s.indexOf(".") < 0) { - // no decimal point, e.g. 1e-9 - return parseInt(s.split("e-")[1]); - } - else { - // exponent and decimal point, e.g. 1.23e-9 - var parts = s.split(".")[1].split("e-"); - return parts[0].length + parseInt(parts[1]); - } - } - else { - return 0; - } - }, - toRadians = helpers.radians = function(degrees){ - return degrees * (Math.PI/180); - }, - // Gets the angle from vertical upright to the point about a centre. - getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint){ - var distanceFromXCenter = anglePoint.x - centrePoint.x, - distanceFromYCenter = anglePoint.y - centrePoint.y, - radialDistanceFromCenter = Math.sqrt( distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); - - - var angle = Math.PI * 2 + Math.atan2(distanceFromYCenter, distanceFromXCenter); - - //If the segment is in the top left quadrant, we need to add another rotation to the angle - if (distanceFromXCenter < 0 && distanceFromYCenter < 0){ - angle += Math.PI*2; - } - - return { - angle: angle, - distance: radialDistanceFromCenter - }; - }, - aliasPixel = helpers.aliasPixel = function(pixelWidth){ - return (pixelWidth % 2 === 0) ? 0 : 0.5; - }, - splineCurve = helpers.splineCurve = function(FirstPoint,MiddlePoint,AfterPoint,t){ - //Props to Rob Spencer at scaled innovation for his post on splining between points - //http://scaledinnovation.com/analytics/splines/aboutSplines.html - var d01=Math.sqrt(Math.pow(MiddlePoint.x-FirstPoint.x,2)+Math.pow(MiddlePoint.y-FirstPoint.y,2)), - d12=Math.sqrt(Math.pow(AfterPoint.x-MiddlePoint.x,2)+Math.pow(AfterPoint.y-MiddlePoint.y,2)), - fa=t*d01/(d01+d12),// scaling factor for triangle Ta - fb=t*d12/(d01+d12); - return { - inner : { - x : MiddlePoint.x-fa*(AfterPoint.x-FirstPoint.x), - y : MiddlePoint.y-fa*(AfterPoint.y-FirstPoint.y) - }, - outer : { - x: MiddlePoint.x+fb*(AfterPoint.x-FirstPoint.x), - y : MiddlePoint.y+fb*(AfterPoint.y-FirstPoint.y) - } - }; - }, - calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val){ - return Math.floor(Math.log(val) / Math.LN10); - }, - calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly){ - - //Set a minimum step of two - a point at the top of the graph, and a point at the base - var minSteps = 2, - maxSteps = Math.floor(drawingSize/(textSize * 1.5)), - skipFitting = (minSteps >= maxSteps); - - var maxValue = max(valuesArray), - minValue = min(valuesArray); - - // We need some degree of seperation here to calculate the scales if all the values are the same - // Adding/minusing 0.5 will give us a range of 1. - if (maxValue === minValue){ - maxValue += 0.5; - // So we don't end up with a graph with a negative start value if we've said always start from zero - if (minValue >= 0.5 && !startFromZero){ - minValue -= 0.5; - } - else{ - // Make up a whole number above the values - maxValue += 0.5; - } - } - - var valueRange = Math.abs(maxValue - minValue), - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphRange = graphMax - graphMin, - stepValue = Math.pow(10, rangeOrderOfMagnitude), - numberOfSteps = Math.round(graphRange / stepValue); - - //If we have more space on the graph we'll use it to give more definition to the data - while((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { - if(numberOfSteps > maxSteps){ - stepValue *=2; - numberOfSteps = Math.round(graphRange/stepValue); - // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. - if (numberOfSteps % 1 !== 0){ - skipFitting = true; - } - } - //We can fit in double the amount of scale points on the scale - else{ - //If user has declared ints only, and the step value isn't a decimal - if (integersOnly && rangeOrderOfMagnitude >= 0){ - //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float - if(stepValue/2 % 1 === 0){ - stepValue /=2; - numberOfSteps = Math.round(graphRange/stepValue); - } - //If it would make it a float break out of the loop - else{ - break; - } - } - //If the scale doesn't have to be an int, make the scale more granular anyway. - else{ - stepValue /=2; - numberOfSteps = Math.round(graphRange/stepValue); - } - - } - } - - if (skipFitting){ - numberOfSteps = minSteps; - stepValue = graphRange / numberOfSteps; - } - return { - steps : numberOfSteps, - stepValue : stepValue, - min : graphMin, - max : graphMin + (numberOfSteps * stepValue) - }; - - }, - /* jshint ignore:start */ - // Blows up jshint errors based on the new Function constructor - //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 instanceof Function){ - return templateString(valuesObject); - } - - var cache = {}; - function tmpl(str, data){ - // Figure out if we're getting a template, or if we need to - // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] : - - // Generate a reusable function that will serve as a template - // generator (and which will be cached). - new Function("obj", - "var p=[],print=function(){p.push.apply(p,arguments);};" + - - // Introduce the data as local variables using with(){} - "with(obj){p.push('" + - - // Convert the template into pure JavaScript - str - .replace(/[\r\t\n]/g, " ") - .split("<%").join("\t") - .replace(/((^|%>)[^\t]*)'/g, "$1\r") - .replace(/\t=(.*?)%>/g, "',$1,'") - .split("\t").join("');") - .split("%>").join("p.push('") - .split("\r").join("\\'") + - "');}return p.join('');" - ); - - // Provide some basic currying to the user - return data ? fn( data ) : fn; - } - return tmpl(templateString,valuesObject); - }, - /* jshint ignore:end */ - generateLabels = helpers.generateLabels = function(templateString,numberOfSteps,graphMin,stepValue){ - var labelsArray = new Array(numberOfSteps); - if (templateString){ - each(labelsArray,function(val,index){ - labelsArray[index] = template(templateString,{value: (graphMin + (stepValue*(index+1)))}); - }); - } - return labelsArray; - }, - //--Animation methods - //Easing functions adapted from Robert Penner's easing equations - //http://www.robertpenner.com/easing/ - easingEffects = helpers.easingEffects = { - linear: function (t) { - return t; - }, - easeInQuad: function (t) { - return t * t; - }, - easeOutQuad: function (t) { - return -1 * t * (t - 2); - }, - easeInOutQuad: function (t) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t; - } - return -1 / 2 * ((--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) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t * t; - } - return 1 / 2 * ((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) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t * t * t; - } - return -1 / 2 * ((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) { - if ((t /= 1 / 2) < 1){ - return 1 / 2 * t * t * t * t * t; - } - return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); - }, - easeInExpo: function (t) { - return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); - }, - easeOutExpo: function (t) { - return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); - }, - easeInOutExpo: function (t) { - if (t === 0){ - return 0; - } - if (t === 1){ - return 1; - } - if ((t /= 1 / 2) < 1){ - return 1 / 2 * Math.pow(2, 10 * (t - 1)); - } - return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); - }, - easeInCirc: function (t) { - if (t >= 1){ - return t; - } - return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); - }, - easeOutCirc: function (t) { - return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); - }, - easeInOutCirc: function (t) { - if ((t /= 1 / 2) < 1){ - return -1 / 2 * (Math.sqrt(1 - t * t) - 1); - } - return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); - }, - easeInElastic: function (t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0){ - return 0; - } - if ((t /= 1) == 1){ - return 1; - } - if (!p){ - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else{ - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); - }, - easeOutElastic: function (t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0){ - return 0; - } - if ((t /= 1) == 1){ - return 1; - } - if (!p){ - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else{ - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; - }, - easeInOutElastic: function (t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0){ - return 0; - } - if ((t /= 1 / 2) == 2){ - return 1; - } - if (!p){ - p = 1 * (0.3 * 1.5); - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - if (t < 1){ - return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));} - return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; - }, - easeInBack: function (t) { - var s = 1.70158; - return 1 * (t /= 1) * t * ((s + 1) * t - s); - }, - easeOutBack: function (t) { - var s = 1.70158; - return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); - }, - easeInOutBack: function (t) { - var s = 1.70158; - if ((t /= 1 / 2) < 1){ - return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); - } - return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); - }, - easeInBounce: function (t) { - return 1 - easingEffects.easeOutBounce(1 - t); - }, - easeOutBounce: function (t) { - if ((t /= 1) < (1 / 2.75)) { - return 1 * (7.5625 * t * t); - } else if (t < (2 / 2.75)) { - return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); - } else if (t < (2.5 / 2.75)) { - return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); - } else { - return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); - } - }, - easeInOutBounce: function (t) { - if (t < 1 / 2){ - return easingEffects.easeInBounce(t * 2) * 0.5; - } - return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; - } - }, - //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ - requestAnimFrame = helpers.requestAnimFrame = (function(){ - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - return window.setTimeout(callback, 1000 / 60); - }; - })(), - cancelAnimFrame = helpers.cancelAnimFrame = (function(){ - return window.cancelAnimationFrame || - window.webkitCancelAnimationFrame || - window.mozCancelAnimationFrame || - window.oCancelAnimationFrame || - window.msCancelAnimationFrame || - function(callback) { - return window.clearTimeout(callback, 1000 / 60); - }; - })(), - animationLoop = helpers.animationLoop = function(callback,totalSteps,easingString,onProgress,onComplete,chartInstance){ - - var currentStep = 0, - easingFunction = easingEffects[easingString] || easingEffects.linear; - - var animationFrame = function(){ - currentStep++; - var stepDecimal = currentStep/totalSteps; - var easeDecimal = easingFunction(stepDecimal); - - callback.call(chartInstance,easeDecimal,stepDecimal, currentStep); - onProgress.call(chartInstance,easeDecimal,stepDecimal); - if (currentStep < totalSteps){ - chartInstance.animationFrame = requestAnimFrame(animationFrame); - } else{ - onComplete.apply(chartInstance); - } - }; - requestAnimFrame(animationFrame); - }, - //-- DOM methods - getRelativePosition = helpers.getRelativePosition = function(evt){ - var mouseX, mouseY; - var e = evt.originalEvent || evt, - canvas = evt.currentTarget || evt.srcElement, - boundingRect = canvas.getBoundingClientRect(); - - if (e.touches){ - mouseX = e.touches[0].clientX - boundingRect.left; - mouseY = e.touches[0].clientY - boundingRect.top; - - } - else{ - mouseX = e.clientX - boundingRect.left; - mouseY = e.clientY - boundingRect.top; - } - - return { - x : mouseX, - y : mouseY - }; - - }, - addEvent = helpers.addEvent = function(node,eventType,method){ - if (node.addEventListener){ - node.addEventListener(eventType,method); - } else if (node.attachEvent){ - node.attachEvent("on"+eventType, method); - } else { - node["on"+eventType] = method; - } - }, - removeEvent = helpers.removeEvent = function(node, eventType, handler){ - if (node.removeEventListener){ - node.removeEventListener(eventType, handler, false); - } else if (node.detachEvent){ - node.detachEvent("on"+eventType,handler); - } else{ - node["on" + eventType] = noop; - } - }, - bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler){ - // Create the events object if it's not already present - if (!chartInstance.events) chartInstance.events = {}; - - each(arrayOfEvents,function(eventName){ - chartInstance.events[eventName] = function(){ - handler.apply(chartInstance, arguments); - }; - addEvent(chartInstance.chart.canvas,eventName,chartInstance.events[eventName]); - }); - }, - unbindEvents = helpers.unbindEvents = function (chartInstance, arrayOfEvents) { - each(arrayOfEvents, function(handler,eventName){ - removeEvent(chartInstance.chart.canvas, eventName, handler); - }); - }, - getMaximumWidth = helpers.getMaximumWidth = function(domNode){ - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); - // TODO = check cross browser stuff with this. - return container.clientWidth - padding; - }, - getMaximumHeight = helpers.getMaximumHeight = function(domNode){ - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); - // TODO = check cross browser stuff with this. - return container.clientHeight - padding; - }, - getStyle = helpers.getStyle = function (el, property) { - return el.currentStyle ? - el.currentStyle[property] : - document.defaultView.getComputedStyle(el, null).getPropertyValue(property); - }, - getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support - retinaScale = helpers.retinaScale = function(chart){ - var ctx = chart.ctx, - width = chart.canvas.width, - height = chart.canvas.height; - - if (window.devicePixelRatio) { - ctx.canvas.style.width = width + "px"; - ctx.canvas.style.height = height + "px"; - ctx.canvas.height = height * window.devicePixelRatio; - ctx.canvas.width = width * window.devicePixelRatio; - ctx.scale(window.devicePixelRatio, window.devicePixelRatio); - } - }, - //-- Canvas methods - clear = helpers.clear = function(chart){ - chart.ctx.clearRect(0,0,chart.width,chart.height); - }, - fontString = helpers.fontString = function(pixelSize,fontStyle,fontFamily){ - return fontStyle + " " + pixelSize+"px " + fontFamily; - }, - longestText = helpers.longestText = function(ctx,font,arrayOfStrings){ - ctx.font = font; - var longest = 0; - each(arrayOfStrings,function(string){ - var textWidth = ctx.measureText(string).width; - longest = (textWidth > longest) ? textWidth : longest; - }); - return longest; - }, - drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx,x,y,width,height,radius){ - ctx.beginPath(); - ctx.moveTo(x + radius, y); - ctx.lineTo(x + width - radius, y); - ctx.quadraticCurveTo(x + width, y, x + width, y + radius); - ctx.lineTo(x + width, y + height - radius); - ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); - ctx.lineTo(x + radius, y + height); - ctx.quadraticCurveTo(x, y + height, x, y + height - radius); - ctx.lineTo(x, y + radius); - ctx.quadraticCurveTo(x, y, x + radius, y); - ctx.closePath(); - }, - color = helpers.color = function(color){ - if(!window.Color){ - console.log('Color.js not found!'); - return color; - } - return window.Color(color); - }, - isArray = helpers.isArray = function(obj){ - if (!Array.isArray) { - return Object.prototype.toString.call(arg) === '[object Array]'; - } - return Array.isArray(obj); - }; - - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. - //Destroy method on the chart will remove the instance of the chart from this reference. - Chart.instances = {}; - - Chart.Type = function(data,options,chart){ - this.options = options; - this.chart = chart; - this.id = uid(); - //Add the chart instance to the global namespace - Chart.instances[this.id] = this; - - // Initialize is always called when a chart type is created - // By default it is a no op, but it should be extended - if (options.responsive){ - this.resize(); - } - this.initialize.call(this,data); - }; - - //Core methods that'll be a part of every chart type - extend(Chart.Type.prototype,{ - initialize : function(){return this;}, - clear : function(){ - clear(this.chart); - return this; - }, - stop : function(){ - // Stops any current animation loop occuring - Chart.animationService.cancelAnimation(this); - return this; - }, - resize : function(callback){ - this.stop(); - var canvas = this.chart.canvas, - newWidth = getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); - - canvas.width = this.chart.width = newWidth; - canvas.height = this.chart.height = newHeight; - - retinaScale(this.chart); - - if (typeof callback === "function"){ - callback.apply(this, Array.prototype.slice.call(arguments, 1)); - } - return this; - }, - reflow : noop, - render : function(reflow, customDuration){ - if (reflow){ - this.reflow(); - } - - if (this.options.animation && !reflow){ - var animation = new Chart.Animation(); - animation.numSteps = (customDuration || this.options.animationDuration) / 16.66; //60 fps - animation.easing = this.options.animationEasing; - - // render function - animation.render = function(chartInstance, animationObject) { - var easingFunction = helpers.easingEffects[animationObject.easing]; - var stepDecimal = animationObject.currentStep / animationObject.numSteps; - var easeDecimal = easingFunction(stepDecimal); - - chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); - }; - - // user events - animation.onAnimationProgress = this.options.onAnimationProgress; - animation.onAnimationComplete = this.options.onAnimationComplete; - - Chart.animationService.addAnimation(this, animation, customDuration); - } - else{ - this.draw(); - this.options.onAnimationComplete.call(this); - } - return this; - }, - generateLegend : function(){ - return template(this.options.legendTemplate,this); - }, - 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]; - }, - toBase64Image : function(){ - return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); - } - }); - - Chart.Type.extend = function(extensions){ - - var parent = this; - - var ChartType = function(){ - return parent.apply(this,arguments); - }; - - //Copy the prototype object of the this class - ChartType.prototype = clone(parent.prototype); - //Now overwrite some of the properties in the base class with the new extensions - extend(ChartType.prototype, extensions); - - ChartType.extend = Chart.Type.extend; - - if (extensions.name || parent.prototype.name){ - - var chartName = extensions.name || parent.prototype.name; - //Assign any potential default values of the new chart type - - //If none are defined, we'll use a clone of the chart type this is being extended from. - //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart - //doesn't define some defaults of their own. - - var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; - - Chart.defaults[chartName] = extend(baseDefaults,extensions.defaults); - - Chart.types[chartName] = ChartType; - - //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(data,options){ - var config = merge(Chart.defaults.global, Chart.defaults[chartName], options || {}); - return new ChartType(data,config,this); - }; - } else{ - warn("Name not provided for this chart, so it hasn't been registered"); - } - return parent; - }; - - Chart.Element = function(configuration){ - extend(this,{ - _vm: {}, - }); - extend(this,configuration); - this.initialize.apply(this,arguments); - }; - extend(Chart.Element.prototype,{ - initialize : function(){}, - save: function(){ - this._vm = clone(this); - delete this._vm._vm; - delete this._vm._start; - return this; - }, - pivot: function(){ - if(this._start){ - this._start = clone(this); - helpers.extend(this._start, this._vm); - } - return this; - }, - transition : function(ease){ - if(!this._start){ - this._start = clone(this._vm); - } - - each(this,function(value, key){ - - // Only non-vm properties - if(key[0] === '_' || !this.hasOwnProperty(key)){ - return; - } - - // Init if doesn't exist - if(!this._vm[key]){ - this._vm[key] = value || null; - return; - } - - // No unnecessary computations - if(this[key] === this._vm[key]){ - return; - } - - // Color transitions if possible - if(typeof value === 'string'){ - try{ - var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); - this._vm[key] = color.rgbString(); - } catch(err){ - this._vm[key] = value; - } - } - // Number transitions - else if(typeof value === 'number'){ - this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; - } - // Non-transitionals or strings - else{ - this._vm[key] = value; - } - - },this); - if(ease === 1){ - delete this._start; - } - return this; - }, - tooltipPosition : function(){ - return { - x : this.x, - y : this.y - }; - }, - hasValue: function(){ - return isNumber(this.value); - } - }); - - Chart.Element.extend = inherits; - - - Chart.Point = Chart.Element.extend({ - display: true, - inRange: function(chartX,chartY){ - var hitDetectionRange = this.hitDetectionRadius + this.radius; - return ((Math.pow(chartX-this.x, 2)+Math.pow(chartY-this.y, 2)) < Math.pow(hitDetectionRange,2)); - }, - draw : function(){ - if (this.display){ - var ctx = this.ctx; - ctx.beginPath(); - - ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2); - ctx.closePath(); - - ctx.strokeStyle = this.borderColor; - ctx.lineWidth = this.borderWidth; - - ctx.fillStyle = this.backgroundColor; - - ctx.fill(); - ctx.stroke(); - } - - - //Quick debug for bezier curve splining - //Highlights control points and the line between them. - //Handy for dev - stripped in the min version. - - // ctx.save(); - // ctx.fillStyle = "black"; - // ctx.strokeStyle = "black" - // ctx.beginPath(); - // ctx.arc(this.controlPoints.inner.x,this.controlPoints.inner.y, 2, 0, Math.PI*2); - // ctx.fill(); - - // ctx.beginPath(); - // ctx.arc(this.controlPoints.outer.x,this.controlPoints.outer.y, 2, 0, Math.PI*2); - // ctx.fill(); - - // ctx.moveTo(this.controlPoints.inner.x,this.controlPoints.inner.y); - // ctx.lineTo(this.x, this.y); - // ctx.lineTo(this.controlPoints.outer.x,this.controlPoints.outer.y); - // ctx.stroke(); - - // ctx.restore(); - - - - } - }); - - Chart.Arc = Chart.Element.extend({ - inRange : function(chartX,chartY){ - - var pointRelativePosition = helpers.getAngleFromPoint(this, { - x: chartX, - y: chartY - }); - - //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle), - withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius); - - return (betweenAngles && withinRadius); - //Ensure within the outside of the arc centre, but inside arc outer - }, - tooltipPosition : function(){ - var centreAngle = this.startAngle + ((this.endAngle - this.startAngle) / 2), - rangeFromCentre = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius; - return { - x : this.x + (Math.cos(centreAngle) * rangeFromCentre), - y : this.y + (Math.sin(centreAngle) * rangeFromCentre) - }; - }, - draw : function(animationPercent){ - - var easingDecimal = animationPercent || 1; - - var ctx = this.ctx; - - ctx.beginPath(); - - ctx.arc(this.x, this.y, this.outerRadius, this.startAngle, this.endAngle); - - ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true); - - ctx.closePath(); - ctx.strokeStyle = this.borderColor; - ctx.lineWidth = this.borderWidth; - - ctx.fillStyle = this.backgroundColor; - - ctx.fill(); - ctx.lineJoin = 'bevel'; - - if (this.showBorder){ - ctx.stroke(); - } - } - }); - - Chart.Rectangle = Chart.Element.extend({ - draw : function(){ - - var vm = this._vm; - - var ctx = this.ctx, - halfWidth = vm.width/2, - leftX = vm.x - halfWidth, - rightX = vm.x + halfWidth, - top = vm.base - (vm.base - vm.y), - halfStroke = vm.borderWidth / 2; - - // Canvas doesn't allow us to stroke inside the width so we can - // adjust the sizes to fit if we're setting a stroke on the line - if (vm.borderWidth){ - leftX += halfStroke; - rightX -= halfStroke; - top += halfStroke; - } - - ctx.beginPath(); - - ctx.fillStyle = vm.backgroundColor; - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; - - // It'd be nice to keep this class totally generic to any rectangle - // and simply specify which border to miss out. - ctx.moveTo(leftX, vm.base); - ctx.lineTo(leftX, top); - ctx.lineTo(rightX, top); - ctx.lineTo(rightX, vm.base); - ctx.fill(); - if (vm.borderWidth){ - ctx.stroke(); - } - }, - height : function(){ - var vm = this._vm; - return vm.base - vm.y; - }, - inRange : function(chartX,chartY){ - var vm = this._vm; - if (vm.y < vm.base){ - return (chartX >= vm.x - vm.width/2 && chartX <= vm.x + vm.width/2) && (chartY >= vm.y && chartY <= vm.base); - } else{ - return (chartX >= vm.x - vm.width / 2 && chartX <= vm.x + vm.width / 2) && (chartY >= vm.base && chartY <= vm.y); - } - }, - tooltipPosition : function(){ - var vm = this._vm; - if (vm.y < vm.base){ - return { - x : vm.x, - y : vm.y - }; - } - else{ - return { - x : vm.x, - y : vm.base - }; - } - }, - }); - - Chart.Animation = Chart.Element.extend({ - currentStep: null, // the current animation step - numSteps: 60, // default number of steps - easing: "", // the easing to use for this animation - render: null, // render function used by the animation service - - onAnimationProgress: null, // user specified callback to fire on each step of the animation - onAnimationComplete: null, // user specified callback to fire when the animation finishes - }); - - Chart.Tooltip = Chart.Element.extend({ - initialize : function(){ - var options = this._options; - extend(this, { - opacity:0, - xPadding: options.tooltipXPadding, - yPadding: options.tooltipYPadding, - xOffset: options.tooltipXOffset, - backgroundColor: options.tooltipBackgroundColor, - textColor: options.tooltipFontColor, - _fontFamily: options.tooltipFontFamily, - _fontStyle: options.tooltipFontStyle, - fontSize: options.tooltipFontSize, - titleTextColor: options.tooltipTitleFontColor, - _titleFontFamily: options.tooltipTitleFontFamily, - _titleFontStyle: options.tooltipTitleFontStyle, - titleFontSize: options.tooltipTitleFontSize, - caretHeight: options.tooltipCaretSize, - cornerRadius: options.tooltipCornerRadius, - legendColorBackground : options.multiTooltipKeyBackground, - labels: [], - colors: [], - }); - }, - update: function(){ - - var ctx = this._chart.ctx; - - switch(this._options.hoverMode){ - case 'single': - helpers.extend(this, { - text: template(this._options.tooltipTemplate, this._active), - }); - var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this.tooltip, { - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - }); - break; - - case 'label': - - // Tooltip Content - - var dataArray, - dataIndex; - - var labels = [], - colors = []; - - for (var i = this._data.datasets.length - 1; i >= 0; i--) { - dataArray = this._data.datasets[i].metaData; - dataIndex = indexOf(dataArray, this._active[0]); - if (dataIndex !== -1){ - break; - } - } - - var medianPosition = (function(index) { - // Get all the points at that particular index - var elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this._data.datasets, function(dataset){ - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){ - elements.push(dataCollection[dataIndex]); - } - }); - - helpers.each(elements, function(element) { - xPositions.push(element._vm.x); - yPositions.push(element._vm.y); - - //Include any colour information about the element - labels.push(helpers.template(this._options.multiTooltipTemplate, element)); - colors.push({ - fill: element._vm.backgroundColor, - stroke: element._vm.borderColor - }); - - }, this); - - yMin = min(yPositions); - yMax = max(yPositions); - - xMin = min(xPositions); - xMax = max(xPositions); - - return { - x: (xMin > this._chart.width/2) ? xMin : xMax, - y: (yMin + yMax)/2, - }; - }).call(this, dataIndex); - - // Apply for now - helpers.extend(this, { - x: medianPosition.x, - y: medianPosition.y, - labels: labels, - title: this._active.length ? this._active[0].label : '', - legendColors: colors, - legendBackgroundColor : this._options.multiTooltipKeyBackground, - }); - - - // Calculate Appearance Tweaks - - this.height = (labels.length * this.fontSize) + ((labels.length-1) * (this.fontSize/2)) + (this.yPadding*2) + this.titleFontSize *1.5; - - var titleWidth = ctx.measureText(this.title).width, - //Label has a legend square as well so account for this. - labelWidth = longestText(ctx,this.font,labels) + this.fontSize + 3, - longestTextWidth = max([labelWidth,titleWidth]); - - this.width = longestTextWidth + (this.xPadding*2); - - - var halfHeight = this.height/2; - - //Check to ensure the height will fit on the canvas - if (this.y - halfHeight < 0 ){ - this.y = halfHeight; - } else if (this.y + halfHeight > this._chart.height){ - this.y = this._chart.height - halfHeight; - } - - //Decide whether to align left or right based on position on canvas - if (this.x > this._chart.width/2){ - this.x -= this.xOffset + this.width; - } else { - this.x += this.xOffset; - } - break; - } - - return this; - }, - draw : function(){ - - var ctx = this._chart.ctx; - var vm = this._vm; - - switch(this._options.hoverMode){ - case 'single': - - ctx.font = fontString(vm.fontSize,vm._fontStyle,vm._fontFamily); - - vm.xAlign = "center"; - vm.yAlign = "above"; - - //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding = 2; - - var tooltipWidth = ctx.measureText(vm.text).width + 2*vm.xPadding, - tooltipRectHeight = vm.fontSize + 2*vm.yPadding, - tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - - if (vm.x + tooltipWidth/2 >this._chart.width){ - vm.xAlign = "left"; - } else if (vm.x - tooltipWidth/2 < 0){ - vm.xAlign = "right"; - } - - if (vm.y - tooltipHeight < 0){ - vm.yAlign = "below"; - } - - var tooltipX = vm.x - tooltipWidth/2, - tooltipY = vm.y - tooltipHeight; - - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - - // Custom Tooltips - if(this._custom){ - this._custom(this._vm); - } - else{ - switch(vm.yAlign){ - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x,vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } - - switch(vm.xAlign){ - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } - - drawRoundedRectangle(ctx,tooltipX,tooltipY,tooltipWidth,tooltipRectHeight,vm.cornerRadius); - - ctx.fill(); - - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth/2, tooltipY + tooltipRectHeight/2); - - } - break; - case 'label': - - drawRoundedRectangle(ctx, vm.x, vm.y - vm.height/2, vm.width, vm.height, vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - ctx.fill(); - ctx.closePath(); - - ctx.textAlign = "left"; - ctx.textBaseline = "middle"; - ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); - ctx.font = fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); - ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); - - ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - helpers.each(vm.labels,function(label,index){ - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.fillText(label,vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); - - //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) - //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); - //Instead we'll make a white filled block to put the legendColour palette over. - - ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); - - ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); - - - },this); - break; - } - }, - getLineHeight : function(index){ - var baseLineHeight = this._vm.y - (this._vm.height/2) + this._vm.yPadding, - afterTitleIndex = index-1; - - //If the index is zero, we're getting the title - if (index === 0){ - return baseLineHeight + this._vm.titleFontSize/2; - } else{ - return baseLineHeight + ((this._vm.fontSize*1.5*afterTitleIndex) + this._vm.fontSize/2) + this._vm.titleFontSize * 1.5; - } - - }, - }); - - Chart.Scale = Chart.Element.extend({ - initialize : function(){ - this.fit(); - }, - buildYLabels : function(){ - this.yLabels = []; - - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); - - 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) + 10 : 0; - }, - addXLabel : function(label){ - this.xLabels.push(label); - this.valuesCount++; - this.fit(); - }, - removeXLabel : function(){ - this.xLabels.shift(); - this.valuesCount--; - this.fit(); - }, - // Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use - fit: function(){ - // First we need the width of the yLabels, assuming the xLabels aren't rotated - - // To do that we need the base line at the top and base of the chart, assuming there is no x label rotation - this.startPoint = (this.display) ? this.fontSize : 0; - this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels - - // Apply padding settings to the start and end point. - this.startPoint += this.padding; - this.endPoint -= this.padding; - - // Cache the starting endpoint, excluding the space for x labels - var cachedEndPoint = this.endPoint; - - // Cache the starting height, so can determine if we need to recalculate the scale yAxis - var cachedHeight = this.endPoint - this.startPoint, - cachedYLabelWidth; - - // Build the current yLabels so we have an idea of what size they'll be to start - /* - * This sets what is returned from calculateScaleRange as static properties of this class: - * - this.steps; - this.stepValue; - this.min; - this.max; - * - */ - this.calculateYRange(cachedHeight); - - // With these properties set we can now build the array of yLabels - // and also the width of the largest yLabel - this.buildYLabels(); - - this.calculateXLabelRotation(); - - while((cachedHeight > this.endPoint - this.startPoint)){ - cachedHeight = this.endPoint - this.startPoint; - cachedYLabelWidth = this.yLabelWidth; - - this.calculateYRange(cachedHeight); - this.buildYLabels(); - - // Only go through the xLabel loop again if the yLabel width has changed - if (cachedYLabelWidth < this.yLabelWidth){ - this.endPoint = cachedEndPoint; - this.calculateXLabelRotation(); - } - } - - }, - calculateXLabelRotation : function(){ - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - - this.ctx.font = this.font; - - var firstWidth = this.ctx.measureText(this.xLabels[0]).width, - lastWidth = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width, - firstRotated, - lastRotated; - - - this.xScalePaddingRight = lastWidth/2 + 3; - this.xScalePaddingLeft = (firstWidth/2 > this.yLabelWidth) ? firstWidth/2 : this.yLabelWidth; - - this.xLabelRotation = 0; - if (this.display){ - var originalLabelWidth = longestText(this.ctx,this.font,this.xLabels), - cosRotation, - firstRotatedWidth; - this.xLabelWidth = originalLabelWidth; - //Allow 3 pixels x2 padding either side for label readability - var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; - - //Max label rotate should be 90 - also act as a loop counter - while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)){ - cosRotation = Math.cos(toRadians(this.xLabelRotation)); - - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; - - // We're right aligning the text now. - if (firstRotated + this.fontSize / 2 > this.yLabelWidth){ - this.xScalePaddingLeft = firstRotated + this.fontSize / 2; - } - this.xScalePaddingRight = this.fontSize/2; - - - this.xLabelRotation++; - this.xLabelWidth = cosRotation * originalLabelWidth; - - } - if (this.xLabelRotation > 0){ - this.endPoint -= Math.sin(toRadians(this.xLabelRotation))*originalLabelWidth + 3; - } - } - else{ - this.xLabelWidth = 0; - this.xScalePaddingRight = this.padding; - this.xScalePaddingLeft = this.padding; - } - - }, - // Needs to be overidden in each Chart type - // Otherwise we need to pass all the data into the scale class - calculateYRange: noop, - drawingArea: function(){ - return this.startPoint - this.endPoint; - }, - calculateY : function(value){ - var scalingFactor = this.drawingArea() / (this.min - this.max); - return this.endPoint - (scalingFactor * (value - this.min)); - }, - calculateX : function(index){ - var isRotated = (this.xLabelRotation > 0), - // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding, - innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight), - valueWidth = innerWidth/Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1), - valueOffset = (valueWidth * index) + this.xScalePaddingLeft; - - if (this.offsetGridLines){ - valueOffset += (valueWidth/2); - } - - return Math.round(valueOffset); - }, - update : function(newProps){ - helpers.extend(this, newProps); - this.fit(); - }, - draw : function(){ - var ctx = this.ctx, - yLabelGap = (this.endPoint - this.startPoint) / this.steps, - xStart = Math.round(this.xScalePaddingLeft); - if (this.display){ - ctx.fillStyle = this.textColor; - ctx.font = this.font; - each(this.yLabels,function(labelString,index){ - var yLabelCenter = this.endPoint - (yLabelGap * index), - linePositionY = Math.round(yLabelCenter), - drawHorizontalLine = this.showHorizontalLines; - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - if (this.showLabels){ - ctx.fillText(labelString,xStart - 10,yLabelCenter); - } - - // This is X axis, so draw it - if (index === 0 && !drawHorizontalLine){ - drawHorizontalLine = true; - } - - if (drawHorizontalLine){ - ctx.beginPath(); - } - - if (index > 0){ - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } - - linePositionY += helpers.aliasPixel(ctx.lineWidth); - - if(drawHorizontalLine){ - ctx.moveTo(xStart, linePositionY); - ctx.lineTo(this.width, linePositionY); - ctx.stroke(); - ctx.closePath(); - } - - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - ctx.beginPath(); - ctx.moveTo(xStart - 5, linePositionY); - ctx.lineTo(xStart, linePositionY); - ctx.stroke(); - ctx.closePath(); - - },this); - - each(this.xLabels,function(label,index){ - var xPos = this.calculateX(index) + aliasPixel(this.lineWidth), - // Check to see if line/bar here and decide where to place the line - linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth), - isRotated = (this.xLabelRotation > 0), - drawVerticalLine = this.showVerticalLines; - - // This is Y axis, so draw it - if (index === 0 && !drawVerticalLine){ - drawVerticalLine = true; - } - - if (drawVerticalLine){ - ctx.beginPath(); - } - - if (index > 0){ - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } - - if (drawVerticalLine){ - ctx.moveTo(linePos,this.endPoint); - ctx.lineTo(linePos,this.startPoint - 3); - ctx.stroke(); - ctx.closePath(); - } - - - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - - - // Small lines at the bottom of the base grid line - ctx.beginPath(); - ctx.moveTo(linePos,this.endPoint); - ctx.lineTo(linePos,this.endPoint + 5); - ctx.stroke(); - ctx.closePath(); - - ctx.save(); - ctx.translate(xPos,(isRotated) ? this.endPoint + 12 : this.endPoint + 8); - ctx.rotate(toRadians(this.xLabelRotation)*-1); - ctx.font = this.font; - ctx.textAlign = (isRotated) ? "right" : "center"; - ctx.textBaseline = (isRotated) ? "middle" : "top"; - ctx.fillText(label, 0, 0); - ctx.restore(); - },this); - - } - } - - }); - - Chart.RadialScale = Chart.Element.extend({ - initialize: function(){ - this.size = min([this.height, this.width]); - this.drawingArea = (this.display) ? (this.size/2) - (this.fontSize/2 + this.backdropPaddingY) : (this.size/2); - }, - calculateCenterOffset: function(value){ - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); - - return (value - this.min) * scalingFactor; - }, - update : function(){ - if (!this.lineArc){ - this.setScaleSize(); - } else { - this.drawingArea = (this.display) ? (this.size/2) - (this.fontSize/2 + this.backdropPaddingY) : (this.size/2); - } - this.buildYLabels(); - }, - buildYLabels: function(){ - this.yLabels = []; - - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); - - for (var i=0; i<=this.steps; i++){ - this.yLabels.push(template(this.templateString,{value:(this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces)})); - } - }, - getCircumference : function(){ - return ((Math.PI*2) / this.valuesCount); - }, - setScaleSize: function(){ - /* - * Right, this is really confusing and there is a lot of maths going on here - * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 - * - * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif - * - * Solution: - * - * We assume the radius of the polygon is half the size of the canvas at first - * at each index we check if the text overlaps. - * - * Where it does, we store that angle and that index. - * - * After finding the largest index and angle we calculate how much we need to remove - * from the shape radius to move the point inwards by that x. - * - * We average the left and right distances to get the maximum shape radius that can fit in the box - * along with labels. - * - * Once we have that, we can find the centre point for the chart, by taking the x text protrusion - * on each side, removing that from the size, halving it and adding the left x protrusion width. - * - * This will mean we have a shape fitted to the canvas, as large as it can be with the labels - * and position it in the most space efficient manner - * - * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - */ - - - // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points - var largestPossibleRadius = min([(this.height/2 - this.pointLabelFontSize - 5), this.width/2]), - pointPosition, - i, - textWidth, - halfTextWidth, - furthestRight = this.width, - furthestRightIndex, - furthestRightAngle, - furthestLeft = 0, - furthestLeftIndex, - furthestLeftAngle, - xProtrusionLeft, - xProtrusionRight, - radiusReductionRight, - radiusReductionLeft, - maxWidthRadius; - this.ctx.font = fontString(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily); - for (i=0;i furthestRight) { - furthestRight = pointPosition.x + halfTextWidth; - furthestRightIndex = i; - } - if (pointPosition.x - halfTextWidth < furthestLeft) { - furthestLeft = pointPosition.x - halfTextWidth; - furthestLeftIndex = i; - } - } - else if (i < this.valuesCount/2) { - // Less than half the values means we'll left align the text - if (pointPosition.x + textWidth > furthestRight) { - furthestRight = pointPosition.x + textWidth; - furthestRightIndex = i; - } - } - else if (i > this.valuesCount/2){ - // More than half the values means we'll right align the text - if (pointPosition.x - textWidth < furthestLeft) { - furthestLeft = pointPosition.x - textWidth; - furthestLeftIndex = i; - } - } - } - - xProtrusionLeft = furthestLeft; - - xProtrusionRight = Math.ceil(furthestRight - this.width); - - furthestRightAngle = this.getIndexAngle(furthestRightIndex); - - furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); - - radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI/2); - - radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI/2); - - // Ensure we actually need to reduce the size of the chart - radiusReductionRight = (isNumber(radiusReductionRight)) ? radiusReductionRight : 0; - radiusReductionLeft = (isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; - - this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight)/2; - - //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) - this.setCenterPoint(radiusReductionLeft, radiusReductionRight); - - }, - setCenterPoint: function(leftMovement, rightMovement){ - - var maxRight = this.width - rightMovement - this.drawingArea, - maxLeft = leftMovement + this.drawingArea; - - this.xCenter = (maxLeft + maxRight)/2; - // Always vertically in the centre as the text height doesn't change - this.yCenter = (this.height/2); - }, - - getIndexAngle : function(index){ - var angleMultiplier = (Math.PI * 2) / this.valuesCount; - // Start from the top instead of right, so remove a quarter of the circle - - return index * angleMultiplier - (Math.PI/2); - }, - getPointPosition : function(index, distanceFromCenter){ - var thisAngle = this.getIndexAngle(index); - return { - x : (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, - y : (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter - }; - }, - draw: function(){ - if (this.display){ - var ctx = this.ctx; - each(this.yLabels, function(label, index){ - // Don't draw a centre value - if (index > 0){ - var yCenterOffset = index * (this.drawingArea/this.steps), - yHeight = this.yCenter - yCenterOffset, - pointPosition; - - // Draw circular lines around the scale - if (this.lineWidth > 0){ - ctx.strokeStyle = this.lineColor; - ctx.lineWidth = this.lineWidth; - - if(this.lineArc){ - ctx.beginPath(); - ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI*2); - ctx.closePath(); - ctx.stroke(); - } else{ - ctx.beginPath(); - for (var i=0;i= 0; i--) { - if (this.angleLineWidth > 0){ - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); - ctx.beginPath(); - ctx.moveTo(this.xCenter, this.yCenter); - ctx.lineTo(outerPosition.x, outerPosition.y); - ctx.stroke(); - ctx.closePath(); - } - // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); - ctx.font = fontString(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily); - ctx.fillStyle = this.pointLabelFontColor; - - var labelsCount = this.labels.length, - halfLabelsCount = this.labels.length/2, - quarterLabelsCount = halfLabelsCount/2, - upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), - exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); - if (i === 0){ - ctx.textAlign = 'center'; - } else if(i === halfLabelsCount){ - ctx.textAlign = 'center'; - } else if (i < halfLabelsCount){ - ctx.textAlign = 'left'; - } else { - ctx.textAlign = 'right'; - } - - // Set the correct text baseline based on outer positioning - if (exactQuarter){ - ctx.textBaseline = 'middle'; - } else if (upperHalf){ - ctx.textBaseline = 'bottom'; - } else { - ctx.textBaseline = 'top'; - } - - ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); - } - } - } - } - }); - - Chart.animationService = { - frameDuration: 17, - animations: [], - dropFrames: 0, - addAnimation: function(chartInstance, animationObject, customDuration) { - - if(!customDuration){ - chartInstance.animating = true; - } - - for (var index = 0; index < this.animations.length; ++ index){ - if (this.animations[index].chartInstance === chartInstance){ - // replacing an in progress animation - this.animations[index].animationObject = animationObject; - return; - } - } - - this.animations.push({ - chartInstance: chartInstance, - animationObject: animationObject - }); - - // If there are no animations queued, manually kickstart a digest, for lack of a better word - if (this.animations.length == 1) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - }, - // Cancel the animation for a given chart instance - cancelAnimation: function(chartInstance) { - var index = helpers.findNextWhere(this.animations, function(animationWrapper) { - return animationWrapper.chartInstance === chartInstance; - }); - - if (index){ - this.animations.splice(index, 1); - chartInstance.animating = false; - } - }, - // calls startDigest with the proper context - digestWrapper: function() { - Chart.animationService.startDigest.call(Chart.animationService); - }, - startDigest: function() { - - var startTime = Date.now(); - var framesToDrop = 0; - - if(this.dropFrames > 1){ - framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; - } - - for (var i = 0; i < this.animations.length; i++) { - - if (this.animations[i].animationObject.currentStep === null){ - this.animations[i].animationObject.currentStep = 0; - } - - this.animations[i].animationObject.currentStep += 1 + framesToDrop; - if(this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps){ - this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; - } - - this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); - - if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps){ - // executed the last frame. Remove the animation. - this.animations[i].chartInstance.animating = false; - this.animations.splice(i, 1); - // Keep the index in place to offset the splice - i--; - } - } - - var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; - - if(frameDelay > 1){ - this.dropFrames += frameDelay; - } - - // Do we have more stuff to animate? - if (this.animations.length > 0){ - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - } - }; - - // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function(){ - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function(){ - clearTimeout(timeout); - timeout = setTimeout(function(){ - each(Chart.instances,function(instance){ - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive){ - instance.resize(instance.render, true); - } - }); - }, 50); - }; - })()); - - - if (amd) { - define(function(){ - return Chart; - }); - } else if (typeof module === 'object' && module.exports) { - module.exports = Chart; - } - - root.Chart = Chart; - - Chart.noConflict = function(){ - root.Chart = previous; - return Chart; - }; - -}).call(this); - -(function(){ - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - - var defaultConfig = { - //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 - Whether to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, - - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, - - //Number - Pixel width of the bar border - barBorderWidth : 2, - - //Number - Spacing between each of the X value sets - barValueSpacing : 5, - - //Number - Spacing between data sets within X values - barDatasetSpacing : 1, - - //String / Boolean - Hover mode for events. - hoverMode : 'single', // 'label', 'dataset', 'false' - - //Function - Custom hover handler - onHover : null, - - //Function - Custom hover handler - hoverAnimationDuration : 400, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - - }; - - - Chart.Type.extend({ - name: "Bar", - defaults : defaultConfig, - initialize: function(data){ - - // Save data as a source for updating of values & methods - this.data = data; - - //Expose options as a scope variable here so we can access it in the ScaleClass - var options = this.options; - - this.ScaleClass = Chart.Scale.extend({ - offsetGridLines : true, - calculateBarX : function(datasetCount, datasetIndex, elementIndex){ - //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.calculateX(elementIndex) - (xWidth/2), - barWidth = this.calculateBarWidth(datasetCount); - - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth/2; - }, - calculateBaseWidth : function(){ - return (this.calculateX(1) - this.calculateX(0)) - (2*options.barValueSpacing); - }, - calculateBarWidth : function(datasetCount){ - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); - - return (baseWidth / datasetCount); - } - }); - - // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); - - //Declare the extension of the default point, to cater for the options passed in to the constructor - this.BarClass = Chart.Rectangle.extend({ - ctx : this.chart.ctx, - }); - - // Build Scale - this.buildScale(data.labels); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets,function(dataset,datasetIndex){ - dataset.metaData = []; - helpers.each(dataset.data,function(dataPoint,index){ - dataset.metaData.push(new this.BarClass()); - },this); - },this); - - // Set defaults for bars - this.eachBars(function(bar, index, datasetIndex){ - helpers.extend(bar, { - width : this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.calculateBarBase(), - _datasetIndex: datasetIndex, - _index: index, - }); - // Copy to view model - bar.save(); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Update the chart with the latest data. - this.update(); - }, - onHover: function(e){ - - - // If exiting chart - if(e.type == 'mouseout'){ - return false; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function(){ - switch(this.options.hoverMode){ - case 'single': - return this.getBarAtEvent(e); - case 'label': - return this.getBarsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if(this.options.onHover){ - this.options.onHover.call(this, this.active); - } - - // Remove styling for last active (even if it may still be active) - if(this.lastActive){ - switch(this.options.hoverMode){ - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; - this.lastActive[0].borderWidth = 0; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; - this.lastActive[i].borderWidth = 0; - } - break; - case 'dataset': - break; - default: - // do nothing - } - } - - // Built in hover actions - if(this.active.length && this.options.hoverMode){ - switch(this.options.hoverMode){ - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); - } - break; - case 'dataset': - break; - default: - // do nothing - } - } - - - // Built in Tooltips - if(this.options.showTooltips){ - - // The usual updates - this.tooltip.initialize(); - - // Active - if(this.active.length){ - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, - }); - - this.tooltip.update(); - } - else{ - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); - } - } - - - if(!this.animating){ - - // If entering - if(!this.lastActive.length && this.active.length){ - console.log('entering'); - this.tooltip.pivot(); - this.stop(); - this.render(false, this.options.hoverAnimationDuration); - } - - var changed; - - helpers.each(this.active, function(element, index){ - if (element !== this.lastActive[index]){ - changed = true; - } - }, this); - - // If different element - if(this.lastActive.length && this.active.length && changed){ - console.log('changing'); - this.tooltip.pivot(); - this.stop(); - this.render(false, this.options.hoverAnimationDuration); - } - - // if Leaving - if (this.lastActive.length && !this.active.length){ - console.log('leaving'); - this.tooltip.pivot(); - this.stop(); - this.render(false, this.options.hoverAnimationDuration); - } - - } - - // Remember Last Active - - this.lastActive = this.active; - }, - // Calculate the base point for the bar. - // If the scale has a 0 point, use that as the base - // If the scale min and max are both positive, use the bottom as a base - // If the scale min and max are both negative, use the top as a base - calculateBarBase: function() { - var base = this.scale.endPoint; - - if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) - { - base = this.scale.calculateY(0); - base += this.options.scaleGridLineWidth; - } - else if (this.scale.min < 0 && this.scale.max < 0) - { - // All values are negative. Use the top as the base - base = this.scale.startPoint; - } - - return base; - }, - update : function(){ - - this.scale.update(); - - this.eachBars(function(bar, index, datasetIndex){ - helpers.extend(bar, { - width : this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), - value : this.data.datasets[datasetIndex].data[index], - label : this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - borderColor : this.data.datasets[datasetIndex].borderColor, - borderWidth : this.data.datasets[datasetIndex].borderWidth, - backgroundColor : this.data.datasets[datasetIndex].backgroundColor, - _datasetIndex: datasetIndex, - _index: index, - _start: undefined - }); - }, this); - - this.render(); - }, - eachBars : function(callback){ - helpers.each(this.data.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.metaData, callback, this, datasetIndex); - },this); - }, - eachValue : function(callback){ - helpers.each(this.data.datasets,function(dataset, datasetIndex){ - helpers.each(dataset.data, callback, this, datasetIndex); - },this); - }, - getBarsAtEvent : function(e){ - var barsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset){ - barsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x,eventPosition.y)){ - helpers.each(this.data.datasets, datasetIterator); - } - } - } - - return barsArray.length ? barsArray : []; - }, - // Get the single bar that was clicked on - // @return : An object containing the dataset index and bar index of the matching bar. Also contains the rectangle that was drawn - getBarAtEvent : function(e) { - var bar = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - bar.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return bar; - } - } - } - - return []; - }, - buildScale : function(labels){ - var self = this; - - var dataTotal = function(){ - var values = []; - self.eachValue(function(value){ - values.push(value); - }); - return values; - }; - - var scaleOptions = { - 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 : labels.length, - beginAtZero : this.options.scaleBeginAtZero, - integersOnly : this.options.scaleIntegersOnly, - calculateYRange: function(currentHeight){ - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); - }, - xLabels : labels, - font : helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth : this.options.scaleLineWidth, - lineColor : this.options.scaleLineColor, - showHorizontalLines : this.options.scaleShowHorizontalLines, - showVerticalLines : this.options.scaleShowVerticalLines, - 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.borderWidth, - showLabels : this.options.scaleShowLabels, - display : this.options.showScale - }; - - if (this.options.scaleOverride){ - helpers.extend(scaleOptions, { - calculateYRange: helpers.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(scaleOptions); - }, - // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function - /*reflow : function(){ - helpers.extend(this.BarClass.prototype,{ - y: this.calculateBarBase(), // so that we animate from the baseline - base : this.calculateBarBase() - }); - var newScaleProps = helpers.extend({ - height : this.chart.height, - width : this.chart.width - }); - this.scale.update(newScaleProps); - },*/ - draw : function(ease){ - - var easingDecimal = ease || 1; - this.clear(); - - this.scale.draw(easingDecimal); - - //Draw all the bars for each dataset - this.eachBars(function(bar, index, datasetIndex){ - if (bar.hasValue()){ - // Update the bar basepoint - bar.base = this.calculateBarBase(); - //Transition - bar.transition(easingDecimal).draw(); - } - }, this); - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - } - }); - - -}).call(this); - -(function(){ - "use strict"; - - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; - - var defaultConfig = { - //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, - - //The percentage of the chart that we cut out of the middle. - percentageInnerCutout : 50, - - //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, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " - - }; - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults : defaultConfig, - //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){ - - // Save data as a source for updating of values & methods - this.data = data; - - //Declare segments as a static property to prevent inheriting across the Chart type prototype - this.segments = []; - this.outerRadius = (helpers.min([this.chart.width,this.chart.height]) - this.options.segmentStrokeWidth/2)/2; - - this.SegmentArc = Chart.Arc.extend({ - ctx : this.chart.ctx, - x : this.chart.width/2, - y : this.chart.height/2 - }); - - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ - var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : []; - - helpers.each(this.segments,function(segment){ - segment.restore(["fillColor"]); - }); - helpers.each(activeSegments,function(activeSegment){ - activeSegment.fillColor = activeSegment.highlightColor; - }); - this.showTooltip(activeSegments); - }); - } - this.calculateTotal(data); - - helpers.each(data,function(datapoint, index){ - if (!datapoint.color) { - datapoint.color = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; - } - this.addData(datapoint, index, true); - },this); - - this.render(); - }, - getSegmentsAtEvent : function(e){ - var segmentsArray = []; - - var location = helpers.getRelativePosition(e); - - helpers.each(this.segments,function(segment){ - if (segment.inRange(location.x,location.y)) segmentsArray.push(segment); - },this); - return segmentsArray; - }, - addData : function(segment, atIndex, silent){ - var index = atIndex || this.segments.length; - this.segments.splice(index, 0, new this.SegmentArc({ - value : segment.value, - outerRadius : (this.options.animateScale) ? 0 : this.outerRadius, - innerRadius : (this.options.animateScale) ? 0 : (this.outerRadius/100) * this.options.percentageInnerCutout, - fillColor : segment.color, - highlightColor : segment.highlight || segment.color, - showStroke : this.options.segmentShowStroke, - strokeWidth : this.options.segmentStrokeWidth, - strokeColor : this.options.segmentStrokeColor, - startAngle : Math.PI * 1.5, - circumference : (this.options.animateRotate) ? 0 : this.calculateCircumference(segment.value), - label : segment.label - })); - if (!silent){ - this.reflow(); - this.update(); - } - }, - calculateCircumference : function(value) { - if ( this.total > 0 ) { - return (Math.PI*2)*(value / this.total); - } else { - return 0; - } - }, - calculateTotal : function(data){ - this.total = 0; - helpers.each(data,function(segment){ - this.total += Math.abs(segment.value); - },this); - }, - update : function(){ - - // Map new data to data points - if(this.data.length == this.segments.length){ - helpers.each(this.data, function(segment, i){ - helpers.extend(this.segments[i], { - value : segment.value, - fillColor : segment.color, - highlightColor : segment.highlight || segment.color, - showStroke : this.options.segmentShowStroke, - strokeWidth : this.options.segmentStrokeWidth, - strokeColor : this.options.segmentStrokeColor, - label : segment.label - }); - }, this); - } else{ - // Data size changed without properly inserting, just redraw the chart - this.initialize(this.data); - } - - this.calculateTotal(this.segments); - - // Reset any highlight colours before updating. - helpers.each(this.activeElements, function(activeElement){ - activeElement.restore(['fillColor']); - }); - - helpers.each(this.segments,function(segment){ - segment.save(); - }); - this.render(); - }, - - removeData: function(atIndex){ - var indexToDelete = (helpers.isNumber(atIndex)) ? atIndex : this.segments.length-1; - this.segments.splice(indexToDelete, 1); - this.reflow(); - this.update(); - }, - - reflow : function(){ - helpers.extend(this.SegmentArc.prototype,{ - x : this.chart.width/2, - y : this.chart.height/2 - }); - this.outerRadius = (helpers.min([this.chart.width,this.chart.height]) - this.options.segmentStrokeWidth/2)/2; - helpers.each(this.segments, function(segment){ - segment.update({ - outerRadius : this.outerRadius, - innerRadius : (this.outerRadius/100) * this.options.percentageInnerCutout - }); - }, this); - }, - draw : function(easeDecimal){ - var animDecimal = (easeDecimal) ? easeDecimal : 1; - this.clear(); - helpers.each(this.segments,function(segment,index){ - segment.transition({ - circumference : this.calculateCircumference(segment.value), - outerRadius : this.outerRadius, - innerRadius : (this.outerRadius/100) * this.options.percentageInnerCutout - },animDecimal); - - segment.endAngle = segment.startAngle + segment.circumference; - - segment.draw(); - if (index === 0){ - segment.startAngle = Math.PI * 1.5; - } - //Check to see if it's the last segment, if not get the next and update the start angle - if (index < this.segments.length-1){ - this.segments[index+1].startAngle = segment.endAngle; - } - },this); - - } - }); - - Chart.types.Doughnut.extend({ - name : "Pie", - defaults : helpers.merge(defaultConfig,{percentageInnerCutout : 0}) - }); - -}).call(this); - -(function(){ - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - - ///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 to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, +(function() { - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, + "use strict"; - //Boolean - Whether the line is curved between points - bezierCurve : true, + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart; - //Number - Tension of the bezier curve between points - bezierCurveTension : 0.4, + //Occupy the global variable of Chart, and create a simple base class + var Chart = function(context) { + var chart = this; + this.canvas = context.canvas; - //Boolean - Whether to show a dot for each point - pointDot : true, + this.ctx = context; - //Number - Radius of each point dot in pixels - pointDotRadius : 4, + //Variables global to the chart + var computeDimension = function(element, dimension) { + if (element['offset' + dimension]) { + return element['offset' + dimension]; + } else { + return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); + } + }; - //Number - Pixel width of point dot stroke - pointDotStrokeWidth : 1, + var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; + var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHitDetectionRadius : 20, + // Firefox requires this to work correctly + context.canvas.width = width; + context.canvas.height = height; - //Boolean - Whether to show a stroke for datasets - datasetStroke : true, + width = this.width = context.canvas.width; + height = this.height = context.canvas.height; + this.aspectRatio = this.width / this.height; + //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. + helpers.retinaScale(this); - //Number - Pixel width of dataset stroke - datasetStrokeWidth : 2, + return this; + }; + //Globally expose the defaults to allow for user updating/changing + Chart.defaults = { + global: { + // Boolean - Whether to animate the chart + animation: true, - //Boolean - Whether to fill the dataset with a colour - datasetFill : true, + // Number - Number of animation steps + animationDuration: 1000, - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - - //Boolean - Whether to horizontally center the label and point dot inside the grid - offsetGridLines : false - - }; - - - Chart.Type.extend({ - name: "Line", - defaults : defaultConfig, - initialize: function(data){ - // Save data as a source for updating of values & methods - this.data = data; + // String - Animation easing effect + animationEasing: "easeOutQuart", - //Declare the extension of the default point, to cater for the options passed in to the constructor - this.PointClass = Chart.Point.extend({ - offsetGridLines : this.options.offsetGridLines, - strokeWidth : this.options.pointDotStrokeWidth, - radius : this.options.pointDotRadius, - display: this.options.pointDot, - hitDetectionRadius : this.options.pointHitDetectionRadius, - ctx : this.chart.ctx, - inRange : function(mouseX){ - return (Math.pow(mouseX-this.x, 2) < Math.pow(this.radius + this.hitDetectionRadius,2)); - } - }); + // Boolean - If we should show the scale at all + showScale: true, - this.datasets = []; + // Boolean - If we want to override with a hard coded scale + scaleOverride: false, - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ - var activePoints = (evt.type !== 'mouseout') ? this.getPointsAtEvent(evt) : []; - this.eachPoints(function(point){ - point.restore(['fillColor', 'strokeColor']); - }); - helpers.each(activePoints, function(activePoint){ - activePoint.fillColor = activePoint.highlightFill; - activePoint.strokeColor = activePoint.highlightStroke; - }); - this.showTooltip(activePoints); - }); - } + // ** 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, - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(data.datasets,function(dataset){ + // String - Colour of the scale line + scaleLineColor: "rgba(0,0,0,.1)", - var datasetObject = { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - pointColor : dataset.pointColor, - pointStrokeColor : dataset.pointStrokeColor, - points : [] - }; + // Number - Pixel width of the scale line + scaleLineWidth: 1, - this.datasets.push(datasetObject); + // Boolean - Whether to show labels on the scale + scaleShowLabels: true, + // Interpolated JS string - can access value + scaleLabel: "<%=value%>", - helpers.each(dataset.data,function(dataPoint,index){ - //Add a new point for each piece of data, passing any required data to draw. - datasetObject.points.push(new this.PointClass({ - value : dataPoint, - label : data.labels[index], - datasetLabel: dataset.label, - strokeColor : dataset.pointStrokeColor, - fillColor : dataset.pointColor, - highlightFill : dataset.pointHighlightFill || dataset.pointColor, - highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor - })); - },this); + // Boolean - Whether the scale should stick to integers, and not show any floats even if drawing space is there + scaleIntegersOnly: true, - this.buildScale(data.labels); + // 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", - this.eachPoints(function(point, index){ - helpers.extend(point, { - x: this.scale.calculateX(index), - y: this.scale.endPoint - }); - point.save(); - }, this); + // Number - Scale label font size in pixels + scaleFontSize: 12, - },this); + // String - Scale label font weight style + scaleFontStyle: "normal", + // String - Scale label font colour + scaleFontColor: "#666", - this.render(); - }, - update : function(){ - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(this.data.datasets,function(dataset,datasetIndex){ + // Boolean - whether or not the chart should be responsive and resize when the browser does. + responsive: false, - helpers.extend(this.datasets[datasetIndex], { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - pointColor : dataset.pointColor, - pointStrokeColor : dataset.pointStrokeColor, - }); + // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container + maintainAspectRatio: true, - helpers.each(dataset.data,function(dataPoint,index){ - helpers.extend(this.datasets[datasetIndex].points[index], { - value : dataPoint, - label : this.data.labels[index], - datasetLabel: dataset.label, - strokeColor : dataset.pointStrokeColor, - fillColor : dataset.pointColor, - highlightFill : dataset.pointHighlightFill || dataset.pointColor, - highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor - }); - },this); + //String / Boolean - Hover mode for events. + hoverMode: 'single', // 'label', 'dataset', 'false' - },this); + //Function - Custom hover handler + onHover: null, - this.scale.update(); - // Reset any highlight colours before updating. - helpers.each(this.activeElements, function(activeElement){ - activeElement.restore(['fillColor', 'strokeColor']); - }); - this.eachPoints(function(point){ - point.save(); - }); - this.render(); - }, - eachPoints : function(callback){ - helpers.each(this.datasets,function(dataset){ - helpers.each(dataset.points,callback,this); - },this); - }, - getPointsAtEvent : function(e){ - var pointsArray = [], - eventPosition = helpers.getRelativePosition(e); - helpers.each(this.datasets,function(dataset){ - helpers.each(dataset.points,function(point){ - if (point.inRange(eventPosition.x,eventPosition.y)) pointsArray.push(point); - }); - },this); - return pointsArray; - }, - buildScale : function(labels){ - var self = this; + //Function - Custom hover handler + hoverAnimationDuration: 400, - var dataTotal = function(){ - var values = []; - self.eachPoints(function(point){ - values.push(point.value); - }); + // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove + showTooltips: true, - return values; - }; + // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function + customTooltips: false, - var scaleOptions = { - templateString : this.options.scaleLabel, - height : this.chart.height, - width : this.chart.width, - ctx : this.chart.ctx, - textColor : this.options.scaleFontColor, - offsetGridLines : this.options.offsetGridLines, - fontSize : this.options.scaleFontSize, - fontStyle : this.options.scaleFontStyle, - fontFamily : this.options.scaleFontFamily, - valuesCount : labels.length, - beginAtZero : this.options.scaleBeginAtZero, - integersOnly : this.options.scaleIntegersOnly, - calculateYRange : function(currentHeight){ - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); - }, - xLabels : labels, - font : helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth : this.options.scaleLineWidth, - lineColor : this.options.scaleLineColor, - showHorizontalLines : this.options.scaleShowHorizontalLines, - showVerticalLines : this.options.scaleShowVerticalLines, - 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 - }; - - if (this.options.scaleOverride){ - helpers.extend(scaleOptions, { - calculateYRange: helpers.noop, - steps: this.options.scaleSteps, - stepValue: this.options.scaleStepWidth, - min: this.options.scaleStartValue, - max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth) - }); - } + // Array - Array of string names to attach tooltip events + tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], + // String - Tooltip background colour + tooltipBackgroundColor: "rgba(0,0,0,0.8)", - this.scale = new Chart.Scale(scaleOptions); - }, - addData : function(valuesArray,label){ - //Map the values array for each of the datasets + // String - Tooltip label font declaration for the scale label + tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - helpers.each(valuesArray,function(value,datasetIndex){ - //Add a new point for each piece of data, passing any required data to draw. - this.datasets[datasetIndex].points.push(new this.PointClass({ - value : value, - label : label, - datasetLabel: this.datasets[datasetIndex].label, - x: this.scale.calculateX(this.scale.valuesCount+1), - y: this.scale.endPoint, - strokeColor : this.datasets[datasetIndex].pointStrokeColor, - fillColor : this.datasets[datasetIndex].pointColor - })); - },this); + // 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, + + // String - Template string for single tooltips + tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", + + // String - Template string for single tooltips + multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", + + // String - Colour behind the legend colour block + multiTooltipKeyBackground: '#fff', + + // Function - Will fire on animation progression. + onAnimationProgress: function() {}, + + // Function - Will fire on animation completion. + onAnimationComplete: function() {}, + + // Color String - Used for undefined Colros + colorFallback: 'rgba(0,0,0,0.1)', + + } + }; + + //Create a dictionary of chart types, to allow for extension of existing types + Chart.types = {}; + + //Global Chart helpers object for utility methods and classes + var helpers = Chart.helpers = {}; + + //-- Basic js utility methods + var each = helpers.each = function(loopable, callback, self) { + var additionalArgs = Array.prototype.slice.call(arguments, 3); + // Check to see if null or undefined firstly. + if (loopable) { + if (loopable.length === +loopable.length) { + var i; + for (i = 0; i < loopable.length; i++) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } + } else { + for (var item in loopable) { + callback.apply(self, [loopable[item], item].concat(additionalArgs)); + } + } + } + }, + clone = helpers.clone = function(obj) { + var objClone = {}; + each(obj, function(value, key) { + if (obj.hasOwnProperty(key)) { + objClone[key] = value; + } + }); + return objClone; + }, + extend = helpers.extend = function(base) { + each(Array.prototype.slice.call(arguments, 1), function(extensionObject) { + each(extensionObject, function(value, key) { + if (extensionObject.hasOwnProperty(key)) { + base[key] = value; + } + }); + }); + return base; + }, + merge = helpers.merge = function(base, master) { + //Merge properties in left object over to a shallow clone of object right. + var args = Array.prototype.slice.call(arguments, 0); + args.unshift({}); + return extend.apply(null, args); + }, + indexOf = helpers.indexOf = function(arrayToSearch, item) { + if (Array.prototype.indexOf) { + return arrayToSearch.indexOf(item); + } else { + for (var i = 0; i < arrayToSearch.length; i++) { + if (arrayToSearch[i] === item) return i; + } + return -1; + } + }, + where = helpers.where = function(collection, filterCallback) { + var filtered = []; + + helpers.each(collection, function(item) { + if (filterCallback(item)) { + filtered.push(item); + } + }); + + return filtered; + }, + findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to start of the array + if (!startIndex) { + startIndex = -1; + } + for (var i = startIndex + 1; i < arrayToSearch.length; i++) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to end of the array + if (!startIndex) { + startIndex = arrayToSearch.length; + } + for (var i = startIndex - 1; i >= 0; i--) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + inherits = helpers.inherits = function(extensions) { + //Basic javascript inheritance based on the model created in Backbone.js + var parent = this; + var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() { + return parent.apply(this, arguments); + }; + + var Surrogate = function() { + this.constructor = ChartElement; + }; + Surrogate.prototype = parent.prototype; + ChartElement.prototype = new Surrogate(); + + ChartElement.extend = inherits; + + if (extensions) extend(ChartElement.prototype, extensions); + + ChartElement.__super__ = parent.prototype; + + return ChartElement; + }, + noop = helpers.noop = function() {}, + uid = helpers.uid = (function() { + var id = 0; + return function() { + return "chart-" + id++; + }; + })(), + warn = helpers.warn = function(str) { + //Method for warning of errors + if (window.console && typeof window.console.warn === "function") console.warn(str); + }, + amd = helpers.amd = (typeof define === 'function' && define.amd), + //-- Math methods + isNumber = helpers.isNumber = function(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + }, + max = helpers.max = function(array) { + return Math.max.apply(Math, array); + }, + min = helpers.min = function(array) { + return Math.min.apply(Math, array); + }, + cap = helpers.cap = function(valueToCap, maxValue, minValue) { + if (isNumber(maxValue)) { + if (valueToCap > maxValue) { + return maxValue; + } + } else if (isNumber(minValue)) { + if (valueToCap < minValue) { + return minValue; + } + } + return valueToCap; + }, + getDecimalPlaces = helpers.getDecimalPlaces = function(num) { + if (num % 1 !== 0 && isNumber(num)) { + var s = num.toString(); + if (s.indexOf("e-") < 0) { + // no exponent, e.g. 0.01 + return s.split(".")[1].length; + } else if (s.indexOf(".") < 0) { + // no decimal point, e.g. 1e-9 + return parseInt(s.split("e-")[1]); + } else { + // exponent and decimal point, e.g. 1.23e-9 + var parts = s.split(".")[1].split("e-"); + return parts[0].length + parseInt(parts[1]); + } + } else { + return 0; + } + }, + toRadians = helpers.radians = function(degrees) { + return degrees * (Math.PI / 180); + }, + // Gets the angle from vertical upright to the point about a centre. + getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { + var distanceFromXCenter = anglePoint.x - centrePoint.x, + distanceFromYCenter = anglePoint.y - centrePoint.y, + radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + + + var angle = Math.PI * 2 + Math.atan2(distanceFromYCenter, distanceFromXCenter); + + //If the segment is in the top left quadrant, we need to add another rotation to the angle + if (distanceFromXCenter < 0 && distanceFromYCenter < 0) { + angle += Math.PI * 2; + } + + return { + angle: angle, + distance: radialDistanceFromCenter + }; + }, + aliasPixel = helpers.aliasPixel = function(pixelWidth) { + return (pixelWidth % 2 === 0) ? 0 : 0.5; + }, + splineCurve = helpers.splineCurve = function(FirstPoint, MiddlePoint, AfterPoint, t) { + //Props to Rob Spencer at scaled innovation for his post on splining between points + //http://scaledinnovation.com/analytics/splines/aboutSplines.html + var d01 = Math.sqrt(Math.pow(MiddlePoint.x - FirstPoint.x, 2) + Math.pow(MiddlePoint.y - FirstPoint.y, 2)), + d12 = Math.sqrt(Math.pow(AfterPoint.x - MiddlePoint.x, 2) + Math.pow(AfterPoint.y - MiddlePoint.y, 2)), + fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta + fb = t * d12 / (d01 + d12); + return { + next: { + x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) + }, + previous: { + x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) + } + }; + }, + calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { + return Math.floor(Math.log(val) / Math.LN10); + }, + calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { + + //Set a minimum step of two - a point at the top of the graph, and a point at the base + var minSteps = 2, + maxSteps = Math.floor(drawingSize / (textSize * 1.5)), + skipFitting = (minSteps >= maxSteps); + + var maxValue = max(valuesArray), + minValue = min(valuesArray); + + // We need some degree of seperation here to calculate the scales if all the values are the same + // Adding/minusing 0.5 will give us a range of 1. + if (maxValue === minValue) { + maxValue += 0.5; + // So we don't end up with a graph with a negative start value if we've said always start from zero + if (minValue >= 0.5 && !startFromZero) { + minValue -= 0.5; + } else { + // Make up a whole number above the values + maxValue += 0.5; + } + } + + var valueRange = Math.abs(maxValue - minValue), + rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), + graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphRange = graphMax - graphMin, + stepValue = Math.pow(10, rangeOrderOfMagnitude), + numberOfSteps = Math.round(graphRange / stepValue); + + //If we have more space on the graph we'll use it to give more definition to the data + while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { + if (numberOfSteps > maxSteps) { + stepValue *= 2; + numberOfSteps = Math.round(graphRange / stepValue); + // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. + if (numberOfSteps % 1 !== 0) { + skipFitting = true; + } + } + //We can fit in double the amount of scale points on the scale + else { + //If user has declared ints only, and the step value isn't a decimal + if (integersOnly && rangeOrderOfMagnitude >= 0) { + //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float + if (stepValue / 2 % 1 === 0) { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + //If it would make it a float break out of the loop + else { + break; + } + } + //If the scale doesn't have to be an int, make the scale more granular anyway. + else { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + + } + } + + if (skipFitting) { + numberOfSteps = minSteps; + stepValue = graphRange / numberOfSteps; + } + return { + steps: numberOfSteps, + stepValue: stepValue, + min: graphMin, + max: graphMin + (numberOfSteps * stepValue) + }; + + }, + /* jshint ignore:start */ + // Blows up jshint errors based on the new Function constructor + //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 instanceof Function) { + return templateString(valuesObject); + } + + var cache = {}; + + function tmpl(str, data) { + // Figure out if we're getting a template, or if we need to + // load the template - and be sure to cache the result. + var fn = !/\W/.test(str) ? + cache[str] = cache[str] : + + // Generate a reusable function that will serve as a template + // generator (and which will be cached). + new Function("obj", + "var p=[],print=function(){p.push.apply(p,arguments);};" + + + // Introduce the data as local variables using with(){} + "with(obj){p.push('" + + + // Convert the template into pure JavaScript + str + .replace(/[\r\t\n]/g, " ") + .split("<%").join("\t") + .replace(/((^|%>)[^\t]*)'/g, "$1\r") + .replace(/\t=(.*?)%>/g, "',$1,'") + .split("\t").join("');") + .split("%>").join("p.push('") + .split("\r").join("\\'") + + "');}return p.join('');" + ); + + // Provide some basic currying to the user + return data ? fn(data) : fn; + } + return tmpl(templateString, valuesObject); + }, + /* jshint ignore:end */ + generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { + var labelsArray = new Array(numberOfSteps); + if (templateString) { + each(labelsArray, function(val, index) { + labelsArray[index] = template(templateString, { + value: (graphMin + (stepValue * (index + 1))) + }); + }); + } + return labelsArray; + }, + //--Animation methods + //Easing functions adapted from Robert Penner's easing equations + //http://www.robertpenner.com/easing/ + easingEffects = helpers.easingEffects = { + linear: function(t) { + return t; + }, + easeInQuad: function(t) { + return t * t; + }, + easeOutQuad: function(t) { + return -1 * t * (t - 2); + }, + easeInOutQuad: function(t) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t; + } + return -1 / 2 * ((--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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t; + } + return 1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t; + } + return -1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t * t; + } + return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); + }, + easeInExpo: function(t) { + return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); + }, + easeOutExpo: function(t) { + return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); + }, + easeInOutExpo: function(t) { + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if ((t /= 1 / 2) < 1) { + return 1 / 2 * Math.pow(2, 10 * (t - 1)); + } + return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); + }, + easeInCirc: function(t) { + if (t >= 1) { + return t; + } + return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); + }, + easeOutCirc: function(t) { + return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); + }, + easeInOutCirc: function(t) { + if ((t /= 1 / 2) < 1) { + return -1 / 2 * (Math.sqrt(1 - t * t) - 1); + } + return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); + }, + easeInElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + }, + easeOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; + }, + easeInOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1 / 2) == 2) { + return 1; + } + if (!p) { + p = 1 * (0.3 * 1.5); + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1) { + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; + }, + easeInBack: function(t) { + var s = 1.70158; + return 1 * (t /= 1) * t * ((s + 1) * t - s); + }, + easeOutBack: function(t) { + var s = 1.70158; + return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); + }, + easeInOutBack: function(t) { + var s = 1.70158; + if ((t /= 1 / 2) < 1) { + return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); + } + return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); + }, + easeInBounce: function(t) { + return 1 - easingEffects.easeOutBounce(1 - t); + }, + easeOutBounce: function(t) { + if ((t /= 1) < (1 / 2.75)) { + return 1 * (7.5625 * t * t); + } else if (t < (2 / 2.75)) { + return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); + } else if (t < (2.5 / 2.75)) { + return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); + } else { + return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); + } + }, + easeInOutBounce: function(t) { + if (t < 1 / 2) { + return easingEffects.easeInBounce(t * 2) * 0.5; + } + return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; + } + }, + //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ + requestAnimFrame = helpers.requestAnimFrame = (function() { + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function(callback) { + return window.setTimeout(callback, 1000 / 60); + }; + })(), + cancelAnimFrame = helpers.cancelAnimFrame = (function() { + return window.cancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.mozCancelAnimationFrame || + window.oCancelAnimationFrame || + window.msCancelAnimationFrame || + function(callback) { + return window.clearTimeout(callback, 1000 / 60); + }; + })(), + animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { + + var currentStep = 0, + easingFunction = easingEffects[easingString] || easingEffects.linear; + + var animationFrame = function() { + currentStep++; + var stepDecimal = currentStep / totalSteps; + var easeDecimal = easingFunction(stepDecimal); + + callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); + onProgress.call(chartInstance, easeDecimal, stepDecimal); + if (currentStep < totalSteps) { + chartInstance.animationFrame = requestAnimFrame(animationFrame); + } else { + onComplete.apply(chartInstance); + } + }; + requestAnimFrame(animationFrame); + }, + //-- DOM methods + getRelativePosition = helpers.getRelativePosition = function(evt) { + var mouseX, mouseY; + var e = evt.originalEvent || evt, + canvas = evt.currentTarget || evt.srcElement, + boundingRect = canvas.getBoundingClientRect(); + + if (e.touches) { + mouseX = e.touches[0].clientX - boundingRect.left; + mouseY = e.touches[0].clientY - boundingRect.top; + + } else { + mouseX = e.clientX - boundingRect.left; + mouseY = e.clientY - boundingRect.top; + } + + return { + x: mouseX, + y: mouseY + }; + + }, + addEvent = helpers.addEvent = function(node, eventType, method) { + if (node.addEventListener) { + node.addEventListener(eventType, method); + } else if (node.attachEvent) { + node.attachEvent("on" + eventType, method); + } else { + node["on" + eventType] = method; + } + }, + removeEvent = helpers.removeEvent = function(node, eventType, handler) { + if (node.removeEventListener) { + node.removeEventListener(eventType, handler, false); + } else if (node.detachEvent) { + node.detachEvent("on" + eventType, handler); + } else { + node["on" + eventType] = noop; + } + }, + bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) { + // Create the events object if it's not already present + if (!chartInstance.events) chartInstance.events = {}; + + each(arrayOfEvents, function(eventName) { + chartInstance.events[eventName] = function() { + handler.apply(chartInstance, arguments); + }; + addEvent(chartInstance.chart.canvas, eventName, chartInstance.events[eventName]); + }); + }, + unbindEvents = helpers.unbindEvents = function(chartInstance, arrayOfEvents) { + each(arrayOfEvents, function(handler, eventName) { + removeEvent(chartInstance.chart.canvas, eventName, handler); + }); + }, + getMaximumWidth = helpers.getMaximumWidth = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); + // TODO = check cross browser stuff with this. + return container.clientWidth - padding; + }, + getMaximumHeight = helpers.getMaximumHeight = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); + // TODO = check cross browser stuff with this. + return container.clientHeight - padding; + }, + getStyle = helpers.getStyle = function(el, property) { + return el.currentStyle ? + el.currentStyle[property] : + document.defaultView.getComputedStyle(el, null).getPropertyValue(property); + }, + getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support + retinaScale = helpers.retinaScale = function(chart) { + var ctx = chart.ctx, + width = chart.canvas.width, + height = chart.canvas.height; + + if (window.devicePixelRatio) { + ctx.canvas.style.width = width + "px"; + ctx.canvas.style.height = height + "px"; + ctx.canvas.height = height * window.devicePixelRatio; + ctx.canvas.width = width * window.devicePixelRatio; + ctx.scale(window.devicePixelRatio, window.devicePixelRatio); + } + }, + //-- Canvas methods + clear = helpers.clear = function(chart) { + chart.ctx.clearRect(0, 0, chart.width, chart.height); + }, + fontString = helpers.fontString = function(pixelSize, fontStyle, fontFamily) { + return fontStyle + " " + pixelSize + "px " + fontFamily; + }, + longestText = helpers.longestText = function(ctx, font, arrayOfStrings) { + ctx.font = font; + var longest = 0; + each(arrayOfStrings, function(string) { + var textWidth = ctx.measureText(string).width; + longest = (textWidth > longest) ? textWidth : longest; + }); + return longest; + }, + drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx, x, y, width, height, radius) { + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + }, + color = helpers.color = function(color) { + if (!window.Color) { + console.log('Color.js not found!'); + return color; + } + return window.Color(color); + }, + isArray = helpers.isArray = function(obj) { + if (!Array.isArray) { + return Object.prototype.toString.call(arg) === '[object Array]'; + } + return Array.isArray(obj); + }; + + //Store a reference to each instance - allowing us to globally resize chart instances on window resize. + //Destroy method on the chart will remove the instance of the chart from this reference. + Chart.instances = {}; + + Chart.Type = function(data, options, chart) { + this.options = options; + this.chart = chart; + this.id = uid(); + //Add the chart instance to the global namespace + Chart.instances[this.id] = this; + + // Initialize is always called when a chart type is created + // By default it is a no op, but it should be extended + if (options.responsive) { + this.resize(); + } + this.initialize.call(this, data); + }; + + //Core methods that'll be a part of every chart type + extend(Chart.Type.prototype, { + initialize: function() { + return this; + }, + clear: function() { + clear(this.chart); + return this; + }, + stop: function() { + // Stops any current animation loop occuring + Chart.animationService.cancelAnimation(this); + return this; + }, + resize: function(callback) { + this.stop(); + var canvas = this.chart.canvas, + newWidth = getMaximumWidth(this.chart.canvas), + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + + canvas.width = this.chart.width = newWidth; + canvas.height = this.chart.height = newHeight; + + retinaScale(this.chart); + + if (typeof callback === "function") { + callback.apply(this, Array.prototype.slice.call(arguments, 1)); + } + return this; + }, + redraw: noop, + render: function(duration) { + + if (this.options.animation) { + var animation = new Chart.Animation(); + animation.numSteps = (duration || this.options.animationDuration) / 16.66; //60 fps + animation.easing = this.options.animationEasing; + + // render function + animation.render = function(chartInstance, animationObject) { + var easingFunction = helpers.easingEffects[animationObject.easing]; + var stepDecimal = animationObject.currentStep / animationObject.numSteps; + var easeDecimal = easingFunction(stepDecimal); + + chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); + }; + + // user events + animation.onAnimationProgress = this.options.onAnimationProgress; + animation.onAnimationComplete = this.options.onAnimationComplete; + + Chart.animationService.addAnimation(this, animation, duration); + } else { + this.draw(); + this.options.onAnimationComplete.call(this); + } + return this; + }, + eachElement: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }, + eachValue: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.data, callback, this, datasetIndex); + }, this); + }, + eachDataset: function(callback) { + helpers.each(this.data.datasets, callback, this); + }, + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + generateLegend: function() { + return template(this.options.legendTemplate, this); + }, + 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]; + }, + toBase64Image: function() { + return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); + } + }); + + Chart.Type.extend = function(extensions) { + + var parent = this; + + var ChartType = function() { + return parent.apply(this, arguments); + }; + + //Copy the prototype object of the this class + ChartType.prototype = clone(parent.prototype); + //Now overwrite some of the properties in the base class with the new extensions + extend(ChartType.prototype, extensions); + + ChartType.extend = Chart.Type.extend; + + if (extensions.name || parent.prototype.name) { + + var chartName = extensions.name || parent.prototype.name; + //Assign any potential default values of the new chart type + + //If none are defined, we'll use a clone of the chart type this is being extended from. + //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart + //doesn't define some defaults of their own. + + var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; + + Chart.defaults[chartName] = extend(baseDefaults, extensions.defaults); + + Chart.types[chartName] = ChartType; + + //Register this new chart type in the Chart prototype + Chart.prototype[chartName] = function(data, options) { + var config = merge(Chart.defaults.global, Chart.defaults[chartName], options || {}); + return new ChartType(data, config, this); + }; + } else { + warn("Name not provided for this chart, so it hasn't been registered"); + } + return parent; + }; + + Chart.Element = function(configuration) { + extend(this, { + _vm: {}, + }); + extend(this, configuration); + this.initialize.apply(this, arguments); + }; + extend(Chart.Element.prototype, { + initialize: function() {}, + save: function() { + this._vm = clone(this); + delete this._vm._vm; + delete this._vm._start; + return this; + }, + pivot: function() { + if (this._start) { + this._start = clone(this); + helpers.extend(this._start, this._vm); + } + return this; + }, + transition: function(ease) { + if (!this._start) { + if (!this._vm) { + this.save(); + } + this._start = clone(this._vm); + } + + each(this, function(value, key) { + + if (key[0] === '_' || !this.hasOwnProperty(key)) { + // Only non-underscored properties + } + + // Init if doesn't exist + else if (!this._vm[key]) { + this._vm[key] = value || null; + } + + // No unnecessary computations + else if (this[key] === this._vm[key]) { + // It's the same! Woohoo! + } + + // Color transitions if possible + else if (typeof value === 'string') { + try { + var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); + this._vm[key] = color.rgbString(); + } catch (err) { + this._vm[key] = value; + } + } + // Number transitions + else if (typeof value === 'number') { + + this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; + } else { + // Everything else + this._vm[key] = value; + } + + }, this); + + if (ease === 1) { + delete this._start; + } + return this; + }, + tooltipPosition: function() { + return { + x: this.x, + y: this.y + }; + }, + hasValue: function() { + return isNumber(this.value); + } + }); + + Chart.Element.extend = inherits; + + + Chart.Point = Chart.Element.extend({ + inRange: function(mouseX, mouseY) { + var vm = this._vm; + var hoverRange = vm.hoverRadius + vm.radius; + return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + }, + inGroupRange: function(mouseX) { + var vm = this._vm; + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + this.hoverRadius, 2)); + }, + tooltipPosition: function() { + var vm = this._vm; + return { + x: vm.x, + y: vm.y + }; + }, + draw: function() { + + var vm = this._vm; + var ctx = this._chart.ctx; + + if (vm.radius > 0 || vm.borderWidth > 0) { + + ctx.beginPath(); + + ctx.arc(vm.x, vm.y, vm.radius, 0, Math.PI * 2); + ctx.closePath(); + + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; + + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + + ctx.fill(); + ctx.stroke(); + } + } + }); + + + Chart.Line = Chart.Element.extend({ + draw: function() { + + var vm = this._vm; + var ctx = this._chart.ctx; + + //Draw the line between all the points + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; + ctx.beginPath(); + + helpers.each(vm._points, function(point, index) { + if (index === 0) { + ctx.moveTo(point._vm.x, point._vm.y); + } else { + if (vm._tension > 0 || 1) { + var previous = this.previousPoint(point, vm._points, index); + + ctx.bezierCurveTo( + previous._vm.controlPointNextX, + previous._vm.controlPointNextY, + point._vm.controlPointPreviousX, + point._vm.controlPointPreviousY, + point._vm.x, + point._vm.y + ); + } else { + ctx.lineTo(point._vm.x, point._vm.y); + } + } + }, this); + + ctx.stroke(); + + if (vm._points.length > 0) { + //Round off the line by going to the base of the chart, back to the start, then fill. + ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleBottom); + ctx.lineTo(vm._points[0].x, vm.scaleBottom); + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + ctx.closePath(); + ctx.fill(); + } + }, + previousPoint: function(point, collection, index) { + return helpers.findPreviousWhere(collection, function() { + return true; + }, index) || point; + }, + }); + + Chart.Arc = Chart.Element.extend({ + inRange: function(chartX, chartY) { + + var pointRelativePosition = helpers.getAngleFromPoint(this, { + x: chartX, + y: chartY + }); + + //Check if within the range of the open/close angle + var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle), + withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius); + + return (betweenAngles && withinRadius); + //Ensure within the outside of the arc centre, but inside arc outer + }, + tooltipPosition: function() { + var centreAngle = this.startAngle + ((this.endAngle - this.startAngle) / 2), + rangeFromCentre = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius; + return { + x: this.x + (Math.cos(centreAngle) * rangeFromCentre), + y: this.y + (Math.sin(centreAngle) * rangeFromCentre) + }; + }, + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._vm; + + ctx.beginPath(); + + ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); + + ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); + + ctx.closePath(); + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; + + ctx.fillStyle = vm.backgroundColor; + + ctx.fill(); + ctx.lineJoin = 'bevel'; + + if (vm.borderWidth) { + ctx.stroke(); + } + } + }); + + Chart.Rectangle = Chart.Element.extend({ + draw: function() { + + var vm = this._vm; + + var ctx = this.ctx, + halfWidth = vm.width / 2, + leftX = vm.x - halfWidth, + rightX = vm.x + halfWidth, + top = vm.base - (vm.base - vm.y), + halfStroke = vm.borderWidth / 2; + + // Canvas doesn't allow us to stroke inside the width so we can + // adjust the sizes to fit if we're setting a stroke on the line + if (vm.borderWidth) { + leftX += halfStroke; + rightX -= halfStroke; + top += halfStroke; + } + + ctx.beginPath(); + + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; + + // It'd be nice to keep this class totally generic to any rectangle + // and simply specify which border to miss out. + ctx.moveTo(leftX, vm.base); + ctx.lineTo(leftX, top); + ctx.lineTo(rightX, top); + ctx.lineTo(rightX, vm.base); + ctx.fill(); + if (vm.borderWidth) { + ctx.stroke(); + } + }, + height: function() { + var vm = this._vm; + return vm.base - vm.y; + }, + inRange: function(mouseX, mouseY) { + var vm = this._vm; + if (vm.y < vm.base) { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); + } else { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); + } + }, + inGroupRange: function(mouseX) { + var vm = this._vm; + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + }, + tooltipPosition: function() { + var vm = this._vm; + if (vm.y < vm.base) { + return { + x: vm.x, + y: vm.y + }; + } else { + return { + x: vm.x, + y: vm.base + }; + } + }, + }); + + Chart.Animation = Chart.Element.extend({ + currentStep: null, // the current animation step + numSteps: 60, // default number of steps + easing: "", // the easing to use for this animation + render: null, // render function used by the animation service + + onAnimationProgress: null, // user specified callback to fire on each step of the animation + onAnimationComplete: null, // user specified callback to fire when the animation finishes + }); + + Chart.Tooltip = Chart.Element.extend({ + initialize: function() { + var options = this._options; + extend(this, { + opacity: 0, + xPadding: options.tooltipXPadding, + yPadding: options.tooltipYPadding, + xOffset: options.tooltipXOffset, + backgroundColor: options.tooltipBackgroundColor, + textColor: options.tooltipFontColor, + _fontFamily: options.tooltipFontFamily, + _fontStyle: options.tooltipFontStyle, + fontSize: options.tooltipFontSize, + titleTextColor: options.tooltipTitleFontColor, + _titleFontFamily: options.tooltipTitleFontFamily, + _titleFontStyle: options.tooltipTitleFontStyle, + titleFontSize: options.tooltipTitleFontSize, + caretHeight: options.tooltipCaretSize, + cornerRadius: options.tooltipCornerRadius, + legendColorBackground: options.multiTooltipKeyBackground, + labels: [], + colors: [], + }); + }, + update: function() { + + var ctx = this._chart.ctx; + + switch (this._options.hoverMode) { + case 'single': + helpers.extend(this, { + text: template(this._options.tooltipTemplate, this._active[0]), + }); + var tooltipPosition = this._active[0].tooltipPosition(); + helpers.extend(this, { + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + }); + break; + + case 'label': + + // Tooltip Content + + var dataArray, + dataIndex; + + var labels = [], + colors = []; + + for (var i = this._data.datasets.length - 1; i >= 0; i--) { + dataArray = this._data.datasets[i].metaData; + dataIndex = indexOf(dataArray, this._active[0]); + if (dataIndex !== -1) { + break; + } + } + + var medianPosition = (function(index) { + // Get all the points at that particular index + var elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this._data.datasets, function(dataset) { + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { + elements.push(dataCollection[dataIndex]); + } + }); + + helpers.each(elements, function(element) { + xPositions.push(element._vm.x); + yPositions.push(element._vm.y); + + //Include any colour information about the element + labels.push(helpers.template(this._options.multiTooltipTemplate, element)); + colors.push({ + fill: element._vm.backgroundColor, + stroke: element._vm.borderColor + }); + + }, this); + + yMin = min(yPositions); + yMax = max(yPositions); + + xMin = min(xPositions); + xMax = max(xPositions); + + return { + x: (xMin > this._chart.width / 2) ? xMin : xMax, + y: (yMin + yMax) / 2, + }; + }).call(this, dataIndex); + + // Apply for now + helpers.extend(this, { + x: medianPosition.x, + y: medianPosition.y, + labels: labels, + title: this._active.length ? this._active[0].label : '', + legendColors: colors, + legendBackgroundColor: this._options.multiTooltipKeyBackground, + }); + + + // Calculate Appearance Tweaks + + this.height = (labels.length * this.fontSize) + ((labels.length - 1) * (this.fontSize / 2)) + (this.yPadding * 2) + this.titleFontSize * 1.5; + + var titleWidth = ctx.measureText(this.title).width, + //Label has a legend square as well so account for this. + labelWidth = longestText(ctx, this.font, labels) + this.fontSize + 3, + longestTextWidth = max([labelWidth, titleWidth]); + + this.width = longestTextWidth + (this.xPadding * 2); + + + var halfHeight = this.height / 2; + + //Check to ensure the height will fit on the canvas + if (this.y - halfHeight < 0) { + this.y = halfHeight; + } else if (this.y + halfHeight > this._chart.height) { + this.y = this._chart.height - halfHeight; + } + + //Decide whether to align left or right based on position on canvas + if (this.x > this._chart.width / 2) { + this.x -= this.xOffset + this.width; + } else { + this.x += this.xOffset; + } + break; + } + + return this; + }, + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._vm; + + switch (this._options.hoverMode) { + case 'single': + + ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + + vm.xAlign = "center"; + vm.yAlign = "above"; + + //Distance between the actual element.y position and the start of the tooltip caret + var caretPadding = vm.caretPadding = 2; + + var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, + tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; + + if (vm.x + tooltipWidth / 2 > this._chart.width) { + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth / 2 < 0) { + vm.xAlign = "right"; + } + + if (vm.y - tooltipHeight < 0) { + vm.yAlign = "below"; + } + + var tooltipX = vm.x - tooltipWidth / 2, + tooltipY = vm.y - tooltipHeight; + + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + + // Custom Tooltips + if (this._custom) { + this._custom(this._vm); + } else { + switch (vm.yAlign) { + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } + + switch (vm.xAlign) { + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } + + drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); + + ctx.fill(); + + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); + + } + break; + case 'label': + + drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + ctx.fill(); + ctx.closePath(); + + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); + ctx.font = fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); + ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); + + ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + helpers.each(vm.labels, function(label, index) { + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); + + //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) + //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + //Instead we'll make a white filled block to put the legendColour palette over. + + ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + + }, this); + break; + } + }, + getLineHeight: function(index) { + var baseLineHeight = this._vm.y - (this._vm.height / 2) + this._vm.yPadding, + afterTitleIndex = index - 1; + + //If the index is zero, we're getting the title + if (index === 0) { + return baseLineHeight + this._vm.titleFontSize / 2; + } else { + return baseLineHeight + ((this._vm.fontSize * 1.5 * afterTitleIndex) + this._vm.fontSize / 2) + this._vm.titleFontSize * 1.5; + } + + }, + }); + + Chart.Scale = Chart.Element.extend({ + initialize: function() { + this.fit(); + }, + buildYLabels: function() { + this.yLabels = []; + + var stepDecimalPlaces = getDecimalPlaces(this.stepValue); + + 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) + 10 : 0; + }, + addXLabel: function(label) { + this.xLabels.push(label); + this.valuesCount++; + this.fit(); + }, + removeXLabel: function() { + this.xLabels.shift(); + this.valuesCount--; + this.fit(); + }, + // Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use + fit: function() { + // First we need the width of the yLabels, assuming the xLabels aren't rotated + + // To do that we need the base line at the top and base of the chart, assuming there is no x label rotation + this.startPoint = (this.display) ? this.fontSize : 0; + this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels + + // Apply padding settings to the start and end point. + this.startPoint += this.padding; + this.endPoint -= this.padding; + + // Cache the starting endpoint, excluding the space for x labels + var cachedEndPoint = this.endPoint; + + // Cache the starting height, so can determine if we need to recalculate the scale yAxis + var cachedHeight = this.endPoint - this.startPoint, + cachedYLabelWidth; + + // Build the current yLabels so we have an idea of what size they'll be to start + /* + * This sets what is returned from calculateScaleRange as static properties of this class: + * + this.steps; + this.stepValue; + this.min; + this.max; + * + */ + this.calculateYRange(cachedHeight); + + // With these properties set we can now build the array of yLabels + // and also the width of the largest yLabel + this.buildYLabels(); + + this.calculateXLabelRotation(); + + while ((cachedHeight > this.endPoint - this.startPoint)) { + cachedHeight = this.endPoint - this.startPoint; + cachedYLabelWidth = this.yLabelWidth; + + this.calculateYRange(cachedHeight); + this.buildYLabels(); + + // Only go through the xLabel loop again if the yLabel width has changed + if (cachedYLabelWidth < this.yLabelWidth) { + this.endPoint = cachedEndPoint; + this.calculateXLabelRotation(); + } + } + + }, + calculateXLabelRotation: function() { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + + this.ctx.font = this.font; + + var firstWidth = this.ctx.measureText(this.xLabels[0]).width, + lastWidth = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width, + firstRotated, + lastRotated; + + + this.xScalePaddingRight = lastWidth / 2 + 3; + this.xScalePaddingLeft = (firstWidth / 2 > this.yLabelWidth) ? firstWidth / 2 : this.yLabelWidth; + + this.xLabelRotation = 0; + if (this.display) { + var originalLabelWidth = longestText(this.ctx, this.font, this.xLabels), + cosRotation, + firstRotatedWidth; + this.xLabelWidth = originalLabelWidth; + //Allow 3 pixels x2 padding either side for label readability + var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; + + //Max label rotate should be 90 - also act as a loop counter + while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)) { + cosRotation = Math.cos(toRadians(this.xLabelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.fontSize / 2 > this.yLabelWidth) { + this.xScalePaddingLeft = firstRotated + this.fontSize / 2; + } + this.xScalePaddingRight = this.fontSize / 2; + + + this.xLabelRotation++; + this.xLabelWidth = cosRotation * originalLabelWidth; + + } + if (this.xLabelRotation > 0) { + this.endPoint -= Math.sin(toRadians(this.xLabelRotation)) * originalLabelWidth + 3; + } + } else { + this.xLabelWidth = 0; + this.xScalePaddingRight = this.padding; + this.xScalePaddingLeft = this.padding; + } + + }, + // Needs to be overidden in each Chart type + // Otherwise we need to pass all the data into the scale class + calculateYRange: noop, + drawingArea: function() { + return this.startPoint - this.endPoint; + }, + calculateY: function(value) { + var scalingFactor = this.drawingArea() / (this.min - this.max); + return this.endPoint - (scalingFactor * (value - this.min)); + }, + calculateX: function(index) { + var isRotated = (this.xLabelRotation > 0), + // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding, + innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight), + valueWidth = innerWidth / Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1), + valueOffset = (valueWidth * index) + this.xScalePaddingLeft; + + if (this.offsetGridLines) { + valueOffset += (valueWidth / 2); + } + + return Math.round(valueOffset); + }, + update: function(newProps) { + helpers.extend(this, newProps); + this.fit(); + }, + draw: function() { + var ctx = this.ctx, + yLabelGap = (this.endPoint - this.startPoint) / this.steps, + xStart = Math.round(this.xScalePaddingLeft); + if (this.display) { + ctx.fillStyle = this.textColor; + ctx.font = this.font; + each(this.yLabels, function(labelString, index) { + var yLabelCenter = this.endPoint - (yLabelGap * index), + linePositionY = Math.round(yLabelCenter), + drawHorizontalLine = this.showHorizontalLines; + + ctx.textAlign = "right"; + ctx.textBaseline = "middle"; + if (this.showLabels) { + ctx.fillText(labelString, xStart - 10, yLabelCenter); + } + + // This is X axis, so draw it + if (index === 0 && !drawHorizontalLine) { + drawHorizontalLine = true; + } + + if (drawHorizontalLine) { + ctx.beginPath(); + } + + if (index > 0) { + // This is a grid line in the centre, so drop that + ctx.lineWidth = this.gridLineWidth; + ctx.strokeStyle = this.gridLineColor; + } else { + // This is the first line on the scale + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + } + + linePositionY += helpers.aliasPixel(ctx.lineWidth); + + if (drawHorizontalLine) { + ctx.moveTo(xStart, linePositionY); + ctx.lineTo(this.width, linePositionY); + ctx.stroke(); + ctx.closePath(); + } + + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + ctx.beginPath(); + ctx.moveTo(xStart - 5, linePositionY); + ctx.lineTo(xStart, linePositionY); + ctx.stroke(); + ctx.closePath(); + + }, this); + + each(this.xLabels, function(label, index) { + var xPos = this.calculateX(index) + aliasPixel(this.lineWidth), + // Check to see if line/bar here and decide where to place the line + linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth), + isRotated = (this.xLabelRotation > 0), + drawVerticalLine = this.showVerticalLines; + + // This is Y axis, so draw it + if (index === 0 && !drawVerticalLine) { + drawVerticalLine = true; + } + + if (drawVerticalLine) { + ctx.beginPath(); + } + + if (index > 0) { + // This is a grid line in the centre, so drop that + ctx.lineWidth = this.gridLineWidth; + ctx.strokeStyle = this.gridLineColor; + } else { + // This is the first line on the scale + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + } + + if (drawVerticalLine) { + ctx.moveTo(linePos, this.endPoint); + ctx.lineTo(linePos, this.startPoint - 3); + ctx.stroke(); + ctx.closePath(); + } + + + ctx.lineWidth = this.lineWidth; + ctx.strokeStyle = this.lineColor; + + + // Small lines at the bottom of the base grid line + ctx.beginPath(); + ctx.moveTo(linePos, this.endPoint); + ctx.lineTo(linePos, this.endPoint + 5); + ctx.stroke(); + ctx.closePath(); + + ctx.save(); + ctx.translate(xPos, (isRotated) ? this.endPoint + 12 : this.endPoint + 8); + ctx.rotate(toRadians(this.xLabelRotation) * -1); + ctx.font = this.font; + ctx.textAlign = (isRotated) ? "right" : "center"; + ctx.textBaseline = (isRotated) ? "middle" : "top"; + ctx.fillText(label, 0, 0); + ctx.restore(); + }, this); + + } + } + + }); + + Chart.RadialScale = Chart.Element.extend({ + initialize: function() { + this.size = min([this.height, this.width]); + this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + }, + calculateCenterOffset: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + + return (value - this.min) * scalingFactor; + }, + update: function() { + if (!this.lineArc) { + this.setScaleSize(); + } else { + this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + } + this.buildYLabels(); + }, + buildYLabels: function() { + this.yLabels = []; + + var stepDecimalPlaces = getDecimalPlaces(this.stepValue); + + for (var i = 0; i <= this.steps; i++) { + this.yLabels.push(template(this.templateString, { + value: (this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces) + })); + } + }, + getCircumference: function() { + return ((Math.PI * 2) / this.valuesCount); + }, + setScaleSize: function() { + /* + * Right, this is really confusing and there is a lot of maths going on here + * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 + * + * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif + * + * Solution: + * + * We assume the radius of the polygon is half the size of the canvas at first + * at each index we check if the text overlaps. + * + * Where it does, we store that angle and that index. + * + * After finding the largest index and angle we calculate how much we need to remove + * from the shape radius to move the point inwards by that x. + * + * We average the left and right distances to get the maximum shape radius that can fit in the box + * along with labels. + * + * Once we have that, we can find the centre point for the chart, by taking the x text protrusion + * on each side, removing that from the size, halving it and adding the left x protrusion width. + * + * This will mean we have a shape fitted to the canvas, as large as it can be with the labels + * and position it in the most space efficient manner + * + * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif + */ + + + // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. + // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points + var largestPossibleRadius = min([(this.height / 2 - this.pointLabelFontSize - 5), this.width / 2]), + pointPosition, + i, + textWidth, + halfTextWidth, + furthestRight = this.width, + furthestRightIndex, + furthestRightAngle, + furthestLeft = 0, + furthestLeftIndex, + furthestLeftAngle, + xProtrusionLeft, + xProtrusionRight, + radiusReductionRight, + radiusReductionLeft, + maxWidthRadius; + this.ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); + for (i = 0; i < this.valuesCount; i++) { + // 5px to space the text slightly out - similar to what we do in the draw function. + pointPosition = this.getPointPosition(i, largestPossibleRadius); + textWidth = this.ctx.measureText(template(this.templateString, { + value: this.labels[i] + })).width + 5; + if (i === 0 || i === this.valuesCount / 2) { + // If we're at index zero, or exactly the middle, we're at exactly the top/bottom + // of the radar chart, so text will be aligned centrally, so we'll half it and compare + // w/left and right text sizes + halfTextWidth = textWidth / 2; + if (pointPosition.x + halfTextWidth > furthestRight) { + furthestRight = pointPosition.x + halfTextWidth; + furthestRightIndex = i; + } + if (pointPosition.x - halfTextWidth < furthestLeft) { + furthestLeft = pointPosition.x - halfTextWidth; + furthestLeftIndex = i; + } + } else if (i < this.valuesCount / 2) { + // Less than half the values means we'll left align the text + if (pointPosition.x + textWidth > furthestRight) { + furthestRight = pointPosition.x + textWidth; + furthestRightIndex = i; + } + } else if (i > this.valuesCount / 2) { + // More than half the values means we'll right align the text + if (pointPosition.x - textWidth < furthestLeft) { + furthestLeft = pointPosition.x - textWidth; + furthestLeftIndex = i; + } + } + } + + xProtrusionLeft = furthestLeft; + + xProtrusionRight = Math.ceil(furthestRight - this.width); + + furthestRightAngle = this.getIndexAngle(furthestRightIndex); + + furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); + + radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); + + radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + + // Ensure we actually need to reduce the size of the chart + radiusReductionRight = (isNumber(radiusReductionRight)) ? radiusReductionRight : 0; + radiusReductionLeft = (isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; + + this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; + + //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) + this.setCenterPoint(radiusReductionLeft, radiusReductionRight); + + }, + setCenterPoint: function(leftMovement, rightMovement) { + + var maxRight = this.width - rightMovement - this.drawingArea, + maxLeft = leftMovement + this.drawingArea; + + this.xCenter = (maxLeft + maxRight) / 2; + // Always vertically in the centre as the text height doesn't change + this.yCenter = (this.height / 2); + }, + + getIndexAngle: function(index) { + var angleMultiplier = (Math.PI * 2) / this.valuesCount; + // Start from the top instead of right, so remove a quarter of the circle + + return index * angleMultiplier - (Math.PI / 2); + }, + getPointPosition: function(index, distanceFromCenter) { + var thisAngle = this.getIndexAngle(index); + return { + x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, + y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter + }; + }, + draw: function() { + if (this.display) { + var ctx = this.ctx; + each(this.yLabels, function(label, index) { + // Don't draw a centre value + if (index > 0) { + var yCenterOffset = index * (this.drawingArea / this.steps), + yHeight = this.yCenter - yCenterOffset, + pointPosition; + + // Draw circular lines around the scale + if (this.lineWidth > 0) { + ctx.strokeStyle = this.lineColor; + ctx.lineWidth = this.lineWidth; + + if (this.lineArc) { + ctx.beginPath(); + ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); + ctx.closePath(); + ctx.stroke(); + } else { + ctx.beginPath(); + for (var i = 0; i < this.valuesCount; i++) { + pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.min + (index * this.stepValue))); + if (i === 0) { + ctx.moveTo(pointPosition.x, pointPosition.y); + } else { + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + } + } + if (this.showLabels) { + ctx.font = fontString(this.fontSize, this._fontStyle, this._fontFamily); + if (this.showLabelBackdrop) { + var labelWidth = ctx.measureText(label).width; + ctx.fillStyle = this.backdropColor; + ctx.fillRect( + this.xCenter - labelWidth / 2 - this.backdropPaddingX, + yHeight - this.fontSize / 2 - this.backdropPaddingY, + labelWidth + this.backdropPaddingX * 2, + this.fontSize + this.backdropPaddingY * 2 + ); + } + ctx.textAlign = 'center'; + ctx.textBaseline = "middle"; + ctx.fillStyle = this.fontColor; + ctx.fillText(label, this.xCenter, yHeight); + } + } + }, this); + + if (!this.lineArc) { + ctx.lineWidth = this.angleLineWidth; + ctx.strokeStyle = this.angleLineColor; + for (var i = this.valuesCount - 1; i >= 0; i--) { + if (this.angleLineWidth > 0) { + var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); + ctx.beginPath(); + ctx.moveTo(this.xCenter, this.yCenter); + ctx.lineTo(outerPosition.x, outerPosition.y); + ctx.stroke(); + ctx.closePath(); + } + // Extra 3px out for some label spacing + var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); + ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); + ctx.fillStyle = this.pointLabelFontColor; + + var labelsCount = this.labels.length, + halfLabelsCount = this.labels.length / 2, + quarterLabelsCount = halfLabelsCount / 2, + upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), + exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); + if (i === 0) { + ctx.textAlign = 'center'; + } else if (i === halfLabelsCount) { + ctx.textAlign = 'center'; + } else if (i < halfLabelsCount) { + ctx.textAlign = 'left'; + } else { + ctx.textAlign = 'right'; + } + + // Set the correct text baseline based on outer positioning + if (exactQuarter) { + ctx.textBaseline = 'middle'; + } else if (upperHalf) { + ctx.textBaseline = 'bottom'; + } else { + ctx.textBaseline = 'top'; + } + + ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + } + } + } + } + }); + + Chart.animationService = { + frameDuration: 17, + animations: [], + dropFrames: 0, + addAnimation: function(chartInstance, animationObject, duration) { + + if (!duration) { + chartInstance.animating = true; + } + + for (var index = 0; index < this.animations.length; ++index) { + if (this.animations[index].chartInstance === chartInstance) { + // replacing an in progress animation + this.animations[index].animationObject = animationObject; + return; + } + } + + this.animations.push({ + chartInstance: chartInstance, + animationObject: animationObject + }); + + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (this.animations.length == 1) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + }, + // Cancel the animation for a given chart instance + cancelAnimation: function(chartInstance) { + var index = helpers.findNextWhere(this.animations, function(animationWrapper) { + return animationWrapper.chartInstance === chartInstance; + }); + + if (index) { + this.animations.splice(index, 1); + chartInstance.animating = false; + } + }, + // calls startDigest with the proper context + digestWrapper: function() { + Chart.animationService.startDigest.call(Chart.animationService); + }, + startDigest: function() { + + var startTime = Date.now(); + var framesToDrop = 0; + + if (this.dropFrames > 1) { + framesToDrop = Math.floor(this.dropFrames); + this.dropFrames -= framesToDrop; + } + + for (var i = 0; i < this.animations.length; i++) { + + if (this.animations[i].animationObject.currentStep === null) { + this.animations[i].animationObject.currentStep = 0; + } + + this.animations[i].animationObject.currentStep += 1 + framesToDrop; + if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { + this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; + } + + this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); + + if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { + // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; + this.animations.splice(i, 1); + // Keep the index in place to offset the splice + i--; + } + } + + var endTime = Date.now(); + var delay = endTime - startTime - this.frameDuration; + var frameDelay = delay / this.frameDuration; + + if (frameDelay > 1) { + this.dropFrames += frameDelay; + } + + // Do we have more stuff to animate? + if (this.animations.length > 0) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + } + }; + + // Attach global event to resize each chart instance when the browser resizes + helpers.addEvent(window, "resize", (function() { + // Basic debounce of resize function so it doesn't hurt performance when resizing browser. + var timeout; + return function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + each(Chart.instances, function(instance) { + // If the responsive flag is set in the chart instance config + // Cascade the resize event down to the chart. + if (instance.options.responsive) { + instance.resize(instance.render, true); + } + }); + }, 50); + }; + })()); + + + if (amd) { + define(function() { + return Chart; + }); + } else if (typeof module === 'object' && module.exports) { + module.exports = Chart; + } + + root.Chart = Chart; + + Chart.noConflict = function() { + root.Chart = previous; + return Chart; + }; - this.scale.addXLabel(label); - //Then re-render the chart. - this.update(); - }, - removeData : function(){ - this.scale.removeXLabel(); - //Then re-render the chart. - helpers.each(this.datasets,function(dataset){ - dataset.points.shift(); - },this); - this.update(); - }, - reflow : function(){ - var newScaleProps = helpers.extend({ - height : this.chart.height, - width : this.chart.width - }); - this.scale.update(newScaleProps); - }, - draw : function(ease){ - var easingDecimal = ease || 1; - this.clear(); +}).call(this); - var ctx = this.chart.ctx; +(function() { + "use strict"; - // Some helper methods for getting the next/prev points - var hasValue = function(item){ - return item.value !== null; - }, - nextPoint = function(point, collection, index){ - return helpers.findNextWhere(collection, hasValue, index) || point; - }, - previousPoint = function(point, collection, index){ - return helpers.findPreviousWhere(collection, hasValue, index) || point; - }; + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - this.scale.draw(easingDecimal); + var defaultConfig = { + //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)", - helpers.each(this.datasets,function(dataset){ - var pointsWithValues = helpers.where(dataset.points, hasValue); + //Number - Width of the grid lines + scaleGridLineWidth: 1, - //Transition each point first so that the line and point drawing isn't out of sync - //We can use this extra loop to calculate the control points of this dataset also in this loop + //Boolean - Whether to show horizontal lines (except X axis) + scaleShowHorizontalLines: true, - helpers.each(dataset.points, function(point, index){ - if (point.hasValue()){ - point.transition({ - y : this.scale.calculateY(point.value), - x : this.scale.calculateX(index) - }, easingDecimal); - } - },this); + //Boolean - Whether to show vertical lines (except Y axis) + scaleShowVerticalLines: true, + //Number - Pixel width of the bar border + barBorderWidth: 2, - // Control points need to be calculated in a seperate loop, because we need to know the current x/y of the point - // This would cause issues when there is no animation, because the y of the next point would be 0, so beziers would be skewed - if (this.options.bezierCurve){ - helpers.each(pointsWithValues, function(point, index){ - var tension = (index > 0 && index < pointsWithValues.length - 1) ? this.options.bezierCurveTension : 0; - point.controlPoints = helpers.splineCurve( - previousPoint(point, pointsWithValues, index), - point, - nextPoint(point, pointsWithValues, index), - tension - ); - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (point.controlPoints.outer.y > this.scale.endPoint){ - point.controlPoints.outer.y = this.scale.endPoint; - } - else if (point.controlPoints.outer.y < this.scale.startPoint){ - point.controlPoints.outer.y = this.scale.startPoint; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (point.controlPoints.inner.y > this.scale.endPoint){ - point.controlPoints.inner.y = this.scale.endPoint; - } - else if (point.controlPoints.inner.y < this.scale.startPoint){ - point.controlPoints.inner.y = this.scale.startPoint; - } - },this); - } + //Number - Spacing between each of the X value sets + barValueSpacing: 5, + + //Number - Spacing between data sets within X values + barDatasetSpacing: 1, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + + }; + + + Chart.Type.extend({ + name: "Bar", + defaults: defaultConfig, + initialize: function(data) { + + // Save data as a source for updating of values & methods + this.data = data; + + var options = this.options; + + // Custom Scale Methods and Options + this.ScaleClass = Chart.Scale.extend({ + offsetGridLines: true, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.calculateX(elementIndex) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth / 2; + }, + calculateBaseWidth: function() { + return (this.calculateX(1) - this.calculateX(0)) - (2 * options.barValueSpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); + + return (baseWidth / datasetCount); + } + }); + + // Events + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + + //Declare the extension of the default point, to cater for the options passed in to the constructor + this.BarClass = Chart.Rectangle.extend({ + ctx: this.chart.ctx, + }); + + // Build Scale + this.buildScale(this.data.labels); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new this.BarClass()); + }, this); + }, this); + + // Set defaults for bars + this.eachElement(function(bar, index, datasetIndex) { + helpers.extend(bar, { + width: this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.calculateBaseY(), + _datasetIndex: datasetIndex, + _index: index, + }); + // Copy to view model + bar.save(); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Update the chart with the latest data. + this.update(); + }, + onHover: function(e) { + + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; + this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; + this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + this.tooltip.pivot(); + + // Hover animations + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + // Calculate the base point for the bar. + calculateBaseY: function() { + var base = this.scale.endPoint; + + if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) { + base = this.scale.calculateY(0); + base += this.options.scaleGridLineWidth; + } else if (this.scale.min < 0 && this.scale.max < 0) { + // All values are negative. Use the top as the base + base = this.scale.startPoint; + } + + return base; + }, + update: function() { + + this.scale.update(); + + this.eachElement(function(bar, index, dataset, datasetIndex) { + helpers.extend(bar, { + width: this.scale.calculateBarWidth(this.data.datasets.length), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), + value: this.data.datasets[datasetIndex].data[index], + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + borderColor: this.data.datasets[datasetIndex].borderColor, + borderWidth: this.data.datasets[datasetIndex].borderWidth, + backgroundColor: this.data.datasets[datasetIndex].backgroundColor, + _datasetIndex: datasetIndex, + _index: index, + }); + bar.pivot(); + }, this); + + this.render(); + }, + buildScale: function(labels) { + var self = this; + + var dataTotal = function() { + var values = []; + self.eachValue(function(value) { + values.push(value); + }); + return values; + }; + + var scaleOptions = { + 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: labels.length, + beginAtZero: this.options.scaleBeginAtZero, + integersOnly: this.options.scaleIntegersOnly, + calculateYRange: function(currentHeight) { + var updatedRanges = helpers.calculateScaleRange( + dataTotal(), + currentHeight, + this.fontSize, + this.beginAtZero, + this.integersOnly + ); + helpers.extend(this, updatedRanges); + }, + xLabels: labels, + font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), + lineWidth: this.options.scaleLineWidth, + lineColor: this.options.scaleLineColor, + showHorizontalLines: this.options.scaleShowHorizontalLines, + showVerticalLines: this.options.scaleShowVerticalLines, + 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.borderWidth, + showLabels: this.options.scaleShowLabels, + display: this.options.showScale + }; + + if (this.options.scaleOverride) { + helpers.extend(scaleOptions, { + calculateYRange: helpers.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(scaleOptions); + }, + // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function + redraw: function() { + var base = this.calculateBaseY(); + this.eachElement(function(element, index, datasetIndex) { + helpers.extend(element, { + y: base, + base: base + }); + }); + this.render(); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + this.scale.draw(easingDecimal); + + //Draw all the bars for each dataset + this.eachElement(function(bar, index, datasetIndex) { + if (bar.hasValue()) { + // Update the bar basepoint + bar.base = this.calculateBaseY(); + //Transition + bar.transition(easingDecimal).draw(); + } + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + } + }); - //Draw the line between all the points - ctx.lineWidth = this.options.datasetStrokeWidth; - ctx.strokeStyle = dataset.strokeColor; - ctx.beginPath(); +}).call(this); - helpers.each(pointsWithValues, function(point, index){ - if (index === 0){ - ctx.moveTo(point.x, point.y); - } - else{ - if(this.options.bezierCurve){ - var previous = previousPoint(point, pointsWithValues, index); - - ctx.bezierCurveTo( - previous.controlPoints.outer.x, - previous.controlPoints.outer.y, - point.controlPoints.inner.x, - point.controlPoints.inner.y, - point.x, - point.y - ); - } - else{ - ctx.lineTo(point.x,point.y); - } - } - }, this); +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; + + var defaultConfig = { + //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 + borderWidth: 2, + + //The percentage of the chart that we cut out of the middle. + cutoutPercentage: 50, + + // The duration of animations triggered by hover events + hoverAnimationDuration: 400, + + //String - Animation easing effect + animationEasing: "easeOutQuart", + + //Boolean - Whether we animate the rotation of the Doughnut + animateRotate: true, + + //Boolean - Whether we animate scaling the Doughnut from the centre + animateScale: false, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " + + }; + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "Doughnut", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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) { + + // Save data as a source for updating of values & methods + this.data = data; + + // Slice Type and defaults + this.Slice = Chart.Arc.extend({ + _chart: this.chart, + x: this.chart.width / 2, + y: this.chart.height / 2 + }); + + //Set up tooltip events on the chart + if (this.options.showTooltips) { + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + } + + // Create new slice for each piece of data + this.data.metaData = []; + helpers.each(this.data.data, function(slice, index) { + var metaSlice = new this.Slice(); + if (typeof slice == 'number') { + helpers.extend(metaSlice, { + value: slice + }); + } else { + helpers.extend(metaSlice, slice); + } + helpers.extend(metaSlice, { + startAngle: Math.PI * 1.5, + circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animateScale) ? 0 : this.outerRadius, + innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, + }); + if (!metaSlice.backgroundColor) { + slice.backgroundColor = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; + } + metaSlice.save(); + this.data.metaData.push(metaSlice); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.update(); + }, + onHover: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = this.getSliceAtEvent(e); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + this.lastActive[0].backgroundColor = this.data.data[this.lastActive[0]._index].backgroundColor; + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.data.data[this.active[0]._index].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + } + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + helpers.each(this.data.metaData, function(slice, index) { + if (slice.inRange(location.x, location.y)) elements.push(slice); + }, this); + return elements; + }, + calculateCircumference: function(value) { + if (this.total > 0) { + return (Math.PI * 2) * (value / this.total); + } else { + return 0; + } + }, + update: function() { + + // Calc Total + this.total = 0; + helpers.each(this.data.data, function(slice) { + this.total += Math.abs(slice.value); + }, this); + + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.borderWidth / 2) / 2; + + // Map new data to data points + helpers.each(this.data.metaData, function(slice, index) { + + var datapoint = this.data.data[index]; + + helpers.extend(slice, { + _index: index, + x: this.chart.width / 2, + y: this.chart.height / 2, + value: datapoint.value, + label: datapoint.label, + circumference: this.calculateCircumference(datapoint.value), + outerRadius: this.outerRadius, + innerRadius: (this.outerRadius / 100) * this.options.cutoutPercentage, + + backgroundColor: datapoint.backgroundColor, + hoverBackgroundColor: datapoint.hoverBackgroundColor || datapoint.backgroundColor, + borderWidth: this.options.borderWidth, + borderColor: this.options.segmentStrokeColor, + }); + + helpers.extend(slice, { + endAngle: slice.startAngle + slice.circumference, + }); + + if (index === 0) { + slice.startAngle = Math.PI * 1.5; + } + + //Check to see if it's the last slice, if not get the next and update its start angle + if (index < this.data.data.length - 1) { + this.data.metaData[index + 1].startAngle = slice.endAngle; + } + + slice.pivot(); + + }, this); + + this.render(); + }, + draw: function(easeDecimal) { + easeDecimal = easeDecimal || 1; + this.clear(); + + helpers.each(this.data.metaData, function(slice, index) { + slice.transition(easeDecimal).draw(); + }, this); + + this.tooltip.transition(easeDecimal).draw(); + } + }); + + Chart.types.Doughnut.extend({ + name: "Pie", + defaults: helpers.merge(defaultConfig, { + cutoutPercentage: 0 + }) + }); - ctx.stroke(); +}).call(this); - if (this.options.datasetFill && pointsWithValues.length > 0){ - //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(pointsWithValues[pointsWithValues.length - 1].x, this.scale.endPoint); - ctx.lineTo(pointsWithValues[0].x, this.scale.endPoint); - ctx.fillStyle = dataset.fillColor; - ctx.closePath(); - ctx.fill(); - } +(function() { + "use strict"; - //Now draw the points over the line - //A little inefficient double looping, but better than the line - //lagging behind the point positions - helpers.each(pointsWithValues,function(point){ - point.draw(); - }); - },this); - } - }); + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + + ///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 to show horizontal lines (except X axis) + scaleShowHorizontalLines: true, + + //Boolean - Whether to show vertical lines (except Y axis) + scaleShowVerticalLines: true, + + //Number - Tension of the bezier curve between points + tension: 0.4, + + //Number - Radius of each point dot in pixels + pointRadius: 4, + + //Number - Pixel width of point dot border + pointBorderWidth: 1, + + //Number - amount extra to add to the radius to cater for hit detection outside the drawn point + pointHoverRadius: 20, + + //Number - Pixel width of dataset border + borderWidth: 2, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", + + //Boolean - Whether to horizontally center the label and point dot inside the grid + offsetGridLines: false + + }; + + + Chart.Type.extend({ + name: "Line", + defaults: defaultConfig, + initialize: function(data) { + // Save data as a source for updating of values & methods + this.data = data; + + //Custom Point Defaults + this.PointClass = Chart.Point.extend({ + _chart: this.chart, + offsetGridLines: this.options.offsetGridLines, + borderWidth: this.options.pointBorderWidth, + radius: this.options.pointRadius, + hoverRadius: this.options.pointHoverRadius, + }); + + // Events + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + + // Build Scale + this.buildScale(this.data.labels); + + + //Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaDataset = new Chart.Line(); + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new this.PointClass()); + }, this); + }, this); + + // Set defaults for lines + this.eachDataset(function(dataset, datasetIndex) { + dataset = helpers.merge(this.options, dataset); + helpers.extend(dataset.metaDataset, { + _points: dataset.metaData, + _datasetIndex: datasetIndex, + _chart: this.chart, + }); + // Copy to view model + dataset.metaDataset.save(); + }, this); + + // Set defaults for points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + x: this.scale.calculateX(index), + y: this.scale.endPoint, + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart + }); + + // Default bezier control points + helpers.extend(point, { + controlPointPreviousX: this.previousPoint(dataset, index).x, + controlPointPreviousY: this.nextPoint(dataset, index).y, + controlPointNextX: this.previousPoint(dataset, index).x, + controlPointNextY: this.nextPoint(dataset, index).y, + }); + // Copy to view model + point.save(); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index - 1] || collection[index]; + }, + previousPoint: function(collection, index) { + return collection[index + 1] || collection[index]; + }, + onHover: function(e) { + + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; + this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; + this.lastActive[0].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBackgroundColor; + this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBorderColor; + this.lastActive[i].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderWidth = this.data.datasets[this.active[0]._datasetIndex].borderWidth + 10; + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderWidth = this.data.datasets[this.active[i]._datasetIndex].borderWidth + 2; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, + update: function() { + + this.scale.update(); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + helpers.extend(dataset.metaDataset, { + backgroundColor: dataset.backgroundColor || this.options.backgroundColor, + borderWidth: dataset.borderWidth || this.options.borderWidth, + borderColor: dataset.borderColor || this.options.borderColor, + tension: dataset.tension || this.options.tension, + scaleTop: this.scale.startPoint, + scaleBottom: this.scale.endPoint, + _points: dataset.metaData, + _datasetIndex: datasetIndex, + }); + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + x: this.scale.calculateX(index), + y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), + value: this.data.datasets[datasetIndex].data[index], + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + // Appearance + hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, + hoverBorderColor: this.data.datasets[datasetIndex].pointHoverBorderColor || this.options.pointHoverBorderColor, + hoverRadius: this.data.datasets[datasetIndex].pointHoverRadius || this.options.pointHoverRadius, + radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, + borderColor: this.data.datasets[datasetIndex].pointBorderColor || this.options.pointBorderColor, + backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, + tension: this.data.datasets[datasetIndex].metaDataset.tension, + _datasetIndex: datasetIndex, + _index: index, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index), + point, + this.nextPoint(dataset, index), + point.tension + ); + + point.controlPointPreviousX = controlPoints.previous.x; + point.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.scale.endPoint) { + point.controlPointNextY = this.scale.endPoint; + } else if (controlPoints.next.y < this.scale.startPoint) { + point.controlPointNextY = this.scale.startPoint; + } else { + point.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.scale.endPoint) { + point.controlPointPreviousY = this.scale.endPoint; + } else if (controlPoints.previous.y < this.scale.startPoint) { + point.controlPointPreviousY = this.scale.startPoint; + } else { + point.controlPointPreviousY = controlPoints.previous.y; + } + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(); + }, + buildScale: function(labels) { + var self = this; + + var dataTotal = function() { + var values = []; + self.eachValue(function(value) { + values.push(value); + }); + + return values; + }; + + var scaleOptions = { + templateString: this.options.scaleLabel, + height: this.chart.height, + width: this.chart.width, + ctx: this.chart.ctx, + textColor: this.options.scaleFontColor, + offsetGridLines: this.options.offsetGridLines, + fontSize: this.options.scaleFontSize, + fontStyle: this.options.scaleFontStyle, + fontFamily: this.options.scaleFontFamily, + valuesCount: labels.length, + beginAtZero: this.options.scaleBeginAtZero, + integersOnly: this.options.scaleIntegersOnly, + calculateYRange: function(currentHeight) { + var updatedRanges = helpers.calculateScaleRange( + dataTotal(), + currentHeight, + this.fontSize, + this.beginAtZero, + this.integersOnly + ); + helpers.extend(this, updatedRanges); + }, + xLabels: this.data.labels, + font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), + lineWidth: this.options.scaleLineWidth, + lineColor: this.options.scaleLineColor, + showHorizontalLines: this.options.scaleShowHorizontalLines, + showVerticalLines: this.options.scaleShowVerticalLines, + 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.pointRadius + this.options.pointBorderWidth, + showLabels: this.options.scaleShowLabels, + display: this.options.showScale + }; + + if (this.options.scaleOverride) { + helpers.extend(scaleOptions, { + calculateYRange: helpers.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 Chart.Scale(scaleOptions); + }, + redraw: function() { + + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + this.scale.draw(easingDecimal); + + this.eachDataset(function(dataset, datasetIndex) { + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + } + }); }).call(this); diff --git a/Chart.min.js b/Chart.min.js index 0b03b1c444a..a83c0899616 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,6 +7,6 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,s=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=s,i=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,n.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},i.types={};var n=i.helpers={},s=n.each=function(t,e,i){var n=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;n--){var s=t[n];if(e(s))return s}},n.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},n=function(){this.constructor=i};return n.prototype=e.prototype,i.prototype=new n,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),c=n.noop=function(){},u=n.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=n.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=n.amd="function"==typeof define&&define.amd,g=n.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=n.max=function(t){return Math.max.apply(Math,t)},v=n.min=function(t){return Math.min.apply(Math,t)},m=(n.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},n.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=n.radians=function(t){return t*(Math.PI/180)},y=(n.getAngleFromPoint=function(t,e){var i=e.x-t.x,n=e.y-t.y,s=Math.sqrt(i*i+n*n),a=2*Math.PI+Math.atan2(n,i);return 0>i&&0>n&&(a+=2*Math.PI),{angle:a,distance:s}},n.aliasPixel=function(t){return t%2===0?0:.5}),w=(n.splineCurve=function(t,e,i,n){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=n*s/(s+a),r=n*a/(s+a);return{inner:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},outer:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},n.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),S=(n.calculateScaleRange=function(t,e,i,n,s){var a=2,o=Math.floor(e/(1.5*i)),r=a>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!n?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=n?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(s&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=a,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},n.template=function(t,e){function i(t,e){var i=/\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('');"):n[t]=n[t];return e?i(e):i}if(t instanceof Function)return t(e);var n={};return i(t,e)}),x=(n.generateLabels=function(t,e,i,n){var a=new Array(e);return t&&s(a,function(e,s){a[s]=S(t,{value:i+n*(s+1)})}),a},n.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 e=1.70158,i=0,n=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),nt?-.5*n*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):n*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),C=n.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(n.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),n.animationLoop=function(t,e,i,n,s,a){var o=0,r=x[i]||x.linear,h=function(){o++;var i=o/e,l=r(i);t.call(a,l,i,o),n.call(a,l,i),e>o?a.animationFrame=C(h):s.apply(a)};C(h)},n.getRelativePosition=function(t){var e,i,n=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return n.touches?(e=n.touches[0].clientX-a.left,i=n.touches[0].clientY-a.top):(e=n.clientX-a.left,i=n.clientY-a.top),{x:e,y:i}},n.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=n.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},L=(n.bindEvents=function(t,e,i){t.events||(t.events={}),s(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},n.unbindEvents=function(t,e){s(e,function(e,i){P(t.chart.canvas,i,e)})}),A=n.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-left"))+parseInt(F(e,"padding-right"));return e.clientWidth-i},M=n.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(F(e,"padding-bottom"))+parseInt(F(e,"padding-top"));return e.clientHeight-i},F=n.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},R=(n.getMaximumSize=n.getMaximumWidth,n.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,n=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=n+"px",e.canvas.height=n*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),W=n.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},z=n.fontString=function(t,e,i){return e+" "+t+"px "+i},T=n.longestText=function(t,e,i){t.font=e;var n=0;return s(i,function(e){var i=t.measureText(e).width;n=i>n?i:n}),n},_=n.drawRoundedRectangle=function(t,e,i,n,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+n-a,i),t.quadraticCurveTo(e+n,i,e+n,i+a),t.lineTo(e+n,i+s-a),t.quadraticCurveTo(e+n,i+s,e+n-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};n.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},n.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e,n){this.options=e,this.chart=n,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return W(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=A(this.chart.canvas),n=this.options.maintainAspectRatio?i/this.chart.aspectRatio:M(this.chart.canvas);return e.width=this.chart.width=i,e.height=this.chart.height=n,R(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t,e){if(t&&this.reflow(),this.options.animation&&!t){var s=new i.Animation;s.numSteps=(e||this.options.animationDuration)/16.66,s.easing=this.options.animationEasing,s.render=function(t,e){var i=n.easingEffects[e.easing],s=e.currentStep/e.numSteps,a=i(s);t.draw(a,s,e.currentStep)},s.onAnimationProgress=this.options.onAnimationProgress,s.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,s,e)}else this.draw(),this.options.onAnimationComplete.call(this);return this},generateLegend:function(){return S(this.options.legendTemplate,this)},destroy:function(){this.clear(),L(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,n=function(){return e.apply(this,arguments)};if(n.prototype=a(e.prototype),o(n.prototype,t),n.extend=i.Type.extend,t.name||e.prototype.name){var s=t.name||e.prototype.name,h=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[s]=o(h,t.defaults),i.types[s]=n,i.prototype[s]=function(t,e){var a=r(i.defaults.global,i.defaults[s],e||{});return new n(t,a,this)}}else d("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,{_vm:{}}),o(this,t),this.initialize.apply(this,arguments)},o(i.Element.prototype,{initialize:function(){},save:function(){return this._vm=a(this),delete this._vm._vm,delete this._vm._start,this},pivot:function(){return this._start&&(this._start=a(this),n.extend(this._start,this._vm)),this},transition:function(t){return this._start||(this._start=a(this._vm)),s(this,function(e,i){if("_"!==i[0]&&this.hasOwnProperty(i)){if(!this._vm[i])return void(this._vm[i]=e||null);if(this[i]!==this._vm[i])if("string"==typeof e)try{var s=n.color(this._start[i]).mix(n.color(this[i]),t);this._vm[i]=s.rgbString()}catch(a){this._vm[i]=e}else"number"==typeof e?this._vm[i]=(this[i]-this._start[i])*t+this._start[i]:this._vm[i]=e}},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return g(this.value)}}),i.Element.extend=l,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return s&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.borderColor,e.lineWidth=this.borderWidth,e.fillStyle=this.backgroundColor,e.fill(),e.lineJoin="bevel",this.showBorder&&e.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,n=t.x-i,s=t.x+i,a=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(n+=o,s-=o,a+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(n,t.base),e.lineTo(n,a),e.lineTo(s,a),e.lineTo(s,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},tooltipPosition:function(){var t=this._vm;return t.y=0&&(i=this._data.datasets[r].metaData,s=h(i,this._active[0]),-1===s);r--);var l=function(t){var e,i,r,h,l,c=[],u=[],d=[];return n.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])}),n.each(c,function(t){u.push(t._vm.x),d.push(t._vm.y),a.push(n.template(this._options.multiTooltipTemplate,t)),o.push({fill:t._vm.backgroundColor,stroke:t._vm.borderColor})},this),l=v(d),r=f(d),h=v(u),i=f(u),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,s);n.extend(this,{x:l.x,y:l.y,labels:a,title:this._active.length?this._active[0].label:"",legendColors:o,legendBackgroundColor:this._options.multiTooltipKeyBackground}),this.height=a.length*this.fontSize+(a.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize;var c=t.measureText(this.title).width,u=T(t,this.font,a)+this.fontSize+3,d=f([u,c]);this.width=d+2*this.xPadding;var p=this.height/2;this.y-p<0?this.y=p:this.y+p>this._chart.height&&(this.y=this._chart.height-p),this.x>this._chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._vm;switch(this._options.hoverMode){case"single":t.font=z(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding=2,s=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,o=a+e.caretHeight+i;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-o;if(t.fillStyle=n.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._vm);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}_(t,r,h,s,a,e.cornerRadius),t.fill(),t.fillStyle=n.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+a/2)}break;case"label":_(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=n.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=n.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=z(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=z(e.fontSize,e._fontStyle,e._fontFamily),n.each(e.labels,function(i,s){t.fillStyle=n.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=n.color(e.legendBackgroundColor).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize),t.fillStyle=n.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._vm.y-this._vm.height/2+this._vm.yPadding,i=t-1;return 0===t?e+this._vm.titleFontSize/2:e+(1.5*this._vm.fontSize*i+this._vm.fontSize/2)+1.5*this._vm.titleFontSize}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?T(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var s,a=T(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)s=Math.cos(b(this.xLabelRotation)),t=s*i,e=s*n,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=s*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*a+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),n=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(n+=i/2),Math.round(n)},update:function(t){n.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,s(this.yLabels,function(s,a){var o=this.endPoint-e*a,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(s,i-10,o),0!==a||h||(h=!0),h&&t.beginPath(),a>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=n.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),s(this.xLabels,function(e,i){var n=this.calculateX(i)+y(this.lineWidth),s=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),a=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(t.moveTo(s,this.endPoint),t.lineTo(s,this.startPoint-3),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(s,this.endPoint),t.lineTo(s,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(n,a?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=a?"right":"center",t.textBaseline=a?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(S(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,n,s,a,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+n,s=e),t.x-np&&(p=t.x+i,s=e):e>this.valuesCount/2&&t.x-i0){var n,s=i*(this.drawingArea/this.steps),a=this.yCenter-s;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var n=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],n.x,n.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var s=Date.now(),a=s-t-this.frameDuration,o=a/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&n.requestAnimFrame.call(window,this.digestWrapper)}},n.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){s(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,hoverMode:"single",onHover:null,hoverAnimationDuration:400,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:n,initialize:function(t){this.data=t;var n=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.calculateX(i)-s/2,o=this.calculateBarWidth(t);return a+o*e+e*n.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*n.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*n.barDatasetSpacing;return e/t}}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx}),this.buildScale(t.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachBars(function(t,e,n){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,n,e),y:this.calculateBarBase(),_datasetIndex:n,_index:e}),t.save()},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return!1;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hoverMode){case"single":return this.getBarAtEvent(t);case"label":return this.getBarsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive)switch(this.options.hoverMode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].borderColor, -this.lastActive[0].borderWidth=0;break;case"label":for(var e=0;e=0||this.scale.min>=0&&this.scale.max<=0?(t=this.scale.calculateY(0),t+=this.options.scaleGridLineWidth):this.scale.min<0&&this.scale.max<0&&(t=this.scale.startPoint),t},update:function(){this.scale.update(),this.eachBars(function(t,e,n){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,n,e),y:this.scale.calculateY(this.data.datasets[n].data[e]),value:this.data.datasets[n].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[n].label,borderColor:this.data.datasets[n].borderColor,borderWidth:this.data.datasets[n].borderWidth,backgroundColor:this.data.datasets[n].backgroundColor,_datasetIndex:n,_index:e,_start:void 0})},this),this.render()},eachBars:function(t){i.each(this.data.datasets,function(e,n){i.each(e.metaData,t,this,n)},this)},eachValue:function(t){i.each(this.data.datasets,function(e,n){i.each(e.data,t,this,n)},this)},getBarsAtEvent:function(t){for(var e,n=[],s=i.getRelativePosition(t),a=function(t){n.push(t.metaData[e])},o=0;o<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Doughnut",defaults:n,initialize:function(t){this.data=t,this.segments=[],this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=e.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),i.each(t,function(e,i){e.color||(e.color="hsl("+360*i/t.length+", 100%, 50%)"),this.addData(e,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],n=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(n.x,n.y)&&e.push(t)},this),e},addData:function(t,e,i){var n=e||this.segments.length;this.segments.splice(n,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})),i||(this.reflow(),this.update())},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{value:t.value,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,label:t.label})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.activeElements,function(t){t.restore(["fillColor"])}),i.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,i.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var e=t?t:1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:n,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({offsetGridLines:this.options.offsetGridLines,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)0&&ethis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(n.lineTo(r[r.length-1].x,this.scale.endPoint),n.lineTo(r[0].x,this.scale.endPoint),n.fillStyle=t.fillColor,n.closePath(),n.fill()),i.each(r,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={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:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"PolarArea",defaults:n,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],n=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(n.x,n.y)&&e.push(t)},this),e},addData:function(t,e,i){var n=e||this.segments.length;this.segments.splice(n,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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.push(t.value)});var n=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,n,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var n={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(n),i.each(e.data,function(i,s){var a;this.scale.animation||(a=this.scale.getPointPosition(s,this.scale.calculateCenterOffset(i))),n.points.push(new this.PointClass({value:i,label:t.labels[s],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),n=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),s=2*Math.PI/this.scale.valuesCount,a=Math.round((n.angle-1.5*Math.PI)/s),o=[];return(a>=this.scale.valuesCount||0>a)&&(a=0),n.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[a])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),n=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,n)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var n=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:n.x,y:n.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(n,s){i.extend(this.datasets[e].points[s],{value:n,label:this.data.labels[s],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,n=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),n.lineWidth=this.options.datasetStrokeWidth,n.strokeStyle=t.strokeColor,n.beginPath(),i.each(t.points,function(t,e){0===e?n.moveTo(t.x,t.y):n.lineTo(t.x,t.y)},this),n.closePath(),n.stroke(),n.fillStyle=t.fillColor,n.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,n){function s(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return s(i?i:t)},c,c.exports,t,e,i,n)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,n=this.alpha()-t.alpha(),s=((i*n==-1?i:(i+n)/(1+i*n))+1)/2,a=1-s,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),n=(r+h)/2,i=h==r?0:.5>=n?l/(h+r):l/(2-h-r),[e,100*i,100*n]}function s(t){var e,i,n,s=t[0],a=t[1],o=t[2],r=Math.min(s,a,o),h=Math.max(s,a,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(a-o)/l:a==h?e=2+(o-s)/l:o==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),n=h/255*1e3/10,[e,i,n]}function a(t){var e=t[0],i=t[1],s=t[2],a=n(t)[0],o=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*o,100*s]}function o(t){var e,i,n,s,a=t[0]/255,o=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-o,1-r),e=(1-a-s)/(1-s)||0,i=(1-o-s)/(1-s)||0,n=(1-r-s)/(1-s)||0,[100*e,100*i,100*n,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var s=.4124*e+.3576*i+.1805*n,a=.2126*e+.7152*i+.0722*n,o=.0193*e+.1192*i+.9505*n;return[100*s,100*a,100*o]}function c(t){var e,i,n,s=l(t),a=s[0],o=s[1],r=s[2];return a/=95.047,o/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(a-o),n=200*(o-r),[e,i,n]}function u(t){return V(c(t))}function d(t){var e,i,n,s,a,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)n=o+1/3*-(l-1),0>n&&n++,n>1&&n--,a=1>6*n?e+6*(i-e)*n:1>2*n?i:2>3*n?e+(i-e)*(2/3-n)*6:e,s[l]=255*a;return s}function p(t){var e,i,n=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[n,100*e,100*i]}function f(t){return a(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,n=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),o=255*n*(1-i),r=255*n*(1-i*a),h=255*n*(1-i*(1-a)),n=255*n;switch(s){case 0:return[n,h,o];case 1:return[r,n,o];case 2:return[o,n,h];case 3:return[o,r,n];case 4:return[h,o,n];case 5:return[n,o,r]}}function w(t){var e,i,n=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[n,100*e,100*i]}function S(t){return a(y(t))}function x(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,n,s,a=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*a),i=1-h,n=6*a-e,0!=(1&e)&&(n=1-n),s=o+n*(i-o),e){default:case 6:case 0:r=i,g=s,b=o;break;case 1:r=s,g=i,b=o;break;case 2:r=o,g=i,b=s;break;case 3:r=o,g=s,b=i;break;case 4:r=s,g=o,b=i;break;case 5:r=i,g=o,b=s}return[255*r,255*g,255*b]}function P(t){return n(k(t))}function L(t){return s(k(t))}function A(t){return o(k(t))}function M(t){return h(k(t))}function F(t){var e,i,n,s=t[0]/100,a=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),n=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*n]}function R(t){return n(F(t))}function W(t){return s(F(t))}function z(t){return a(F(t))}function T(t){return h(F(t))}function _(t){var e,i,n,s=t[0]/100,a=t[1]/100,o=t[2]/100;return e=3.2406*s+-1.5372*a+o*-.4986,i=s*-.9689+1.8758*a+.0415*o,n=.0557*s+a*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),n=Math.min(Math.max(0,n),1),[255*e,255*i,255*n]}function I(t){var e,i,n,s=t[0],a=t[1],o=t[2];return s/=95.047,a/=100,o/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*a-16,i=500*(s-a),n=200*(a-o),[e,i,n]}function O(t){return V(I(t))}function B(t){var e,i,n,s,a=t[0],o=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+s-16/116)/7.787:95.047*Math.pow(o/500+s,3),n=.008859>=n/108.883?n=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,n]}function V(t){var e,i,n,s=t[0],a=t[1],o=t[2];return e=Math.atan2(o,a),i=360*e/2/Math.PI,0>i&&(i+=360),n=Math.sqrt(a*a+o*o),[s,n,i]}function E(t){return _(B(t))}function D(t){var e,i,n,s=t[0],a=t[1],o=t[2];return n=o/360*2*Math.PI,e=a*Math.cos(n),i=a*Math.sin(n),[s,e,i]}function H(t){return B(D(t))}function q(t){return E(D(t))}function X(t){return U[t]}function Y(t){return n(X(t))}function j(t){return s(X(t))}function N(t){return a(X(t))}function G(t){return o(X(t))}function Z(t){return c(X(t))}function Q(t){return l(X(t))}e.exports={rgb2hsl:n,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:S,hsv2cmyk:x,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:L,hwb2cmyk:A,hwb2keyword:M,cmyk2rgb:F,cmyk2hsl:R,cmyk2hsv:W,cmyk2hwb:z,cmyk2keyword:T,keyword2rgb:X,keyword2hsl:Y,keyword2hsv:j,keyword2hwb:N,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:_,xyz2lab:I,xyz2lch:O,lab2xyz:B,lab2rgb:E,lab2lch:V,lch2lab:D,lch2xyz:H,lch2rgb:q};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var n=t("./conversions"),s=function(){return new l};for(var a in n){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),n[t](e)}}(a);var o=/(\w+)2(\w+)/.exec(a),r=o[1],h=o[2];s[r]=s[r]||{},s[r][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=n[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+n+"%, "+s+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+n+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return S[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:n,getHsla:s,getRgb:o,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var S={};for(var x in w)S[w[x]]=x},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,a.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,hoverMode:"single",onHover:null,hoverAnimationDuration:400,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){},colorFallback:"rgba(0,0,0,0.1)"}},i.types={};var a=i.helpers={},n=a.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;a--){var n=t[a];if(e(n))return n}},a.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),c=a.noop=function(){},u=a.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=a.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=a.amd="function"==typeof define&&define.amd,g=a.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=a.max=function(t){return Math.max.apply(Math,t)},v=a.min=function(t){return Math.min.apply(Math,t)},m=(a.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},a.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=a.radians=function(t){return t*(Math.PI/180)},y=(a.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,n=Math.sqrt(i*i+a*a),s=2*Math.PI+Math.atan2(a,i);return 0>i&&0>a&&(s+=2*Math.PI),{angle:s,distance:n}},a.aliasPixel=function(t){return t%2===0?0:.5}),w=(a.splineCurve=function(t,e,i,a){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=a*n/(n+s),r=a*s/(n+s);return{next:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},previous:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},a.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),x=(a.calculateScaleRange=function(t,e,i,a,n){var s=2,o=Math.floor(e/(1.5*i)),r=s>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!a?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=a?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=s,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},a.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),S=(a.generateLabels=function(t,e,i,a){var s=new Array(e);return t&&n(s,function(e,n){s[n]=x(t,{value:i+a*(n+1)})}),s},a.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-S.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*S.easeInBounce(2*t):.5*S.easeOutBounce(2*t-1)+.5}}),C=a.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(a.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),a.animationLoop=function(t,e,i,a,n,s){var o=0,r=S[i]||S.linear,h=function(){o++;var i=o/e,l=r(i);t.call(s,l,i,o),a.call(s,l,i),e>o?s.animationFrame=C(h):n.apply(s)};C(h)},a.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,n=t.currentTarget||t.srcElement,s=n.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},a.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=a.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},A=(a.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},a.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),L=a.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(_(e,"padding-left"))+parseInt(_(e,"padding-right"));return e.clientWidth-i},M=a.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(_(e,"padding-bottom"))+parseInt(_(e,"padding-top"));return e.clientHeight-i},_=a.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},F=(a.getMaximumSize=a.getMaximumWidth,a.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),R=a.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=a.fontString=function(t,e,i){return e+" "+t+"px "+i},T=a.longestText=function(t,e,i){t.font=e;var a=0;return n(i,function(e){var i=t.measureText(e).width;a=i>a?i:a}),a},z=a.drawRoundedRectangle=function(t,e,i,a,n,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+n-s),t.quadraticCurveTo(e+a,i+n,e+a-s,i+n),t.lineTo(e+s,i+n),t.quadraticCurveTo(e,i+n,e,i+n-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()};a.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},a.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e,a){this.options=e,this.chart=a,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return R(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=L(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:M(this.chart.canvas);return e.width=this.chart.width=i,e.height=this.chart.height=a,F(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},redraw:c,render:function(t){if(this.options.animation){var e=new i.Animation;e.numSteps=(t||this.options.animationDuration)/16.66,e.easing=this.options.animationEasing,e.render=function(t,e){var i=a.easingEffects[e.easing],n=e.currentStep/e.numSteps,s=i(n);t.draw(s,n,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){a.each(this.data.datasets,function(e,i){a.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){a.each(this.data.datasets,function(e,i){a.each(e.data,t,this,i)},this)},eachDataset:function(t){a.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],n=a.getRelativePosition(t),s=function(t){i.push(t.metaData[e])},o=0;o0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.colorFallback,e.lineWidth=t.borderWidth||i.defaults.global.colorFallback,e.fillStyle=t.backgroundColor||i.defaults.global.colorFallback,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._vm,e=this._chart.ctx;e.lineWidth=t.borderWidth||i.defaults.global.colorFallback,e.strokeStyle=t.borderColor||i.defaults.global.colorFallback,e.beginPath(),a.each(t._points,function(i,a){if(0===a)e.moveTo(i._vm.x,i._vm.y);else if(t._tension>0,0)e.lineTo(i._vm.x,i._vm.y);else{var n=this.previousPoint(i,t._points,a);e.bezierCurveTo(n._vm.controlPointNextX,n._vm.controlPointNextY,i._vm.controlPointPreviousX,i._vm.controlPointPreviousY,i._vm.x,i._vm.y)}},this),e.stroke(),t._points.length>0&&(e.lineTo(t._points[t._points.length-1].x,t.scaleBottom),e.lineTo(t._points[0].x,t.scaleBottom),e.fillStyle=t.backgroundColor||i.defaults.global.colorFallback,e.closePath(),e.fill())},previousPoint:function(t,e,i){return a.findPreviousWhere(e,function(){return!0},i)||t}}),i.Arc=i.Element.extend({inRange:function(t,e){var i=a.getAngleFromPoint(this,{x:t,y:e}),n=i.angle>=this.startAngle&&i.angle<=this.endAngle,s=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&s},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(){var t=this._chart.ctx,e=this._vm;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,a=t.x-i,n=t.x+i,s=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(a+=o,n-=o,s+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(a,t.base),e.lineTo(a,s),e.lineTo(n,s),e.lineTo(n,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._vm;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._vm;return t.y=0&&(i=this._data.datasets[r].metaData,n=h(i,this._active[0]),-1===n);r--);var l=function(t){var e,i,r,h,l,c=[],u=[],d=[];return a.each(this._data.datasets,function(t){e=t.metaData,e[n]&&e[n].hasValue()&&c.push(e[n])}),a.each(c,function(t){u.push(t._vm.x),d.push(t._vm.y),s.push(a.template(this._options.multiTooltipTemplate,t)),o.push({fill:t._vm.backgroundColor,stroke:t._vm.borderColor})},this),l=v(d),r=f(d),h=v(u),i=f(u),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,n);a.extend(this,{x:l.x,y:l.y,labels:s,title:this._active.length?this._active[0].label:"",legendColors:o,legendBackgroundColor:this._options.multiTooltipKeyBackground}),this.height=s.length*this.fontSize+(s.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize;var c=t.measureText(this.title).width,u=T(t,this.font,s)+this.fontSize+3,d=f([u,c]);this.width=d+2*this.xPadding;var p=this.height/2;this.y-p<0?this.y=p:this.y+p>this._chart.height&&(this.y=this._chart.height-p),this.x>this._chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._vm;switch(this._options.hoverMode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding=2,n=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,o=s+e.caretHeight+i;e.x+n/2>this._chart.width?e.xAlign="left":e.x-n/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-n/2,h=e.y-o;if(t.fillStyle=a.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._vm);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-n+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}z(t,r,h,n,s,e.cornerRadius),t.fill(),t.fillStyle=a.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+n/2,h+s/2)}break;case"label":z(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=a.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),a.each(e.labels,function(i,n){t.fillStyle=a.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(n+1)),t.fillStyle=a.color(e.legendBackgroundColor).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize),t.fillStyle=a.color(e.legendColors[n].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._vm.y-this._vm.height/2+this._vm.yPadding,i=t-1;return 0===t?e+this._vm.titleFontSize/2:e+(1.5*this._vm.fontSize*i+this._vm.fontSize/2)+1.5*this._vm.titleFontSize}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?T(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,s=T(this.ctx,this.font,this.xLabels);this.xLabelWidth=s;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*a,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*s;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*s+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),a=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(a+=i/2),Math.round(a)},update:function(t){a.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,s){var o=this.endPoint-e*s,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==s||h||(h=!0),h&&t.beginPath(),s>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=a.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var a=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),s=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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(a,s?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=s?"right":"center",t.textBaseline=s?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,a,n,s,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+a,n=e),t.x-ap&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var a,n=i*(this.drawingArea/this.steps),s=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var a=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var s=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],a.x,a.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var n=0;n1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var n=Date.now(),s=n-t-this.frameDuration,o=s/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&a.requestAnimFrame.call(window,this.digestWrapper)}},a.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0, +scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:a,initialize:function(t){this.data=t;var a=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),s=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return s+o*e+e*a.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*a.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*a.barDatasetSpacing;return e/t}}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx}),this.buildScale(this.data.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachElement(function(t,e,a){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,a,e),y:this.calculateBaseY(),_datasetIndex:a,_index:e}),t.save()},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hoverMode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length)switch(this.options.hoverMode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].borderColor;break;case"label":for(var e=0;e=0||this.scale.min>=0&&this.scale.max<=0?(t=this.scale.calculateY(0),t+=this.options.scaleGridLineWidth):this.scale.min<0&&this.scale.max<0&&(t=this.scale.startPoint),t},update:function(){this.scale.update(),this.eachElement(function(t,e,a,n){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,n,e),y:this.scale.calculateY(this.data.datasets[n].data[e]),value:this.data.datasets[n].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[n].label,borderColor:this.data.datasets[n].borderColor,borderWidth:this.data.datasets[n].borderWidth,backgroundColor:this.data.datasets[n].backgroundColor,_datasetIndex:n,_index:e}),t.pivot()},this),this.render()},buildScale:function(t){var e=this,a=function(){var t=[];return e.eachValue(function(e){t.push(e)}),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 e=i.calculateScaleRange(a(),t,this.fontSize,this.beginAtZero,this.integersOnly);i.extend(this,e)},xLabels:t,font:i.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,showHorizontalLines:this.options.scaleShowHorizontalLines,showVerticalLines:this.options.scaleShowVerticalLines,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.borderWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&i.extend(n,{calculateYRange:i.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)},redraw:function(){var t=this.calculateBaseY();this.eachElement(function(e,a,n){i.extend(e,{y:t,base:t})}),this.render()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(e),this.eachElement(function(t,i,a){t.hasValue()&&(t.base=this.calculateBaseY(),t.transition(e).draw())},this),this.tooltip.transition(e).draw()}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={segmentShowStroke:!0,segmentStrokeColor:"#fff",borderWidth:2,cutoutPercentage:50,hoverAnimationDuration:400,animationEasing:"easeOutQuart",animateRotate:!0,animateScale:!1,legendTemplate:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Doughnut",defaults:a,initialize:function(t){this.data=t,this.Slice=e.Arc.extend({_chart:this.chart,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.data.metaData=[],i.each(this.data.data,function(e,a){var n=new this.Slice;"number"==typeof e?i.extend(n,{value:e}):i.extend(n,e),i.extend(n,{startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(n.value),outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout}),n.backgroundColor||(e.backgroundColor="hsl("+360*a/t.length+", 100%, 50%)"),n.save(),this.data.metaData.push(n)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=this.getSliceAtEvent(t),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length&&(this.lastActive[0].backgroundColor=this.data.data[this.lastActive[0]._index].backgroundColor),this.active.length&&this.options.hoverMode&&(this.active[0].backgroundColor=this.data.data[this.active[0]._index].hoverBackgroundColor||i.color(this.data.data[this.active[0]._index].backgroundColor).saturate(.5).darken(.35).rgbString()),this.options.showTooltips&&(this.tooltip.initialize(),this.active.length?(i.extend(this.tooltip,{opacity:1,_active:this.active}),this.tooltip.update()):i.extend(this.tooltip,{opacity:0})),this.tooltip.pivot(),!this.animating){var e;i.each(this.active,function(t,i){t!==this.lastActive[i]&&(e=!0)},this),(!this.lastActive.length&&this.active.length||this.lastActive.length&&!this.active.length||this.lastActive.length&&this.active.length&&e)&&(this.stop(),this.render(this.options.hoverAnimationDuration))}return this.lastActive=this.active,this},getSliceAtEvent:function(t){var e=[],a=i.getRelativePosition(t);return i.each(this.data.metaData,function(t,i){t.inRange(a.x,a.y)&&e.push(t)},this),e},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},update:function(){this.total=0,i.each(this.data.data,function(t){this.total+=Math.abs(t.value)},this),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.borderWidth/2)/2,i.each(this.data.metaData,function(t,e){var a=this.data.data[e];i.extend(t,{_index:e,x:this.chart.width/2,y:this.chart.height/2,value:a.value,label:a.label,circumference:this.calculateCircumference(a.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.cutoutPercentage,backgroundColor:a.backgroundColor,hoverBackgroundColor:a.hoverBackgroundColor||a.backgroundColor,borderWidth:this.options.borderWidth,borderColor:this.options.segmentStrokeColor}),i.extend(t,{endAngle:t.startAngle+t.circumference}),0===e&&(t.startAngle=1.5*Math.PI),e<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:a,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({_chart:this.chart,offsetGridLines:this.options.offsetGridLines,borderWidth:this.options.pointBorderWidth,radius:this.options.pointRadius,hoverRadius:this.options.pointHoverRadius}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.buildScale(this.data.labels),i.each(this.data.datasets,function(t,a){t.metaDataset=new e.Line,t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.PointClass)},this)},this),this.eachDataset(function(t,e){t=i.merge(this.options,t),i.extend(t.metaDataset,{_points:t.metaData,_datasetIndex:e,_chart:this.chart}),t.metaDataset.save()},this),this.eachElement(function(t,e,a,n){i.extend(t,{x:this.scale.calculateX(e),y:this.scale.endPoint,_datasetIndex:n,_index:e,_chart:this.chart}),i.extend(t,{controlPointPreviousX:this.previousPoint(a,e).x,controlPointPreviousY:this.nextPoint(a,e).y,controlPointNextX:this.previousPoint(a,e).x,controlPointNextY:this.nextPoint(a,e).y}),t.save()},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},nextPoint:function(t,e){return t[e-1]||t[e]},previousPoint:function(t,e){return t[e+1]||t[e]},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hoverMode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length)switch(this.options.hoverMode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor,this.lastActive[0].borderWidth=this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth;break;case"label":for(var e=0;ethis.scale.endPoint?t.controlPointNextY=this.scale.endPoint:s.next.ythis.scale.endPoint?t.controlPointPreviousY=this.scale.endPoint:s.previous.y<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"PolarArea",defaults:a,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],a=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(a.x,a.y)&&e.push(t)},this),e},addData:function(t,e,i){var a=e||this.segments.length;this.segments.splice(a,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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.push(t.value)});var a=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,a,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var a={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(a),i.each(e.data,function(i,n){var s;this.scale.animation||(s=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),a.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:s.x,y:this.options.animation?this.scale.yCenter:s.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),a=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,s=Math.round((a.angle-1.5*Math.PI)/n),o=[];return(s>=this.scale.valuesCount||0>s)&&(s=0),a.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[s])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),a=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,a)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var a=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:a.x,y:a.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(a,n){i.extend(this.datasets[e].points[n],{value:a,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,a=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),a.lineWidth=this.options.datasetStrokeWidth,a.strokeStyle=t.strokeColor,a.beginPath(),i.each(t.points,function(t,e){0===e?a.moveTo(t.x,t.y):a.lineTo(t.x,t.y)},this),a.closePath(),a.stroke(),a.fillStyle=t.fillColor,a.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,a){function n(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,a)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),n=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,s=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function n(t){var e,i,a,n=t[0],s=t[1],o=t[2],r=Math.min(n,s,o),h=Math.max(n,s,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(s-o)/l:s==h?e=2+(o-n)/l:o==h&&(e=4+(n-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],i=t[1],n=t[2],s=a(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[s,100*o,100*n]}function o(t){var e,i,a,n,s=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-s,1-o,1-r),e=(1-s-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,a=(1-r-n)/(1-n)||0,[100*e,100*i,100*a,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var n=.4124*e+.3576*i+.1805*a,s=.2126*e+.7152*i+.0722*a,o=.0193*e+.1192*i+.9505*a;return[100*n,100*s,100*o]}function c(t){var e,i,a,n=l(t),s=n[0],o=n[1],r=n[2];return s/=95.047,o/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(s-o),a=200*(o-r),[e,i,a]}function u(t){return E(c(t))}function d(t){var e,i,a,n,s,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)a=o+1/3*-(l-1),0>a&&a++,a>1&&a--,s=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,n[l]=255*s;return n}function p(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return s*=2,n*=1>=s?s:2-s,i=(s+n)/2,e=2*n/(s+n),[a,100*e,100*i]}function f(t){return s(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,n=Math.floor(e)%6,s=e-Math.floor(e),o=255*a*(1-i),r=255*a*(1-i*s),h=255*a*(1-i*(1-s)),a=255*a;switch(n){case 0:return[a,h,o];case 1:return[r,a,o];case 2:return[o,a,h];case 3:return[o,r,a];case 4:return[h,o,a];case 5:return[a,o,r]}}function w(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return i=(2-n)*s,e=n*s,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function x(t){return s(y(t))}function S(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,a,n,s=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*s),i=1-h,a=6*s-e,0!=(1&e)&&(a=1-a),n=o+a*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return a(k(t))}function A(t){return n(k(t))}function L(t){return o(k(t))}function M(t){return h(k(t))}function _(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),a=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*a]}function F(t){return a(_(t))}function R(t){return n(_(t))}function W(t){return s(_(t))}function T(t){return h(_(t))}function z(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*s+o*-.4986,i=n*-.9689+1.8758*s+.0415*o,a=.0557*n+s*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function B(t){var e,i,a,n=t[0],s=t[1],o=t[2];return n/=95.047,s/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*s-16,i=500*(n-s),a=200*(s-o),[e,i,a]}function I(t){return E(B(t))}function O(t){var e,i,a,n,s=t[0],o=t[1],r=t[2];return 8>=s?(i=100*s/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),a=.008859>=a/108.883?a=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,a]}function E(t){var e,i,a,n=t[0],s=t[1],o=t[2];return e=Math.atan2(o,s),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(s*s+o*o),[n,a,i]}function D(t){return z(O(t))}function V(t){var e,i,a,n=t[0],s=t[1],o=t[2];return a=o/360*2*Math.PI,e=s*Math.cos(a),i=s*Math.sin(a),[n,e,i]}function H(t){return O(V(t))}function Y(t){return D(V(t))}function q(t){return U[t]}function X(t){return a(q(t))}function N(t){return n(q(t))}function j(t){return s(q(t))}function G(t){return o(q(t))}function Z(t){return c(q(t))}function Q(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:n,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:x,hsv2cmyk:S,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:A,hwb2cmyk:L,hwb2keyword:M,cmyk2rgb:_,cmyk2hsl:F,cmyk2hsv:R,cmyk2hwb:W,cmyk2keyword:T,keyword2rgb:q,keyword2hsl:X,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:z,xyz2lab:B,xyz2lch:I,lab2xyz:O,lab2rgb:D,lab2lch:E,lch2lab:V,lch2xyz:H,lch2rgb:Y};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var a=t("./conversions"),n=function(){return new l};for(var s in a){n[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return x[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:a,getHsla:n,getRgb:o,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var x={};for(var S in w)x[w[S]]=S},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/samples/doughnut.html b/samples/doughnut.html index 145ff450a1a..19c6a6d0cbf 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -34,27 +34,22 @@ data: [{ value: randomScalingFactor(), backgroundColor: "#F7464A", - hoverBackgroundColor: "#FF5A5E", label: "Red" }, { value: randomScalingFactor(), backgroundColor: "#46BFBD", - hoverBackgroundColor: "#5AD3D1", label: "Green" }, { value: randomScalingFactor(), backgroundColor: "#FDB45C", - hoverBackgroundColor: "#FFC870", label: "Yellow" }, { value: randomScalingFactor(), backgroundColor: "#949FB1", - hoverBackgroundColor: "#A8B3C5", label: "Grey" }, { value: randomScalingFactor(), backgroundColor: "#4D5360", - hoverBackgroundColor: "#616774", label: "Dark Grey" } diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 64e3634ab0a..1fc05581c79 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -117,7 +117,7 @@ // Built in hover styling if (this.active.length && this.options.hoverMode) { - this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.data.data[this.active[0]._index].backgroundColor).saturate(0.5).darken(0.35).rgbString(); } // Built in Tooltips From fff81c455d5919bb58462ea18773da56a0c75fda Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 15 May 2015 23:07:21 -0600 Subject: [PATCH 030/424] Tooltip Position, Active Element Position, Tooltip animation follow --- src/Chart.Core.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index fbb6f539758..939fecf2910 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -939,7 +939,7 @@ Chart.animationService.cancelAnimation(this); return this; }, - resize: function(callback) { + resize: function() { this.stop(); var canvas = this.chart.canvas, newWidth = getMaximumWidth(this.chart.canvas), @@ -950,9 +950,6 @@ retinaScale(this.chart); - if (typeof callback === "function") { - callback.apply(this, Array.prototype.slice.call(arguments, 1)); - } return this; }, redraw: noop, @@ -1279,24 +1276,28 @@ Chart.Arc = Chart.Element.extend({ inRange: function(chartX, chartY) { - var pointRelativePosition = helpers.getAngleFromPoint(this, { + var vm = this._vm; + + var pointRelativePosition = helpers.getAngleFromPoint(vm, { x: chartX, y: chartY }); //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle), - withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius); + var betweenAngles = (pointRelativePosition.angle >= vm.startAngle && pointRelativePosition.angle <= vm.endAngle), + withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); return (betweenAngles && withinRadius); //Ensure within the outside of the arc centre, but inside arc outer }, tooltipPosition: function() { - var centreAngle = this.startAngle + ((this.endAngle - this.startAngle) / 2), - rangeFromCentre = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius; + var vm = this._vm; + + var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), + rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; return { - x: this.x + (Math.cos(centreAngle) * rangeFromCentre), - y: this.y + (Math.sin(centreAngle) * rangeFromCentre) + x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), + y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) }; }, draw: function() { @@ -2312,7 +2313,9 @@ // If the responsive flag is set in the chart instance config // Cascade the resize event down to the chart. if (instance.options.responsive) { - instance.resize(instance.render, true); + instance.resize(); + instance.update(); + instance.render(); } }); }, 50); From b5b00811084e618278550e69e3c247a44163d1fc Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 16 May 2015 19:38:31 -0400 Subject: [PATCH 031/424] Some helper functions needed for better scales. --- src/Chart.Core.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 939fecf2910..f60d7c2e7e0 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -360,6 +360,9 @@ toRadians = helpers.radians = function(degrees) { return degrees * (Math.PI / 180); }, + toDegrees = helpers.toDegrees = function(radians) { + return radians * (180 / Math.PI); + }, // Gets the angle from vertical upright to the point about a centre. getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { var distanceFromXCenter = anglePoint.x - centrePoint.x, @@ -479,6 +482,36 @@ }; }, + // Implementation of the nice number algorithm used in determining where axis labels will go + niceNum = helpers.niceNum = function(range, round) { + var exponent = Math.floor(Math.log10(range)); + var fraction = range / Math.pow(10, exponent); + var niceFraction; + + if (round) { + if (fraction < 1.5) { + niceFraction = 1; + } else if (fraction < 3) { + niceFraction = 2; + } else if (fraction < 7) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } else { + if (fraction <= 1.0) { + niceFraction = 1; + } else if (fraction <= 2) { + niceFraction = 2; + } else if (fraction <= 5) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } + + return niceFraction * Math.pow(10, exponent); + }, /* jshint ignore:start */ // Blows up jshint errors based on the new Function constructor //Templating methods From db1365c8cec4a682690898f8c0565df486aa6165 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 16 May 2015 19:40:52 -0400 Subject: [PATCH 032/424] Initial check in of the scale service and the scale constructor registration. An initial implementation of a linear scale that can be drawn in both horizontal and vertical orientations. --- src/Chart.Scale.js | 655 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 655 insertions(+) create mode 100644 src/Chart.Scale.js diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js new file mode 100644 index 00000000000..3a2495cbef4 --- /dev/null +++ b/src/Chart.Scale.js @@ -0,0 +1,655 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + // The scale service is used to resize charts along with all of their axes. We make this as + // a service where scales are registered with their respective charts so that changing the + // scales does not require + Chart.scaleService = { + registeredCharts: [], + getWrapperForChart: function(chartInstance) { + var wrapper = helpers.findNextWhere(this.registeredCharts, function(charScaleWrapper) { + return charScaleWrapper.chartInstance == chartInstance; + }); + + return wrapper; + }, + registerChartScale: function(chartInstance, scaleInstance) { + var chartScaleWrapper = this.getWrapperForChart(chartInstance); + + if (!chartScaleWrapper) { + chartScaleWrapper = { + scales: [], + chartInstance: chartInstance, + }; + + this.registeredCharts.push(chartScaleWrapper); + } + + chartScaleWrapper.scales.push(scaleInstance); + }, + removeChartScale: function(chartInstance, scaleInstance) { + var chartScaleWrapper = this.getWrapperForChart(chartInstance); + + if (chartScaleWrapper) { + var scaleIndex = helpers.indexOf(scaleWrapper.scales, scaleInstance); + + if (scaleIndex) { + scaleWrapper.scales.splice(scaleIndex, 1); + } + } + }, + // Remove a chart instance from the scale service. Useful when a chart is destroyed + removeChartInstance: function(chartInstance) { + var index = helpers.findNextWhere(this.registeredCharts, function(scaleWrapper) { + return scaleWrapper.chartInstance == chartInstance; + }); + + if (index) { + this.registeredCharts.splice(index, 1); + } + }, + // The interesting function + fitScalesForChart: function(chartInstance, width, height) { + var chartScaleWrapper = this.getWrapperForChart(chartInstance); + + if (chartScaleWrapper) { + var leftScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + return scaleInstance.options.position == "left"; + }); + var rightScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + return scaleInstance.options.position == "right"; + }); + var topScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + return scaleInstance.options.position == "top"; + }); + var bottomScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + return scaleInstance.options.position == "bottom"; + }); + + // Essentially we now have any number of scales on each of the 4 sides. + // Our canvas looks like the following. + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and + // B1 is the bottom axis + // |------------------------------------------------------| + // | | T1 | | + // |----|-----|-------------------------------------|-----| + // | | | | | + // | L1 | L2 | Chart area | R1 | + // | | | | | + // | | | | | + // |----|-----|-------------------------------------|-----| + // | | B1 | | + // | | | | + // |------------------------------------------------------| + + // What we do to find the best sizing, we do the following + // 1. Determine the minimum size of the chart area. + // 2. Split the remaining width equally between each vertical axis + // 3. Split the remaining height equally between each horizontal axis + // 4. Give each scale the maximum size it can be. The scale will return it's minimum size + // 5. Adjust the sizes of each axis based on it's minimum reported size. + // 6. Refit each axis + // 7. Position each axis in the final location + // 8. Tell the chart the final location of the chart area + + // Step 1 + var chartWidth = width / 2; // min 50% + var chartHeight = height / 2; // min 50% + var aspectRatio = chartHeight / chartWidth; + var screenAspectRatio; + + if (chartInstance.options.maintainAspectRatio) { + screenAspectRatio = height / width; + + if (aspectRatio != screenAspectRatio) { + chartHeight = chartWidth * screenAspectRatio; + aspectRatio = screenAspectRatio; + } + } + + // Step 2 + var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); + + // Step 3 + var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); + + // Step 4; + var scalesToMinSize = {}; + + var verticalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); + scalesToMinSize[scaleInstance] = minSize; + }; + + var horizontalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); + scalesToMinSize[scaleInstance] = minSize; + }; + + // vertical scales + helpers.each(leftScales, verticalScaleMinSizeFunction); + helpers.each(rightScales, verticalScaleMinSizeFunction); + + // horizontal scales + helpers.each(topScales, horizontalScaleMinSizeFunction); + helpers.each(bottomScales, horizontalScaleMinSizeFunction); + + // Step 5 + var maxChartHeight = height; + var maxChartWidth = width; + + var chartWidthReduceFunction = function(scaleInstance) { + maxChartWidth -= scalesToMinSize[scaleInstance].width; + }; + + var chartHeightReduceFunction = function(scaleInstance) { + maxChartHeight -= scalesToMinSize[scaleInstance].height; + }; + + helpers.each(leftScales, chartWidthReduceFunction); + helpers.each(rightScales, chartWidthReduceFunction); + helpers.each(topScales, chartHeightReduceFunction); + helpers.each(bottomScales, chartHeightReduceFunction); + + // At this point, maxChartHeight and maxChartWidth are the size the chart area could + // be if the axes are drawn at their minimum sizes. + if (chartInstance.options.maintainAspectRatio) { + // Figure out what the real max size will be + var maxAspectRatio = maxChartHeight / maxChartWidth; + + if (maxAspectRatio != screenAspectRatio) { + // Need to adjust + if (maxChartHeight < maxChartWidth) { + maxChartWidth = maxChartHeight / screenAspectRatio; + } + else { + maxChartHeight = maxChartWidth * screenAspectRatio; + } + } + } + + // Step 6 + var verticalScaleFitFunction = function(scaleInstance) { + var minSize = scalesToMinSize[scaleInstance]; + scaleInstance.fit(minSize.width, maxChartHeight); + }; + + var horizontalScaleFitFunction = function(scaleInstance) { + var minSize = scalesToMinSize[scaleInstance]; + scaleInstance.fit(maxChartWidth, minSize.width); + }; + + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); + + // Step 7 + var totalLeftWidth = 0; + var totalTopHeight = 0; + + // Calculate total width of all left axes + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); + + // Calculate total height of all top axes + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; + }); + + // Position the scales + var left = 0; + var top = 0; + var right = 0; + var bottom = 0; + + var verticalScalePlacer = function(scaleInstance) { + scaleInstance.left = left; + scaleInstance.right = left + scaleInstance.width; + scaleInstance.top = totalTopHeight; + scaleInstance.bottom = totalTopHeight + maxChartHeight; + + // Move to next point + left = scaleInstance.right; + }; + + var horizontalScalePlacer = function(scaleInstance) { + scaleInstance.left = totalLeftWidth; + scaleInstance.right = totalLeftWidth + maxChartWidth; + scaleInstance.top = top; + scaleInstance.bottom = top + scaleInstance.height; + + // Move to next point + top = scaleInstance.bottom; + }; + + helpers.each(leftScales, verticalScalePlacer); + helpers.each(topScales, horizontalScalePlacer); + + // Account for chart width and height + left += maxChartWidth; + top += maxChartHeight; + + helpers.each(rightScales, verticalScalePlacer); + helpers.each(bottomScales, horizontalScalePlacer); + + // Step 8 + chartScaleWrapper.chartInstance.chartArea = { + left: totalLeftWidth, + top: totalTopHeight, + right: totalLeftWidth + maxChartWidth, + bottom: totalTopHeight + maxChartHeight, + }; + } + } + }; + + // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then + // use the new chart options to grab the correct scale + Chart.scales = { + constructors: {}, + // Use a registration function so that we can move to an ES6 map when we no longer need to support + // old browsers + registerScaleType: function(scaleType, scaleConstructor) { + this.constructors[scaleType] = scaleConstructor; + }, + getScaleConstructor: function(scaleType) { + return this.constructors.hasOwnProperty(scaleType) ? this.constructors[scaleType] : undefined; + } + }; + + var LinearScale = Chart.Element.extend({ + calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + generateTicks: function(width, height) { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } + else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks; + + if (this.isHorizontal()) { + maxTicks = Math.min(11, Math.ceil(width / 50)); + } else { + maxTicks = Math.min(11, Math.ceil(height / 50)); + } + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + this.min = Math.min(this.min, 0); + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + this.labels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labelCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labelCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.labels.push(label ? label : ""); // empty string will not render so we're good + }, this); + }, + getPixelForValue: function(value) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + var pixel; + var range = this.max - this.min; + + if (this.isHorizontal()) { + pixel = this.left + (this.width / range * (value - this.min)); + } else { + // Bottom - top since pixels increase downard on a screen + pixel = this.bottom - (this.height / range * (value - this.min)); + } + + return pixel; + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.generateTicks(maxWidth, maxHeight); + this.buildLabels(); + + var minSize = { + width: 0, + height: 0, + }; + + if (this.isHorizontal()) { + minSize.width = maxWidth; // fill all the width + + // In a horizontal axis, we need some room for the scale to be drawn + // + // ----------------------------------------------------- + // | | | | | + // + minSize.height = this.options.gridLines.show ? 25 : 0; + } else { + minSize.height = maxHeight; // fill all the height + + // In a vertical axis, we need some room for the scale to be drawn. + // The actual grid lines will be drawn on the chart area, however, we need to show + // ticks where the axis actually is. + // We will allocate 25px for this width + // | + // -| + // | + // | + // -| + // | + // | + // -| + minSize.width = this.options.gridLines.show ? 25 : 0; + } + + if (this.options.labels.show) { + // Don't bother fitting the labels if we are not showing them + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.isHorizontal()) { + // A horizontal axis is more constrained by the height. + var maxLabelHeight = maxHeight - minSize.height; + + // Calculate the label rotation + var labelHeight = this.calculateLabelRotation(minSize.width, maxLabelHeight); + minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + } else { + // A vertical axis is more constrained by the width. Labels are the dominant factor + // here, so get that length first + var maxLabelWidth = maxWidth - minSize.width; + var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (largestTextWidth < maxLabelWidth) { + // We don't need all the room + minSize.width += largestTextWidth; + } else { + // Expand to max size + minSize.width = maxWidth; + } + } + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Function calculate the needed rotation of the labels. Should only be used in horizontal mode + // @param {number} width : the available width + // @param {number} height: the available height + // @return {number} : the height needed by the labels + calculateLabelRotation : function(width, height){ + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + + this.labelRotation = 0; // reset + + // Steps + // 1. determine if we need to overlap + // 2. if overlap, determine max rotation + // 3. Rotate until no overlap + // 4. Save rotation + // 5. Return height needed for rotation + var longestTextWidth = helpers.longestText(this.ctx, labelFont, this.lables); + var maxAvailableWidth = (width / (this.ticks.length - 1)) - 6; + + // 6 adds 3px of padding on each end of the label + if (longestTextWidth > maxAvailableWidth) { + // Ok, we need to rotate. Do steps 2-4 + var idealRotation = Math.floor(helpers.toDegrees(Math.asin(height / longestTextWidth))); + var maxRotation = Math.min(90, idealRotation); + + // Increment the rotation in 1 degree steps (step 3) + for (var rotation = 1; rotation < maxRotation; ++rotation) { + var cosRotation = Math.cos(helpers.toRadians(rotation)); + this.labelRotation = rotation; // step 4 + + if (cosRotation * longestTextWidth <= maxAvailableWidth) { + // Rotated enough + break; + } + } + + // step 5 + return Math.min(height, longestTextWidth * Math.sin(this.labelRotation)); + } else { + // Height only constrained by text font size and padding + var idealHeight = this.options.labels.fontSize + 10; // add 10 for padding + return Math.min(height, idealHeight); + } + }, + + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.show) { + + var setContextLineSettings; + var hasZero; + + if (this.isHorizontal()) { + if (this.options.gridLines.show) { + // Draw the horizontal line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + + this.ctx.beginPath(); + + if (this.options.position == "top") { + this.ctx.moveTo(this.left, this.bottom - 5); + this.ctx.lineTo(this.right, this.bottom - 5); + } else { + // On bottom, so draw horizontal line on the top + this.ctx.moveTo(this.left, this.top + 5); + this.ctx.lineTo(this.right, this.top + 5); + } + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are vertical + var xValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the left if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xValue, chartArea.top); + this.ctx.lineTo(xValue, chartArea.bottom); + } + }, this); + + this.ctx.stroke(); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartY; + + if (this.options.position == "top") { + labelStartY = this.top; + } else { + // bottom side + labelStartY = this.top + 20; + } + + this.ctx.textAlign = "center"; + this.ctx.textBaseline = "top"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var xValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, xValue, labelStartY); + }, this); + } + } else { + // Vertical + if (this.options.gridLines.show) { + + // Draw the vertical line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; + var xTickStart = this.options.position == "left" ? this.left : this.right - 10; + var xTickEnd = this.options.position == "left" ? this.left + 10 : this.right; + + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + + this.ctx.beginPath(); + + if (this.options.position == "left") { + this.ctx.moveTo(this.right - 5, this.top); + this.ctx.lineTo(this.right - 5, this.bottom); + } else { + // On right, so draw vertical line on left size of axis block + this.ctx.moveTo(this.left + 5, this.top); + this.ctx.lineTo(this.left + 5, this.bottom); + } + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are horizontal + var yValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the bottom if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + // Draw the label area + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(chartArea.left, yValue); + this.ctx.lineTo(chartArea.right, yValue); + } + }, this); + + this.ctx.stroke(); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartX; + var maxLabelWidth = this.width - 25; + + if (this.options.position == "left") { + labelStartX = this.left; + } else { + // right side + labelStartX = this.left + 20; + } + + this.ctx.textAlign = "left"; + this.ctx.textBaseline = "middle"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var yValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, labelStartX, yValue, maxLabelWidth); + }, this); + } + } + } + } + }); + Chart.scales.registerScaleType("linear", LinearScale); +}).call(this); \ No newline at end of file From d7ad5b6340d1200570b904cce09a1960c8088e55 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 17 May 2015 13:19:37 -0400 Subject: [PATCH 033/424] Add a scatter chart sample --- samples/scatter.html | 145 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 samples/scatter.html diff --git a/samples/scatter.html b/samples/scatter.html new file mode 100644 index 00000000000..afb04edc854 --- /dev/null +++ b/samples/scatter.html @@ -0,0 +1,145 @@ + + + + + Scatter Chart + + + + + +
    +
    + +
    +
    + + + + + From 67b3d32218e1a27d59d13f8fd4eb88282b59e1ac Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 17 May 2015 13:20:37 -0400 Subject: [PATCH 034/424] Initial implementation of a scatter chart. Uses a new style of config from the other charts. For now, the config is not changeable. --- src/Chart.Scale.js | 53 ++++- src/Chart.Scatter.js | 490 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 536 insertions(+), 7 deletions(-) create mode 100644 src/Chart.Scatter.js diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 3a2495cbef4..dcaaefe2ca4 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -55,6 +55,8 @@ // The interesting function fitScalesForChart: function(chartInstance, width, height) { var chartScaleWrapper = this.getWrapperForChart(chartInstance); + var xPadding = 10; + var yPadding = 10; if (chartScaleWrapper) { var leftScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { @@ -70,6 +72,31 @@ return scaleInstance.options.position == "bottom"; }); + // Adjust the padding to take into account displaying labels + if (topScales.length == 0 || bottomScales.length == 0) { + var maxFontHeight = 0; + + var maxFontHeightFunction = function(scaleInstance) { + if (scaleInstance.options.labels.show) { + // Only consider font sizes for axes that actually show labels + maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); + } + }; + + helpers.each(leftScales, maxFontHeightFunction); + helpers.each(rightScales, maxFontHeightFunction); + + if (topScales.length == 0) { + // Add padding so that we can handle drawing the top nicely + yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides + } + + if (bottomScales.length == 0) { + // Add padding so that we can handle drawing the bottom nicely + yPadding += 1.5 * maxFontHeight; + } + } + // Essentially we now have any number of scales on each of the 4 sides. // Our canvas looks like the following. // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and @@ -111,6 +138,9 @@ } } + chartWidth -= (2 * xPadding); + chartHeight-= (2 * yPadding); + // Step 2 var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); @@ -139,8 +169,8 @@ helpers.each(bottomScales, horizontalScaleMinSizeFunction); // Step 5 - var maxChartHeight = height; - var maxChartWidth = width; + var maxChartHeight = height - (2 * yPadding); + var maxChartWidth = width - (2 * xPadding); var chartWidthReduceFunction = function(scaleInstance) { maxChartWidth -= scalesToMinSize[scaleInstance].width; @@ -189,8 +219,8 @@ helpers.each(bottomScales, horizontalScaleFitFunction); // Step 7 - var totalLeftWidth = 0; - var totalTopHeight = 0; + var totalLeftWidth = xPadding; + var totalTopHeight = yPadding; // Calculate total width of all left axes helpers.each(leftScales, function(scaleInstance) { @@ -203,8 +233,8 @@ }); // Position the scales - var left = 0; - var top = 0; + var left = xPadding; + var top = yPadding; var right = 0; var bottom = 0; @@ -303,7 +333,8 @@ if (this.isHorizontal()) { maxTicks = Math.min(11, Math.ceil(width / 50)); } else { - maxTicks = Math.min(11, Math.ceil(height / 50)); + // The factor of 2 used to scale the font size has been experimentally determined. + maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); } // To get a "nice" value for the tick spacing, we will use the appropriately named @@ -332,6 +363,11 @@ // We are in a vertical orientation. The top value is the highest. So reverse the array this.ticks.reverse(); } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); }, buildLabels: function() { // We assume that this has been run after ticks have been generated. We try to figure out @@ -498,6 +534,9 @@ var setContextLineSettings; var hasZero; + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + if (this.isHorizontal()) { if (this.options.gridLines.show) { // Draw the horizontal line diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js new file mode 100644 index 00000000000..d1c6b8b2a5b --- /dev/null +++ b/src/Chart.Scatter.js @@ -0,0 +1,490 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + + ///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 to show horizontal lines (except X axis) + scaleShowHorizontalLines: true, + + //Boolean - Whether to show vertical lines (except Y axis) + scaleShowVerticalLines: true, + + //Number - Tension of the bezier curve between points + tension: 0.4, + + //Number - Radius of each point dot in pixels + pointRadius: 4, + + //Number - Pixel width of point dot border + pointBorderWidth: 1, + + //Number - amount extra to add to the radius to cater for hit detection outside the drawn point + pointHoverRadius: 20, + + //Number - Pixel width of dataset border + borderWidth: 2, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", + + //Boolean - Whether to horizontally center the label and point dot inside the grid + offsetGridLines: false + + }; + + + Chart.Type.extend({ + name: "Scatter", + defaults: defaultConfig, + initialize: function(data) { + // Save data as a source for updating of values & methods + this.data = data; + + //Custom Point Defaults + this.PointClass = Chart.Point.extend({ + _chart: this.chart, + offsetGridLines: this.options.offsetGridLines, + borderWidth: this.options.pointBorderWidth, + radius: this.options.pointRadius, + hoverRadius: this.options.pointHoverRadius, + }); + + // Events + helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + + // Build Scale + this.buildScale(this.data.labels); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + //Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaDataset = new Chart.Line(); + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new this.PointClass()); + }, this); + }, this); + + // Set defaults for lines + this.eachDataset(function(dataset, datasetIndex) { + dataset = helpers.merge(this.options, dataset); + helpers.extend(dataset.metaDataset, { + _points: dataset.metaData, + _datasetIndex: datasetIndex, + _chart: this.chart, + }); + // Copy to view model + dataset.metaDataset.save(); + }, this); + + // Set defaults for points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + x: this.xScale.getPixelForValue(index), + y: this.chartArea.bottom, + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart + }); + + // Default bezier control points + helpers.extend(point, { + controlPointPreviousX: this.previousPoint(dataset, index).x, + controlPointPreviousY: this.nextPoint(dataset, index).y, + controlPointNextX: this.previousPoint(dataset, index).x, + controlPointNextY: this.nextPoint(dataset, index).y, + }); + // Copy to view model + point.save(); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index - 1] || collection[index]; + }, + previousPoint: function(collection, index) { + return collection[index + 1] || collection[index]; + }, + onHover: function(e) { + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; + this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; + this.lastActive[0].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBackgroundColor; + this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBorderColor; + this.lastActive[i].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderWidth = this.data.datasets[this.active[0]._datasetIndex].borderWidth + 10; + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderWidth = this.data.datasets[this.active[i]._datasetIndex].borderWidth + 2; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, + update: function() { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + helpers.extend(dataset.metaDataset, { + backgroundColor: dataset.backgroundColor || this.options.backgroundColor, + borderWidth: dataset.borderWidth || this.options.borderWidth, + borderColor: dataset.borderColor || this.options.borderColor, + tension: dataset.tension || this.options.tension, + scaleTop: this.chartArea.top, + scaleBottom: this.chartArea.bottom, + _points: dataset.metaData, + _datasetIndex: datasetIndex, + }); + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + x: this.xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), + y: this.yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), + value: this.data.datasets[datasetIndex].data[index].y, + label: this.data.datasets[datasetIndex].data[index].x, + datasetLabel: this.data.datasets[datasetIndex].label, + // Appearance + hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, + hoverBorderColor: this.data.datasets[datasetIndex].pointHoverBorderColor || this.options.pointHoverBorderColor, + hoverRadius: this.data.datasets[datasetIndex].pointHoverRadius || this.options.pointHoverRadius, + radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, + borderColor: this.data.datasets[datasetIndex].pointBorderColor || this.options.pointBorderColor, + backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, + tension: this.data.datasets[datasetIndex].metaDataset.tension, + _datasetIndex: datasetIndex, + _index: index, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index), + point, + this.nextPoint(dataset, index), + point.tension + ); + + point.controlPointPreviousX = controlPoints.previous.x; + point.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point.controlPointNextY = this.chartArea.top; + } else { + point.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point.controlPointPreviousY = this.chartArea.top; + } else { + point.controlPointPreviousY = controlPoints.previous.y; + } + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(); + }, + buildScale: function(labels) { + var self = this; + + var dataTotal = function() { + var values = []; + self.eachValue(function(value) { + values.push(value); + }); + + return values; + }; + + var XScaleClass = Chart.scales.getScaleConstructor("linear"); + var YScaleClass = Chart.scales.getScaleConstructor("linear"); + + this.xScale = new XScaleClass({ + ctx: this.chart.ctx, + }); + + // Eventually this will be referenced from the user supplied config options. + this.xScale.options = { + scaleType: "dataset", // default options are 'dataset', 'linear'. + show: true, + position: "bottom", + horizontal: true, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + }, + + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }; + this.yScale = new YScaleClass({ + ctx: this.chart.ctx, + }); + this.yScale.options = { + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + show: true, + position: "left", + horizontal: false, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + }, + + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }; + + this.xScale.calculateRange = function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + helpers.each(dataset.data, function(value) { + if (this.min === null) { + this.min = value.x; + } else if (value.x < this.min) { + this.min = value.x; + } + + if (this.max === null) { + this.max = value.x; + } else if (value.x > this.max) { + this.max = value.x; + } + }, this); + }, this); + }; + + this.yScale.calculateRange = function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + helpers.each(dataset.data, function(value) { + if (this.min === null) { + this.min = value.y; + } else if (value.y < this.min) { + this.min = value.y; + } + + if (this.max === null) { + this.max = value.y; + } else if (value.y > this.max) { + this.max = value.y; + } + }, this); + }, this); + }; + + // Register the axes with the scale service + Chart.scaleService.registerChartScale(this, this.xScale); + Chart.scaleService.registerChartScale(this, this.yScale); + }, + redraw: function() { + + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + var chartScaleWrapper = Chart.scaleService.getWrapperForChart(this); + + // Draw all the scales + helpers.each(chartScaleWrapper.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + this.eachDataset(function(dataset, datasetIndex) { + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + } + }); + + +}).call(this); From 56d53e3ad482f50df130aa4979d438d5af347e28 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 17 May 2015 13:29:17 -0400 Subject: [PATCH 035/424] Ensure that you always have at least 2 ticks on the linear axis --- src/Chart.Scale.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index dcaaefe2ca4..1353c9a7f63 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -337,6 +337,9 @@ maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); } + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + // To get a "nice" value for the tick spacing, we will use the appropriately named // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks // for details. From 454f519b6ddc2d60dba0ae2257e0252c6555374c Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 18 May 2015 08:27:18 -0400 Subject: [PATCH 036/424] Fix jshint warnings --- src/Chart.Scale.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 1353c9a7f63..2dd6ace7b3b 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -73,7 +73,7 @@ }); // Adjust the padding to take into account displaying labels - if (topScales.length == 0 || bottomScales.length == 0) { + if (topScales.length === 0 || bottomScales.length === 0) { var maxFontHeight = 0; var maxFontHeightFunction = function(scaleInstance) { @@ -86,12 +86,12 @@ helpers.each(leftScales, maxFontHeightFunction); helpers.each(rightScales, maxFontHeightFunction); - if (topScales.length == 0) { + if (topScales.length === 0) { // Add padding so that we can handle drawing the top nicely yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides } - if (bottomScales.length == 0) { + if (bottomScales.length === 0) { // Add padding so that we can handle drawing the bottom nicely yPadding += 1.5 * maxFontHeight; } From 492292e94b9ba902d6a13329d2a1d6410be29dfb Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 18 May 2015 08:43:38 -0400 Subject: [PATCH 037/424] Remove x label rotation code since we dynamically adjust the number of labels to show and as such do not need to rotate --- src/Chart.Scale.js | 52 +--------------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 2dd6ace7b3b..1f2ae87793f 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -457,9 +457,7 @@ if (this.isHorizontal()) { // A horizontal axis is more constrained by the height. var maxLabelHeight = maxHeight - minSize.height; - - // Calculate the label rotation - var labelHeight = this.calculateLabelRotation(minSize.width, maxLabelHeight); + var labelHeight = 1.5 * this.options.labels.fontSize; minSize.height = Math.min(maxHeight, minSize.height + labelHeight); } else { // A vertical axis is more constrained by the width. Labels are the dominant factor @@ -481,54 +479,6 @@ this.height = minSize.height; return minSize; }, - // Function calculate the needed rotation of the labels. Should only be used in horizontal mode - // @param {number} width : the available width - // @param {number} height: the available height - // @return {number} : the height needed by the labels - calculateLabelRotation : function(width, height){ - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - - var labelFont = helpers.fontString(this.options.labels.fontSize, - this.options.labels.fontStyle, this.options.labels.fontFamily); - - this.labelRotation = 0; // reset - - // Steps - // 1. determine if we need to overlap - // 2. if overlap, determine max rotation - // 3. Rotate until no overlap - // 4. Save rotation - // 5. Return height needed for rotation - var longestTextWidth = helpers.longestText(this.ctx, labelFont, this.lables); - var maxAvailableWidth = (width / (this.ticks.length - 1)) - 6; - - // 6 adds 3px of padding on each end of the label - if (longestTextWidth > maxAvailableWidth) { - // Ok, we need to rotate. Do steps 2-4 - var idealRotation = Math.floor(helpers.toDegrees(Math.asin(height / longestTextWidth))); - var maxRotation = Math.min(90, idealRotation); - - // Increment the rotation in 1 degree steps (step 3) - for (var rotation = 1; rotation < maxRotation; ++rotation) { - var cosRotation = Math.cos(helpers.toRadians(rotation)); - this.labelRotation = rotation; // step 4 - - if (cosRotation * longestTextWidth <= maxAvailableWidth) { - // Rotated enough - break; - } - } - - // step 5 - return Math.min(height, longestTextWidth * Math.sin(this.labelRotation)); - } else { - // Height only constrained by text font size and padding - var idealHeight = this.options.labels.fontSize + 10; // add 10 for padding - return Math.min(height, idealHeight); - } - }, - // Actualy draw the scale on the canvas // @param {rectangle} chartArea : the area of the chart to draw full grid lines on draw: function(chartArea) { From e30a9d2a94f3013a084fb1acd4ceb451d1a07d34 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 18 May 2015 08:44:06 -0400 Subject: [PATCH 038/424] The scatter example page now has negative numbers in both directions --- samples/scatter.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/scatter.html b/samples/scatter.html index afb04edc854..56c23fa72ca 100644 --- a/samples/scatter.html +++ b/samples/scatter.html @@ -16,7 +16,7 @@ + + + + +
    +
    + +
    +
    + + + + + diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index e07aacb0363..3707597b694 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -538,9 +538,11 @@ xValue += helpers.aliasPixel(this.ctx.lineWidth); // Draw the label area - this.ctx.beginPath(); - this.ctx.moveTo(xValue, yTickStart); - this.ctx.lineTo(xValue, yTickEnd); + if (this.options.gridLines.drawTicks) { + this.ctx.beginPath(); + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); + } // Draw the chart area if (this.options.gridLines.drawOnChartArea) { @@ -602,9 +604,11 @@ yValue += helpers.aliasPixel(this.ctx.lineWidth); // Draw the label area - this.ctx.beginPath(); - this.ctx.moveTo(xTickStart, yValue); - this.ctx.lineTo(xTickEnd, yValue); + if (this.options.gridLines.drawTicks) { + this.ctx.beginPath(); + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + } // Draw the chart area if (this.options.gridLines.drawOnChartArea) { diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 10aa6757ce5..8267f2a8bc2 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -21,6 +21,7 @@ color: "rgba(0, 0, 0, 0.05)", lineWidth: 1, drawOnChartArea: true, + drawTicks: true, zeroLineWidth: 1, zeroLineColor: "rgba(0,0,0,0.25)", }, @@ -53,6 +54,7 @@ color: "rgba(0, 0, 0, 0.05)", lineWidth: 1, drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label zeroLineWidth: 1, zeroLineColor: "rgba(0,0,0,0.25)", }, From 4b8c9bc30d9137bc375c3527c8742036ed524377 Mon Sep 17 00:00:00 2001 From: etimberg Date: Mon, 18 May 2015 20:59:21 -0400 Subject: [PATCH 044/424] Fix a drawing bug when drawTicks is false. --- samples/scatter-multi-axis.html | 1 + src/Chart.Scale.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/samples/scatter-multi-axis.html b/samples/scatter-multi-axis.html index 8d4658471d0..30473a1ada9 100644 --- a/samples/scatter-multi-axis.html +++ b/samples/scatter-multi-axis.html @@ -95,6 +95,7 @@ hoverMode: 'single', scales: { xAxes: [{ + position: "bottom", gridLines: { zeroLineColor: "rgba(0,0,0,1)" } diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 3707597b694..96897f671d2 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -538,8 +538,9 @@ xValue += helpers.aliasPixel(this.ctx.lineWidth); // Draw the label area - if (this.options.gridLines.drawTicks) { - this.ctx.beginPath(); + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { this.ctx.moveTo(xValue, yTickStart); this.ctx.lineTo(xValue, yTickEnd); } @@ -604,8 +605,9 @@ yValue += helpers.aliasPixel(this.ctx.lineWidth); // Draw the label area + this.ctx.beginPath(); + if (this.options.gridLines.drawTicks) { - this.ctx.beginPath(); this.ctx.moveTo(xTickStart, yValue); this.ctx.lineTo(xTickEnd, yValue); } From 4cc24d475ab69047b0cab2d47f214c334ed1b404 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 19 May 2015 18:22:05 -0400 Subject: [PATCH 045/424] Clean up the scale service. It's now more of a helper function for fitting the scales. Since each chart needed to know it's scales, there wasn't much point in registering them into the service. When we support overlapping charts, we can do something fancier --- src/Chart.Scale.js | 56 +++++--------------------------------------- src/Chart.Scatter.js | 6 +---- 2 files changed, 7 insertions(+), 55 deletions(-) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 96897f671d2..b7db8c1bae4 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -9,66 +9,22 @@ // a service where scales are registered with their respective charts so that changing the // scales does not require Chart.scaleService = { - registeredCharts: [], - getWrapperForChart: function(chartInstance) { - var wrapper = helpers.findNextWhere(this.registeredCharts, function(charScaleWrapper) { - return charScaleWrapper.chartInstance == chartInstance; - }); - - return wrapper; - }, - registerChartScale: function(chartInstance, scaleInstance) { - var chartScaleWrapper = this.getWrapperForChart(chartInstance); - - if (!chartScaleWrapper) { - chartScaleWrapper = { - scales: [], - chartInstance: chartInstance, - }; - - this.registeredCharts.push(chartScaleWrapper); - } - - chartScaleWrapper.scales.push(scaleInstance); - }, - removeChartScale: function(chartInstance, scaleInstance) { - var chartScaleWrapper = this.getWrapperForChart(chartInstance); - - if (chartScaleWrapper) { - var scaleIndex = helpers.indexOf(scaleWrapper.scales, scaleInstance); - - if (scaleIndex) { - scaleWrapper.scales.splice(scaleIndex, 1); - } - } - }, - // Remove a chart instance from the scale service. Useful when a chart is destroyed - removeChartInstance: function(chartInstance) { - var index = helpers.findNextWhere(this.registeredCharts, function(scaleWrapper) { - return scaleWrapper.chartInstance == chartInstance; - }); - - if (index) { - this.registeredCharts.splice(index, 1); - } - }, // The interesting function fitScalesForChart: function(chartInstance, width, height) { - var chartScaleWrapper = this.getWrapperForChart(chartInstance); var xPadding = 10; var yPadding = 10; - if (chartScaleWrapper) { - var leftScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + if (chartInstance) { + var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { return scaleInstance.options.position == "left"; }); - var rightScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { return scaleInstance.options.position == "right"; }); - var topScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { return scaleInstance.options.position == "top"; }); - var bottomScales = helpers.where(chartScaleWrapper.scales, function(scaleInstance) { + var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { return scaleInstance.options.position == "bottom"; }); @@ -282,7 +238,7 @@ helpers.each(bottomScales, horizontalScalePlacer); // Step 8 - chartScaleWrapper.chartInstance.chartArea = { + chartInstance.chartArea = { left: totalLeftWidth, top: totalTopHeight, right: totalLeftWidth + maxChartWidth, diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 8267f2a8bc2..d1c2cf10b5e 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -451,7 +451,6 @@ }); this.scales[scale.id] = scale; - Chart.scaleService.registerChartScale(this, scale); }, this); helpers.each(this.options.scales.yAxes, function(yAxisOptions) { @@ -464,7 +463,6 @@ }); this.scales[scale.id] = scale; - Chart.scaleService.registerChartScale(this, scale); }, this); }, redraw: function() { @@ -475,10 +473,8 @@ var easingDecimal = ease || 1; this.clear(); - var chartScaleWrapper = Chart.scaleService.getWrapperForChart(this); - // Draw all the scales - helpers.each(chartScaleWrapper.scales, function(scale) { + helpers.each(this.scales, function(scale) { scale.draw(this.chartArea); }, this); From 008bb1aab365c46cbf479cbf9ae2bd98f2350bef Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 19 May 2015 20:33:39 -0400 Subject: [PATCH 046/424] Set new tooltip templates for the scatter chart --- samples/scatter.html | 2 +- src/Chart.Scatter.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/samples/scatter.html b/samples/scatter.html index ecc259f2faf..84cfb2a0e6c 100644 --- a/samples/scatter.html +++ b/samples/scatter.html @@ -88,7 +88,7 @@ var ctx = document.getElementById("canvas").getContext("2d"); window.myScatter = new Chart(ctx).Scatter(scatterChartData, { responsive: true, - hoverMode: 'single', + hoverMode: 'single', // should always use single for a scatter chart scales: { xAxes: [{ gridLines: { diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index d1c2cf10b5e..1de1b06b940 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -6,7 +6,7 @@ helpers = Chart.helpers; var defaultConfig = { - + hoverMode: 'single', scales: { xAxes: [{ scaleType: "linear", // scatter should not use a dataset axis @@ -94,6 +94,9 @@ //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", + tooltipTemplate: "(<%= dataX %>, <%= dataY %>)", + multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= dataX %>, <%= dataY %>)", + }; @@ -334,8 +337,10 @@ helpers.extend(point, { x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), - value: this.data.datasets[datasetIndex].data[index].y, - label: this.data.datasets[datasetIndex].data[index].x, + dataX: this.data.datasets[datasetIndex].data[index].x, + dataY: this.data.datasets[datasetIndex].data[index].y, + label: '', // so that the multitooltip looks ok + value: this.data.datasets[datasetIndex].data[index].y, // for legacy reasons datasetLabel: this.data.datasets[datasetIndex].label, // Appearance hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, From 951e714e779bd96ac4f0a7bc04c75685b7b68616 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 20 May 2015 00:03:45 -0700 Subject: [PATCH 047/424] Playground and big changes --- .gitignore | 2 + Chart.js | 713 ++++++++++++++++++++++++++-------------- Chart.min.js | 6 +- bower.json | 8 +- package.json | 1 + samples/bar.html | 34 +- samples/line.html | 9 +- samples/playground.html | 72 ++++ samples/playground.js | 156 +++++++++ src/Chart.Bar.js | 162 +++++++-- src/Chart.Core.js | 101 ++++-- src/Chart.Line.js | 423 ++++++++++++++---------- 12 files changed, 1173 insertions(+), 514 deletions(-) create mode 100644 samples/playground.html create mode 100644 samples/playground.js diff --git a/.gitignore b/.gitignore index 3969d0aade1..5016e5def4b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ node_modules/* custom/* docs/index.md + +bower_components/ diff --git a/Chart.js b/Chart.js index 5a1408d4fae..f16219b5018 100644 --- a/Chart.js +++ b/Chart.js @@ -113,9 +113,12 @@ //String / Boolean - Hover mode for events. hoverMode: 'single', // 'label', 'dataset', 'false' - //Function - Custom hover handler + //Function(event) - Custom hover handler onHover: null, + //Function(event, clickedElements) - Custom click handler + onClick: null, + //Function - Custom hover handler hoverAnimationDuration: 400, @@ -125,8 +128,8 @@ // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function customTooltips: false, - // Array - Array of string names to attach tooltip events - tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], + // Array - Array of string names to attach interaction events + events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], // String - Tooltip background colour tooltipBackgroundColor: "rgba(0,0,0,0.8)", @@ -186,7 +189,7 @@ onAnimationComplete: function() {}, // Color String - Used for undefined Colros - colorFallback: 'rgba(0,0,0,0.1)', + defaultColor: 'rgba(0,0,0,0.1)', } }; @@ -910,19 +913,20 @@ //Destroy method on the chart will remove the instance of the chart from this reference. Chart.instances = {}; - Chart.Type = function(data, options, chart) { - this.options = options; - this.chart = chart; + Chart.Type = function(config, instance) { + this.data = config.data; + this.options = config.options; + this.chart = instance; this.id = uid(); //Add the chart instance to the global namespace Chart.instances[this.id] = this; // Initialize is always called when a chart type is created // By default it is a no op, but it should be extended - if (options.responsive) { + if (this.options.responsive) { this.resize(); } - this.initialize.call(this, data); + this.initialize.call(this); }; //Core methods that'll be a part of every chart type @@ -939,7 +943,7 @@ Chart.animationService.cancelAnimation(this); return this; }, - resize: function(callback) { + resize: function() { this.stop(); var canvas = this.chart.canvas, newWidth = getMaximumWidth(this.chart.canvas), @@ -950,9 +954,6 @@ retinaScale(this.chart); - if (typeof callback === "function") { - callback.apply(this, Array.prototype.slice.call(arguments, 1)); - } return this; }, redraw: noop, @@ -1090,9 +1091,9 @@ Chart.types[chartName] = ChartType; //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(data, options) { - var config = merge(Chart.defaults.global, Chart.defaults[chartName], options || {}); - return new ChartType(data, config, this); + Chart.prototype[chartName] = function(config) { + helpers.extend(config.options, merge(Chart.defaults.global, Chart.defaults[chartName], config.options || {})); + return new ChartType(config, this); }; } else { warn("Name not provided for this chart, so it hasn't been registered"); @@ -1199,7 +1200,8 @@ var vm = this._vm; return { x: vm.x, - y: vm.y + y: vm.y, + padding: vm.radius + vm.borderWidth }; }, draw: function() { @@ -1214,10 +1216,10 @@ ctx.arc(vm.x, vm.y, vm.radius, 0, Math.PI * 2); ctx.closePath(); - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.fill(); ctx.stroke(); @@ -1232,11 +1234,7 @@ var vm = this._vm; var ctx = this._chart.ctx; - //Draw the line between all the points - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; - ctx.beginPath(); - + // Draw the background first (so the border is always on top) helpers.each(vm._points, function(point, index) { if (index === 0) { ctx.moveTo(point._vm.x, point._vm.y); @@ -1258,16 +1256,45 @@ } }, this); - ctx.stroke(); - if (vm._points.length > 0) { //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleBottom); - ctx.lineTo(vm._points[0].x, vm.scaleBottom); - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleZero); + ctx.lineTo(vm._points[0].x, vm.scaleZero); + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.closePath(); ctx.fill(); } + + + // Now draw the line between all the points with any borders + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.beginPath(); + + helpers.each(vm._points, function(point, index) { + if (index === 0) { + ctx.moveTo(point._vm.x, point._vm.y); + } else { + if (vm._tension > 0 || 1) { + var previous = this.previousPoint(point, vm._points, index); + + ctx.bezierCurveTo( + previous._vm.controlPointNextX, + previous._vm.controlPointNextY, + point._vm.controlPointPreviousX, + point._vm.controlPointPreviousY, + point._vm.x, + point._vm.y + ); + } else { + ctx.lineTo(point._vm.x, point._vm.y); + } + } + }, this); + + + ctx.stroke(); + }, previousPoint: function(point, collection, index) { return helpers.findPreviousWhere(collection, function() { @@ -1279,24 +1306,28 @@ Chart.Arc = Chart.Element.extend({ inRange: function(chartX, chartY) { - var pointRelativePosition = helpers.getAngleFromPoint(this, { + var vm = this._vm; + + var pointRelativePosition = helpers.getAngleFromPoint(vm, { x: chartX, y: chartY }); //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle), - withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius); + var betweenAngles = (pointRelativePosition.angle >= vm.startAngle && pointRelativePosition.angle <= vm.endAngle), + withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); return (betweenAngles && withinRadius); //Ensure within the outside of the arc centre, but inside arc outer }, tooltipPosition: function() { - var centreAngle = this.startAngle + ((this.endAngle - this.startAngle) / 2), - rangeFromCentre = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius; + var vm = this._vm; + + var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), + rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; return { - x: this.x + (Math.cos(centreAngle) * rangeFromCentre), - y: this.y + (Math.sin(centreAngle) * rangeFromCentre) + x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), + y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) }; }, draw: function() { @@ -1441,6 +1472,7 @@ helpers.extend(this, { x: Math.round(tooltipPosition.x), y: Math.round(tooltipPosition.y), + caretPadding: tooltipPosition.padding }); break; @@ -1561,7 +1593,7 @@ vm.yAlign = "above"; //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding = 2; + var caretPadding = vm.caretPadding || 2; var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, @@ -1722,14 +1754,14 @@ // Build the current yLabels so we have an idea of what size they'll be to start /* - * This sets what is returned from calculateScaleRange as static properties of this class: - * - this.steps; - this.stepValue; - this.min; - this.max; - * - */ + * This sets what is returned from calculateScaleRange as static properties of this class: + * + this.steps; + this.stepValue; + this.min; + this.max; + * + */ this.calculateYRange(cachedHeight); // With these properties set we can now build the array of yLabels @@ -2312,7 +2344,9 @@ // If the responsive flag is set in the chart instance config // Cascade the resize event down to the chart. if (instance.options.responsive) { - instance.resize(instance.render, true); + instance.resize(); + instance.update(); + instance.render(); } }); }, 50); @@ -2373,6 +2407,9 @@ //Number - Spacing between data sets within X values barDatasetSpacing: 1, + //Boolean - Whether bars should be rendered on a percentage base + relativeBars: false, + //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " @@ -2389,26 +2426,109 @@ var options = this.options; + var _this = this; + // Custom Scale Methods and Options this.ScaleClass = Chart.Scale.extend({ offsetGridLines: true, + calculateBarBase: function(datasetIndex, index) { + + var base = 0; + + if (_this.options.stacked) { + var bar = _this.data.datasets[datasetIndex].metaData[index]; + if (bar.value < 0) { + for (var i = 0; i < datasetIndex; i++) { + base += _this.data.datasets[i].metaData[index].value < base ? _this.data.datasets[i].metaData[index].value : 0; + } + } else { + for (var i = 0; i < datasetIndex; i++) { + base += _this.data.datasets[i].metaData[index].value > base ? _this.data.datasets[i].metaData[index].value : 0; + } + } + return this.calculateY(base); + } + + base = this.endPoint; + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.calculateY(0); + base += _this.options.scaleGridLineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.startPoint; + } + + return base; + + }, calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar var xWidth = this.calculateBaseWidth(), xAbsolute = this.calculateX(elementIndex) - (xWidth / 2), barWidth = this.calculateBarWidth(datasetCount); + if (_this.options.stacked) { + return xAbsolute + barWidth / 2; + } + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth / 2; }, + calculateBarY: function(datasets, datasetIndex, barIndex, value) { + + if (_this.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (datasets[i].metaData[barIndex].value < 0) { + sumNeg += datasets[i].metaData[barIndex].value || 0; + } else { + sumPos += datasets[i].metaData[barIndex].value || 0; + } + } + + if (value < 0) { + return this.calculateY(sumNeg + value); + } else { + return this.calculateY(sumPos + value); + } + + /*if (options.relativeBars) { + offset = offset / sum * 100; + }*/ + + return this.calculateY(0); + } + + var offset = 0; + + for (i = datasetIndex; i < datasets.length; i++) { + if (i === datasetIndex && value) { + offset += value; + } else { + offset = offset + (datasets[i].metaData[barIndex].value); + } + } + + return this.calculateY(value); + }, calculateBaseWidth: function() { return (this.calculateX(1) - this.calculateX(0)) - (2 * options.barValueSpacing); }, + calculateBaseHeight: function() { + return (this.calculateY(1) - this.calculateY(0)); + }, calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); + if (_this.options.stacked) { + return baseWidth; + } return (baseWidth / datasetCount); - } + }, }); // Events @@ -2431,11 +2551,12 @@ }, this); // Set defaults for bars - this.eachElement(function(bar, index, datasetIndex) { + this.eachElement(function(bar, index, dataset, datasetIndex) { helpers.extend(bar, { + base: this.scale.zeroPoint, width: this.scale.calculateBarWidth(this.data.datasets.length), x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.calculateBaseY(), + y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), _datasetIndex: datasetIndex, _index: index, }); @@ -2506,13 +2627,13 @@ if (this.active.length && this.options.hoverMode) { switch (this.options.hoverMode) { case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.8).darken(0.2).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.8).darken(0.2).rgbString(); break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.8).darken(0.2).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.8).darken(0.2).rgbString(); } break; case 'dataset': @@ -2572,30 +2693,23 @@ this.lastActive = this.active; return this; }, - // Calculate the base point for the bar. - calculateBaseY: function() { - var base = this.scale.endPoint; - - if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) { - base = this.scale.calculateY(0); - base += this.options.scaleGridLineWidth; - } else if (this.scale.min < 0 && this.scale.max < 0) { - // All values are negative. Use the top as the base - base = this.scale.startPoint; - } - - return base; - }, update: function() { this.scale.update(); this.eachElement(function(bar, index, dataset, datasetIndex) { helpers.extend(bar, { - width: this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), value: this.data.datasets[datasetIndex].data[index], + }); + bar.pivot(); + }, this); + + this.eachElement(function(bar, index, dataset, datasetIndex) { + helpers.extend(bar, { + base: this.scale.calculateBarBase(datasetIndex, index), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), + width: this.scale.calculateBarWidth(this.data.datasets.length), label: this.data.labels[index], datasetLabel: this.data.datasets[datasetIndex].label, borderColor: this.data.datasets[datasetIndex].borderColor, @@ -2614,10 +2728,31 @@ var dataTotal = function() { var values = []; - self.eachValue(function(value) { + var negativeValues = []; + + if (self.options.stacked) { + self.eachValue(function(value, index) { + values[index] = values[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + if (self.options.relativeBars) { + values[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + values[index] += value; + } + } + }); + return values.concat(negativeValues); + } + + self.eachValue(function(value, index) { values.push(value); }); + return values; + }; var scaleOptions = { @@ -2669,7 +2804,7 @@ }, // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function redraw: function() { - var base = this.calculateBaseY(); + var base = this.scale.zeroPoint; this.eachElement(function(element, index, datasetIndex) { helpers.extend(element, { y: base, @@ -2687,12 +2822,7 @@ //Draw all the bars for each dataset this.eachElement(function(bar, index, datasetIndex) { - if (bar.hasValue()) { - // Update the bar basepoint - bar.base = this.calculateBaseY(); - //Transition - bar.transition(easingDecimal).draw(); - } + bar.transition(easingDecimal).draw(); }, this); // Finally draw the tooltip @@ -2974,39 +3104,50 @@ ///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 to show horizontal lines (except X axis) scaleShowHorizontalLines: true, - //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines: true, + //Boolean - Whether to horizontally center the label and point dot inside the grid + offsetGridLines: false, + + + + //Boolean - Whether to stack the lines essentially creating a stacked area chart. + stacked: false, + //Number - Tension of the bezier curve between points tension: 0.4, - //Number - Radius of each point dot in pixels - pointRadius: 4, + //Number - Radius of each point dot in pixels + pointRadius: 3, //Number - Pixel width of point dot border pointBorderWidth: 1, + //Number - Pixel width of point on hover + pointHoverRadius: 5, + //Number - Pixel width of point dot border on hover + pointHoverBorderWidth: 2, + pointBackgroundColor: Chart.defaults.global.defaultColor, + pointBorderColor: Chart.defaults.global.defaultColor, //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHoverRadius: 20, + pointHitRadius: 6, //Number - Pixel width of dataset border borderWidth: 2, + //Number - Pixel width of dataset border on hover + hoverBorderWidth: 2, //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - //Boolean - Whether to horizontally center the label and point dot inside the grid - offsetGridLines: false + }; @@ -3014,23 +3155,39 @@ Chart.Type.extend({ name: "Line", defaults: defaultConfig, - initialize: function(data) { - // Save data as a source for updating of values & methods - this.data = data; - - //Custom Point Defaults - this.PointClass = Chart.Point.extend({ - _chart: this.chart, - offsetGridLines: this.options.offsetGridLines, - borderWidth: this.options.pointBorderWidth, - radius: this.options.pointRadius, - hoverRadius: this.options.pointHoverRadius, - }); + initialize: function() { // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + helpers.bindEvents(this, this.options.events, this.events); + + var _this = this; // Build Scale + this.ScaleClass = Chart.Scale.extend({ + calculatePointY: function(index, datasetIndex) { + + var value = _this.data.datasets[datasetIndex].data[index]; + + if (_this.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + for (var i = 0; i < datasetIndex; i++) { + if (_this.data.datasets[i].data[index] < 0) { + offsetNeg += _this.data.datasets[i].data[index]; + } else { + offsetPos += _this.data.datasets[i].data[index]; + } + } + if (value < 0) { + return this.calculateY(offsetNeg + value); + } else { + return this.calculateY(offsetPos + value); + } + } + + return this.calculateY(value); + } + }); this.buildScale(this.data.labels); @@ -3039,19 +3196,20 @@ dataset.metaDataset = new Chart.Line(); dataset.metaData = []; helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new this.PointClass()); + dataset.metaData.push(new Chart.Point()); }, this); }, this); // Set defaults for lines this.eachDataset(function(dataset, datasetIndex) { - dataset = helpers.merge(this.options, dataset); helpers.extend(dataset.metaDataset, { _points: dataset.metaData, _datasetIndex: datasetIndex, _chart: this.chart, }); - // Copy to view model + // Fill in dataset defaults from options + helpers.extend(dataset, helpers.merge(this.options, dataset)); + // Copy to view modele dataset.metaDataset.save(); }, this); @@ -3059,7 +3217,7 @@ this.eachElement(function(point, index, dataset, datasetIndex) { helpers.extend(point, { x: this.scale.calculateX(index), - y: this.scale.endPoint, + y: this.scale.calculateY(0), _datasetIndex: datasetIndex, _index: index, _chart: this.chart @@ -3091,145 +3249,27 @@ previousPoint: function(collection, index) { return collection[index + 1] || collection[index]; }, - onHover: function(e) { - - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hoverMode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); - } - - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hoverMode) { - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; - this.lastActive[0].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBackgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBorderColor; - this.lastActive[i].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderWidth = this.data.datasets[this.active[0]._datasetIndex].borderWidth + 10; - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderWidth = this.data.datasets[this.active[i]._datasetIndex].borderWidth + 2; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.showTooltips) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - - }, update: function() { + // Update the scale this.scale.update(); // Update the lines this.eachDataset(function(dataset, datasetIndex) { helpers.extend(dataset.metaDataset, { + // Utility + _datasetIndex: datasetIndex, + // Data + _points: dataset.metaData, + // Geometry + scaleTop: this.scale.startPoint, + scaleBottom: this.scale.endPoint, + scaleZero: this.scale.calculateY(0), + // Appearance + tension: dataset.tension || this.options.tension, backgroundColor: dataset.backgroundColor || this.options.backgroundColor, borderWidth: dataset.borderWidth || this.options.borderWidth, borderColor: dataset.borderColor || this.options.borderColor, - tension: dataset.tension || this.options.tension, - scaleTop: this.scale.startPoint, - scaleBottom: this.scale.endPoint, - _points: dataset.metaData, - _datasetIndex: datasetIndex, }); dataset.metaDataset.pivot(); }); @@ -3237,22 +3277,25 @@ // Update the points this.eachElement(function(point, index, dataset, datasetIndex) { helpers.extend(point, { - x: this.scale.calculateX(index), - y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), - value: this.data.datasets[datasetIndex].data[index], + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + // Data label: this.data.labels[index], + value: this.data.datasets[datasetIndex].data[index], datasetLabel: this.data.datasets[datasetIndex].label, - // Appearance - hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, - hoverBorderColor: this.data.datasets[datasetIndex].pointHoverBorderColor || this.options.pointHoverBorderColor, - hoverRadius: this.data.datasets[datasetIndex].pointHoverRadius || this.options.pointHoverRadius, + // Geometry + offsetGridLines: this.options.offsetGridLines, + x: this.scale.calculateX(index), + y: this.scale.calculatePointY(index, datasetIndex), + tension: this.data.datasets[datasetIndex].metaDataset.tension, + // Appearnce radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, - borderColor: this.data.datasets[datasetIndex].pointBorderColor || this.options.pointBorderColor, backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, - tension: this.data.datasets[datasetIndex].metaDataset.tension, - _datasetIndex: datasetIndex, - _index: index, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, + // Tooltip + hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.pointHitRadius, }); }, this); @@ -3269,7 +3312,6 @@ point.controlPointNextX = controlPoints.next.x; // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.scale.endPoint) { point.controlPointNextY = this.scale.endPoint; @@ -3298,11 +3340,31 @@ var dataTotal = function() { var values = []; - self.eachValue(function(value) { + var negativeValues = []; + + if (self.options.stacked) { + self.eachValue(function(value, index) { + values[index] = values[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + if (self.options.relativePoints) { + values[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + values[index] += value; + } + } + }); + return values.concat(negativeValues); + } + + self.eachValue(function(value, index) { values.push(value); }); return values; + }; var scaleOptions = { @@ -3351,7 +3413,7 @@ }); } - this.scale = new Chart.Scale(scaleOptions); + this.scale = new this.ScaleClass(scaleOptions); }, redraw: function() { @@ -3363,7 +3425,11 @@ this.scale.draw(easingDecimal); - this.eachDataset(function(dataset, datasetIndex) { + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + var datasetIndex = i; // Transition Point Locations helpers.each(dataset.metaData, function(point, index) { @@ -3377,11 +3443,152 @@ helpers.each(dataset.metaData, function(point) { point.draw(); }); - }, this); + } // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); - } + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + + this.lastActive[0].radius = dataset.pointRadius; + this.lastActive[0].backgroundColor = dataset.pointBackgroundColor; + this.lastActive[0].borderColor = dataset.pointBorderColor; + this.lastActive[0].borderWidth = dataset.pointBorderWidth; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + + this.lastActive[i].radius = dataset.pointRadius; + this.lastActive[i].backgroundColor = dataset.pointBackgroundColor; + this.lastActive[i].borderColor = dataset.pointBorderColor; + this.lastActive[i].borderWidth = dataset.pointBorderWidth; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + + this.active[0].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; + this.active[0].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + + this.active[i].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; + this.active[i].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, }); diff --git a/Chart.min.js b/Chart.min.js index a83c0899616..498e634aafc 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,6 +7,6 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,a.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,hoverMode:"single",onHover:null,hoverAnimationDuration:400,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipBackgroundColor:"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:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){},colorFallback:"rgba(0,0,0,0.1)"}},i.types={};var a=i.helpers={},n=a.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;a--){var n=t[a];if(e(n))return n}},a.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),c=a.noop=function(){},u=a.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=a.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=a.amd="function"==typeof define&&define.amd,g=a.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=a.max=function(t){return Math.max.apply(Math,t)},v=a.min=function(t){return Math.min.apply(Math,t)},m=(a.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},a.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=a.radians=function(t){return t*(Math.PI/180)},y=(a.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,n=Math.sqrt(i*i+a*a),s=2*Math.PI+Math.atan2(a,i);return 0>i&&0>a&&(s+=2*Math.PI),{angle:s,distance:n}},a.aliasPixel=function(t){return t%2===0?0:.5}),w=(a.splineCurve=function(t,e,i,a){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=a*n/(n+s),r=a*s/(n+s);return{next:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},previous:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},a.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),x=(a.calculateScaleRange=function(t,e,i,a,n){var s=2,o=Math.floor(e/(1.5*i)),r=s>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!a?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=a?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=s,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},a.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),S=(a.generateLabels=function(t,e,i,a){var s=new Array(e);return t&&n(s,function(e,n){s[n]=x(t,{value:i+a*(n+1)})}),s},a.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-S.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*S.easeInBounce(2*t):.5*S.easeOutBounce(2*t-1)+.5}}),C=a.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(a.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),a.animationLoop=function(t,e,i,a,n,s){var o=0,r=S[i]||S.linear,h=function(){o++;var i=o/e,l=r(i);t.call(s,l,i,o),a.call(s,l,i),e>o?s.animationFrame=C(h):n.apply(s)};C(h)},a.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,n=t.currentTarget||t.srcElement,s=n.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},a.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=a.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},A=(a.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},a.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),L=a.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(_(e,"padding-left"))+parseInt(_(e,"padding-right"));return e.clientWidth-i},M=a.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(_(e,"padding-bottom"))+parseInt(_(e,"padding-top"));return e.clientHeight-i},_=a.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},F=(a.getMaximumSize=a.getMaximumWidth,a.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),R=a.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=a.fontString=function(t,e,i){return e+" "+t+"px "+i},T=a.longestText=function(t,e,i){t.font=e;var a=0;return n(i,function(e){var i=t.measureText(e).width;a=i>a?i:a}),a},z=a.drawRoundedRectangle=function(t,e,i,a,n,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+n-s),t.quadraticCurveTo(e+a,i+n,e+a-s,i+n),t.lineTo(e+s,i+n),t.quadraticCurveTo(e,i+n,e,i+n-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()};a.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},a.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e,a){this.options=e,this.chart=a,this.id=u(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return R(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var e=this.chart.canvas,i=L(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:M(this.chart.canvas);return e.width=this.chart.width=i,e.height=this.chart.height=a,F(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},redraw:c,render:function(t){if(this.options.animation){var e=new i.Animation;e.numSteps=(t||this.options.animationDuration)/16.66,e.easing=this.options.animationEasing,e.render=function(t,e){var i=a.easingEffects[e.easing],n=e.currentStep/e.numSteps,s=i(n);t.draw(s,n,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){a.each(this.data.datasets,function(e,i){a.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){a.each(this.data.datasets,function(e,i){a.each(e.data,t,this,i)},this)},eachDataset:function(t){a.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],n=a.getRelativePosition(t),s=function(t){i.push(t.metaData[e])},o=0;o0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.colorFallback,e.lineWidth=t.borderWidth||i.defaults.global.colorFallback,e.fillStyle=t.backgroundColor||i.defaults.global.colorFallback,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._vm,e=this._chart.ctx;e.lineWidth=t.borderWidth||i.defaults.global.colorFallback,e.strokeStyle=t.borderColor||i.defaults.global.colorFallback,e.beginPath(),a.each(t._points,function(i,a){if(0===a)e.moveTo(i._vm.x,i._vm.y);else if(t._tension>0,0)e.lineTo(i._vm.x,i._vm.y);else{var n=this.previousPoint(i,t._points,a);e.bezierCurveTo(n._vm.controlPointNextX,n._vm.controlPointNextY,i._vm.controlPointPreviousX,i._vm.controlPointPreviousY,i._vm.x,i._vm.y)}},this),e.stroke(),t._points.length>0&&(e.lineTo(t._points[t._points.length-1].x,t.scaleBottom),e.lineTo(t._points[0].x,t.scaleBottom),e.fillStyle=t.backgroundColor||i.defaults.global.colorFallback,e.closePath(),e.fill())},previousPoint:function(t,e,i){return a.findPreviousWhere(e,function(){return!0},i)||t}}),i.Arc=i.Element.extend({inRange:function(t,e){var i=a.getAngleFromPoint(this,{x:t,y:e}),n=i.angle>=this.startAngle&&i.angle<=this.endAngle,s=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&s},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(){var t=this._chart.ctx,e=this._vm;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,a=t.x-i,n=t.x+i,s=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(a+=o,n-=o,s+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(a,t.base),e.lineTo(a,s),e.lineTo(n,s),e.lineTo(n,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._vm;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._vm;return t.y=0&&(i=this._data.datasets[r].metaData,n=h(i,this._active[0]),-1===n);r--);var l=function(t){var e,i,r,h,l,c=[],u=[],d=[];return a.each(this._data.datasets,function(t){e=t.metaData,e[n]&&e[n].hasValue()&&c.push(e[n])}),a.each(c,function(t){u.push(t._vm.x),d.push(t._vm.y),s.push(a.template(this._options.multiTooltipTemplate,t)),o.push({fill:t._vm.backgroundColor,stroke:t._vm.borderColor})},this),l=v(d),r=f(d),h=v(u),i=f(u),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,n);a.extend(this,{x:l.x,y:l.y,labels:s,title:this._active.length?this._active[0].label:"",legendColors:o,legendBackgroundColor:this._options.multiTooltipKeyBackground}),this.height=s.length*this.fontSize+(s.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize;var c=t.measureText(this.title).width,u=T(t,this.font,s)+this.fontSize+3,d=f([u,c]);this.width=d+2*this.xPadding;var p=this.height/2;this.y-p<0?this.y=p:this.y+p>this._chart.height&&(this.y=this._chart.height-p),this.x>this._chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._vm;switch(this._options.hoverMode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding=2,n=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,o=s+e.caretHeight+i;e.x+n/2>this._chart.width?e.xAlign="left":e.x-n/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-n/2,h=e.y-o;if(t.fillStyle=a.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._vm);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-n+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}z(t,r,h,n,s,e.cornerRadius),t.fill(),t.fillStyle=a.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+n/2,h+s/2)}break;case"label":z(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=a.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),a.each(e.labels,function(i,n){t.fillStyle=a.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(n+1)),t.fillStyle=a.color(e.legendBackgroundColor).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize),t.fillStyle=a.color(e.legendColors[n].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._vm.y-this._vm.height/2+this._vm.yPadding,i=t-1;return 0===t?e+this._vm.titleFontSize/2:e+(1.5*this._vm.fontSize*i+this._vm.fontSize/2)+1.5*this._vm.titleFontSize}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?T(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,s=T(this.ctx,this.font,this.xLabels);this.xLabelWidth=s;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*a,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*s;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*s+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),a=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(a+=i/2),Math.round(a)},update:function(t){a.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,s){var o=this.endPoint-e*s,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==s||h||(h=!0),h&&t.beginPath(),s>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=a.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var a=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),s=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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(a,s?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=s?"right":"center",t.textBaseline=s?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,a,n,s,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+a,n=e),t.x-ap&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var a,n=i*(this.drawingArea/this.steps),s=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var a=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var s=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],a.x,a.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var n=0;n1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var n=Date.now(),s=n-t-this.frameDuration,o=s/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&a.requestAnimFrame.call(window,this.digestWrapper)}},a.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0, -scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:a,initialize:function(t){this.data=t;var a=this.options;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),s=this.calculateX(i)-n/2,o=this.calculateBarWidth(t);return s+o*e+e*a.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*a.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*a.barDatasetSpacing;return e/t}}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.BarClass=e.Rectangle.extend({ctx:this.chart.ctx}),this.buildScale(this.data.labels),i.each(this.data.datasets,function(t,e){t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.BarClass)},this)},this),this.eachElement(function(t,e,a){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,a,e),y:this.calculateBaseY(),_datasetIndex:a,_index:e}),t.save()},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hoverMode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length)switch(this.options.hoverMode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].borderColor;break;case"label":for(var e=0;e=0||this.scale.min>=0&&this.scale.max<=0?(t=this.scale.calculateY(0),t+=this.options.scaleGridLineWidth):this.scale.min<0&&this.scale.max<0&&(t=this.scale.startPoint),t},update:function(){this.scale.update(),this.eachElement(function(t,e,a,n){i.extend(t,{width:this.scale.calculateBarWidth(this.data.datasets.length),x:this.scale.calculateBarX(this.data.datasets.length,n,e),y:this.scale.calculateY(this.data.datasets[n].data[e]),value:this.data.datasets[n].data[e],label:this.data.labels[e],datasetLabel:this.data.datasets[n].label,borderColor:this.data.datasets[n].borderColor,borderWidth:this.data.datasets[n].borderWidth,backgroundColor:this.data.datasets[n].backgroundColor,_datasetIndex:n,_index:e}),t.pivot()},this),this.render()},buildScale:function(t){var e=this,a=function(){var t=[];return e.eachValue(function(e){t.push(e)}),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 e=i.calculateScaleRange(a(),t,this.fontSize,this.beginAtZero,this.integersOnly);i.extend(this,e)},xLabels:t,font:i.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,showHorizontalLines:this.options.scaleShowHorizontalLines,showVerticalLines:this.options.scaleShowVerticalLines,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.borderWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&i.extend(n,{calculateYRange:i.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)},redraw:function(){var t=this.calculateBaseY();this.eachElement(function(e,a,n){i.extend(e,{y:t,base:t})}),this.render()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(e),this.eachElement(function(t,i,a){t.hasValue()&&(t.base=this.calculateBaseY(),t.transition(e).draw())},this),this.tooltip.transition(e).draw()}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={segmentShowStroke:!0,segmentStrokeColor:"#fff",borderWidth:2,cutoutPercentage:50,hoverAnimationDuration:400,animationEasing:"easeOutQuart",animateRotate:!0,animateScale:!1,legendTemplate:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Doughnut",defaults:a,initialize:function(t){this.data=t,this.Slice=e.Arc.extend({_chart:this.chart,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.data.metaData=[],i.each(this.data.data,function(e,a){var n=new this.Slice;"number"==typeof e?i.extend(n,{value:e}):i.extend(n,e),i.extend(n,{startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(n.value),outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout}),n.backgroundColor||(e.backgroundColor="hsl("+360*a/t.length+", 100%, 50%)"),n.save(),this.data.metaData.push(n)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=this.getSliceAtEvent(t),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length&&(this.lastActive[0].backgroundColor=this.data.data[this.lastActive[0]._index].backgroundColor),this.active.length&&this.options.hoverMode&&(this.active[0].backgroundColor=this.data.data[this.active[0]._index].hoverBackgroundColor||i.color(this.data.data[this.active[0]._index].backgroundColor).saturate(.5).darken(.35).rgbString()),this.options.showTooltips&&(this.tooltip.initialize(),this.active.length?(i.extend(this.tooltip,{opacity:1,_active:this.active}),this.tooltip.update()):i.extend(this.tooltip,{opacity:0})),this.tooltip.pivot(),!this.animating){var e;i.each(this.active,function(t,i){t!==this.lastActive[i]&&(e=!0)},this),(!this.lastActive.length&&this.active.length||this.lastActive.length&&!this.active.length||this.lastActive.length&&this.active.length&&e)&&(this.stop(),this.render(this.options.hoverAnimationDuration))}return this.lastActive=this.active,this},getSliceAtEvent:function(t){var e=[],a=i.getRelativePosition(t);return i.each(this.data.metaData,function(t,i){t.inRange(a.x,a.y)&&e.push(t)},this),e},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},update:function(){this.total=0,i.each(this.data.data,function(t){this.total+=Math.abs(t.value)},this),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.borderWidth/2)/2,i.each(this.data.metaData,function(t,e){var a=this.data.data[e];i.extend(t,{_index:e,x:this.chart.width/2,y:this.chart.height/2,value:a.value,label:a.label,circumference:this.calculateCircumference(a.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.cutoutPercentage,backgroundColor:a.backgroundColor,hoverBackgroundColor:a.hoverBackgroundColor||a.backgroundColor,borderWidth:this.options.borderWidth,borderColor:this.options.segmentStrokeColor}),i.extend(t,{endAngle:t.startAngle+t.circumference}),0===e&&(t.startAngle=1.5*Math.PI),e<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',offsetGridLines:!1};e.Type.extend({name:"Line",defaults:a,initialize:function(t){this.data=t,this.PointClass=e.Point.extend({_chart:this.chart,offsetGridLines:this.options.offsetGridLines,borderWidth:this.options.pointBorderWidth,radius:this.options.pointRadius,hoverRadius:this.options.pointHoverRadius}),i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.buildScale(this.data.labels),i.each(this.data.datasets,function(t,a){t.metaDataset=new e.Line,t.metaData=[],i.each(t.data,function(e,i){t.metaData.push(new this.PointClass)},this)},this),this.eachDataset(function(t,e){t=i.merge(this.options,t),i.extend(t.metaDataset,{_points:t.metaData,_datasetIndex:e,_chart:this.chart}),t.metaDataset.save()},this),this.eachElement(function(t,e,a,n){i.extend(t,{x:this.scale.calculateX(e),y:this.scale.endPoint,_datasetIndex:n,_index:e,_chart:this.chart}),i.extend(t,{controlPointPreviousX:this.previousPoint(a,e).x,controlPointPreviousY:this.nextPoint(a,e).y,controlPointNextX:this.previousPoint(a,e).x,controlPointNextY:this.nextPoint(a,e).y}),t.save()},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},nextPoint:function(t,e){return t[e-1]||t[e]},previousPoint:function(t,e){return t[e+1]||t[e]},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hoverMode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length)switch(this.options.hoverMode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor,this.lastActive[0].borderWidth=this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth;break;case"label":for(var e=0;ethis.scale.endPoint?t.controlPointNextY=this.scale.endPoint:s.next.ythis.scale.endPoint?t.controlPointPreviousY=this.scale.endPoint:s.previous.y<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"PolarArea",defaults:a,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],a=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(a.x,a.y)&&e.push(t)},this),e},addData:function(t,e,i){var a=e||this.segments.length;this.segments.splice(a,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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.push(t.value)});var a=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,a,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var a={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(a),i.each(e.data,function(i,n){var s;this.scale.animation||(s=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),a.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:s.x,y:this.options.animation?this.scale.yCenter:s.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),a=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,s=Math.round((a.angle-1.5*Math.PI)/n),o=[];return(s>=this.scale.valuesCount||0>s)&&(s=0),a.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[s])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),a=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,a)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var a=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:a.x,y:a.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(a,n){i.extend(this.datasets[e].points[n],{value:a,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,a=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),a.lineWidth=this.options.datasetStrokeWidth,a.strokeStyle=t.strokeColor,a.beginPath(),i.each(t.points,function(t,e){0===e?a.moveTo(t.x,t.y):a.lineTo(t.x,t.y)},this),a.closePath(),a.stroke(),a.fillStyle=t.fillColor,a.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,a){function n(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,a)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),n=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,s=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function n(t){var e,i,a,n=t[0],s=t[1],o=t[2],r=Math.min(n,s,o),h=Math.max(n,s,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(s-o)/l:s==h?e=2+(o-n)/l:o==h&&(e=4+(n-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],i=t[1],n=t[2],s=a(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[s,100*o,100*n]}function o(t){var e,i,a,n,s=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-s,1-o,1-r),e=(1-s-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,a=(1-r-n)/(1-n)||0,[100*e,100*i,100*a,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var n=.4124*e+.3576*i+.1805*a,s=.2126*e+.7152*i+.0722*a,o=.0193*e+.1192*i+.9505*a;return[100*n,100*s,100*o]}function c(t){var e,i,a,n=l(t),s=n[0],o=n[1],r=n[2];return s/=95.047,o/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(s-o),a=200*(o-r),[e,i,a]}function u(t){return E(c(t))}function d(t){var e,i,a,n,s,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)a=o+1/3*-(l-1),0>a&&a++,a>1&&a--,s=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,n[l]=255*s;return n}function p(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return s*=2,n*=1>=s?s:2-s,i=(s+n)/2,e=2*n/(s+n),[a,100*e,100*i]}function f(t){return s(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,n=Math.floor(e)%6,s=e-Math.floor(e),o=255*a*(1-i),r=255*a*(1-i*s),h=255*a*(1-i*(1-s)),a=255*a;switch(n){case 0:return[a,h,o];case 1:return[r,a,o];case 2:return[o,a,h];case 3:return[o,r,a];case 4:return[h,o,a];case 5:return[a,o,r]}}function w(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return i=(2-n)*s,e=n*s,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function x(t){return s(y(t))}function S(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,a,n,s=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*s),i=1-h,a=6*s-e,0!=(1&e)&&(a=1-a),n=o+a*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return a(k(t))}function A(t){return n(k(t))}function L(t){return o(k(t))}function M(t){return h(k(t))}function _(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),a=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*a]}function F(t){return a(_(t))}function R(t){return n(_(t))}function W(t){return s(_(t))}function T(t){return h(_(t))}function z(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*s+o*-.4986,i=n*-.9689+1.8758*s+.0415*o,a=.0557*n+s*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function B(t){var e,i,a,n=t[0],s=t[1],o=t[2];return n/=95.047,s/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*s-16,i=500*(n-s),a=200*(s-o),[e,i,a]}function I(t){return E(B(t))}function O(t){var e,i,a,n,s=t[0],o=t[1],r=t[2];return 8>=s?(i=100*s/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),a=.008859>=a/108.883?a=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,a]}function E(t){var e,i,a,n=t[0],s=t[1],o=t[2];return e=Math.atan2(o,s),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(s*s+o*o),[n,a,i]}function D(t){return z(O(t))}function V(t){var e,i,a,n=t[0],s=t[1],o=t[2];return a=o/360*2*Math.PI,e=s*Math.cos(a),i=s*Math.sin(a),[n,e,i]}function H(t){return O(V(t))}function Y(t){return D(V(t))}function q(t){return U[t]}function X(t){return a(q(t))}function N(t){return n(q(t))}function j(t){return s(q(t))}function G(t){return o(q(t))}function Z(t){return c(q(t))}function Q(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:n,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:x,hsv2cmyk:S,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:A,hwb2cmyk:L,hwb2keyword:M,cmyk2rgb:_,cmyk2hsl:F,cmyk2hsv:R,cmyk2hwb:W,cmyk2keyword:T,keyword2rgb:q,keyword2hsl:X,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:z,xyz2lab:B,xyz2lch:I,lab2xyz:O,lab2rgb:D,lab2lch:E,lch2lab:V,lch2xyz:H,lch2rgb:Y};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var a=t("./conversions"),n=function(){return new l};for(var s in a){n[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return x[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:a,getHsla:n,getRgb:o,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var x={};for(var S in w)x[w[S]]=S},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,n=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=n,i=this.width=t.canvas.width,n=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,a.retinaScale(this),this};i.defaults={global:{animation:!0,animationDuration:1e3,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,maintainAspectRatio:!0,hoverMode:"single",onHover:null,onClick:null,hoverAnimationDuration:400,showTooltips:!0,customTooltips:!1,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],tooltipBackgroundColor:"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:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){},defaultColor:"rgba(0,0,0,0.1)"}},i.types={};var a=i.helpers={},n=a.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;a--){var n=t[a];if(e(n))return n}},a.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=l,t&&o(i.prototype,t),i.__super__=e.prototype,i}),c=a.noop=function(){},u=a.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=a.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=a.amd="function"==typeof define&&define.amd,g=a.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},f=a.max=function(t){return Math.max.apply(Math,t)},v=a.min=function(t){return Math.min.apply(Math,t)},m=(a.cap=function(t,e,i){if(g(e)){if(t>e)return e}else if(g(i)&&i>t)return i;return t},a.getDecimalPlaces=function(t){if(t%1!==0&&g(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0}),b=a.radians=function(t){return t*(Math.PI/180)},y=(a.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,n=Math.sqrt(i*i+a*a),s=2*Math.PI+Math.atan2(a,i);return 0>i&&0>a&&(s+=2*Math.PI),{angle:s,distance:n}},a.aliasPixel=function(t){return t%2===0?0:.5}),w=(a.splineCurve=function(t,e,i,a){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=a*n/(n+s),r=a*s/(n+s);return{next:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},previous:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},a.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),x=(a.calculateScaleRange=function(t,e,i,a,n){var s=2,o=Math.floor(e/(1.5*i)),r=s>=o,h=f(t),l=v(t);h===l&&(h+=.5,l>=.5&&!a?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=w(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=a?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),g=d-p,m=Math.pow(10,u),b=Math.round(g/m);(b>o||o>2*b)&&!r;)if(b>o)m*=2,b=Math.round(g/m),b%1!==0&&(r=!0);else if(n&&u>=0){if(m/2%1!==0)break;m/=2,b=Math.round(g/m)}else m/=2,b=Math.round(g/m);return r&&(b=s,m=g/b),{steps:b,stepValue:m,min:p,max:p+b*m}},a.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),S=(a.generateLabels=function(t,e,i,a){var s=new Array(e);return t&&n(s,function(e,n){s[n]=x(t,{value:i+a*(n+1)})}),s},a.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-S.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*S.easeInBounce(2*t):.5*S.easeOutBounce(2*t-1)+.5}}),C=a.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),k=(a.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),a.animationLoop=function(t,e,i,a,n,s){var o=0,r=S[i]||S.linear,h=function(){o++;var i=o/e,l=r(i);t.call(s,l,i,o),a.call(s,l,i),e>o?s.animationFrame=C(h):n.apply(s)};C(h)},a.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,n=t.currentTarget||t.srcElement,s=n.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},a.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),P=a.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},A=(a.bindEvents=function(t,e,i){t.events||(t.events={}),n(e,function(e){t.events[e]=function(){i.apply(t,arguments)},k(t.chart.canvas,e,t.events[e])})},a.unbindEvents=function(t,e){n(e,function(e,i){P(t.chart.canvas,i,e)})}),L=a.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(_(e,"padding-left"))+parseInt(_(e,"padding-right"));return e.clientWidth-i},M=a.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(_(e,"padding-bottom"))+parseInt(_(e,"padding-top"));return e.clientHeight-i},_=a.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},F=(a.getMaximumSize=a.getMaximumWidth,a.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),R=a.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=a.fontString=function(t,e,i){return e+" "+t+"px "+i},T=a.longestText=function(t,e,i){t.font=e;var a=0;return n(i,function(e){var i=t.measureText(e).width;a=i>a?i:a}),a},z=a.drawRoundedRectangle=function(t,e,i,a,n,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+n-s),t.quadraticCurveTo(e+a,i+n,e+a-s,i+n),t.lineTo(e+s,i+n),t.quadraticCurveTo(e,i+n,e,i+n-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()};a.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},a.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=u(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return R(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=L(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:M(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,F(this.chart),this},redraw:c,render:function(t){if(this.options.animation){var e=new i.Animation;e.numSteps=(t||this.options.animationDuration)/16.66,e.easing=this.options.animationEasing,e.render=function(t,e){var i=a.easingEffects[e.easing],n=e.currentStep/e.numSteps,s=i(n);t.draw(s,n,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){a.each(this.data.datasets,function(e,i){a.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){a.each(this.data.datasets,function(e,i){a.each(e.data,t,this,i)},this)},eachDataset:function(t){a.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],n=a.getRelativePosition(t),s=function(t){i.push(t.metaData[e])},o=0;o0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._vm,e=this._chart.ctx;a.each(t._points,function(i,a){if(0===a)e.moveTo(i._vm.x,i._vm.y);else if(t._tension>0,0)e.lineTo(i._vm.x,i._vm.y);else{var n=this.previousPoint(i,t._points,a);e.bezierCurveTo(n._vm.controlPointNextX,n._vm.controlPointNextY,i._vm.controlPointPreviousX,i._vm.controlPointPreviousY,i._vm.x,i._vm.y)}},this),t._points.length>0&&(e.lineTo(t._points[t._points.length-1].x,t.scaleZero),e.lineTo(t._points[0].x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),a.each(t._points,function(i,a){if(0===a)e.moveTo(i._vm.x,i._vm.y);else if(t._tension>0,0)e.lineTo(i._vm.x,i._vm.y);else{var n=this.previousPoint(i,t._points,a);e.bezierCurveTo(n._vm.controlPointNextX,n._vm.controlPointNextY,i._vm.controlPointPreviousX,i._vm.controlPointPreviousY,i._vm.x,i._vm.y)}},this),e.stroke()},previousPoint:function(t,e,i){return a.findPreviousWhere(e,function(){return!0},i)||t}}),i.Arc=i.Element.extend({inRange:function(t,e){var i=this._vm,n=a.getAngleFromPoint(i,{x:t,y:e}),s=n.angle>=i.startAngle&&n.angle<=i.endAngle,o=n.distance>=i.innerRadius&&n.distance<=i.outerRadius;return s&&o},tooltipPosition:function(){var t=this._vm,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._vm;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._vm,e=this.ctx,i=t.width/2,a=t.x-i,n=t.x+i,s=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(a+=o,n-=o,s+=o),e.beginPath(),e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.moveTo(a,t.base),e.lineTo(a,s),e.lineTo(n,s),e.lineTo(n,t.base),e.fill(),t.borderWidth&&e.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,e){var i=this._vm;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._vm;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._vm;return t.y=0&&(i=this._data.datasets[r].metaData,n=h(i,this._active[0]),-1===n);r--);var l=function(t){var e,i,r,h,l,c=[],u=[],d=[];return a.each(this._data.datasets,function(t){e=t.metaData,e[n]&&e[n].hasValue()&&c.push(e[n])}),a.each(c,function(t){u.push(t._vm.x),d.push(t._vm.y),s.push(a.template(this._options.multiTooltipTemplate,t)),o.push({fill:t._vm.backgroundColor,stroke:t._vm.borderColor})},this),l=v(d),r=f(d),h=v(u),i=f(u),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,n);a.extend(this,{x:l.x,y:l.y,labels:s,title:this._active.length?this._active[0].label:"",legendColors:o,legendBackgroundColor:this._options.multiTooltipKeyBackground}),this.height=s.length*this.fontSize+(s.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize;var c=t.measureText(this.title).width,u=T(t,this.font,s)+this.fontSize+3,d=f([u,c]);this.width=d+2*this.xPadding;var p=this.height/2;this.y-p<0?this.y=p:this.y+p>this._chart.height&&(this.y=this._chart.height-p),this.x>this._chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._vm;switch(this._options.hoverMode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,n=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,o=s+e.caretHeight+i;e.x+n/2>this._chart.width?e.xAlign="left":e.x-n/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-n/2,h=e.y-o;if(t.fillStyle=a.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._vm);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-n+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}z(t,r,h,n,s,e.cornerRadius),t.fill(),t.fillStyle=a.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+n/2,h+s/2)}break;case"label":z(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=a.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),a.each(e.labels,function(i,n){t.fillStyle=a.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(n+1)),t.fillStyle=a.color(e.legendBackgroundColor).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize),t.fillStyle=a.color(e.legendColors[n].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._vm.y-this._vm.height/2+this._vm.yPadding,i=t-1;return 0===t?e+this._vm.titleFontSize/2:e+(1.5*this._vm.fontSize*i+this._vm.fontSize/2)+1.5*this._vm.titleFontSize}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?T(this.ctx,this.font,this.yLabels)+10: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,e=this.endPoint,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(),tthis.yLabelWidth?i/2:this.yLabelWidth,this.xLabelRotation=0,this.display){var n,s=T(this.ctx,this.font,this.xLabels);this.xLabelWidth=s;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(b(this.xLabelRotation)),t=n*i,e=n*a,t+this.fontSize/2>this.yLabelWidth&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*s;this.xLabelRotation>0&&(this.endPoint-=Math.sin(b(this.xLabelRotation))*s+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 e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),a=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(a+=i/2),Math.round(a)},update:function(t){a.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,s){var o=this.endPoint-e*s,r=Math.round(o),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,o),0!==s||h||(h=!0),h&&t.beginPath(),s>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r+=a.aliasPixel(t.lineWidth),h&&(t.moveTo(i,r),t.lineTo(this.width,r),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-5,r),t.lineTo(i,r),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var a=this.calculateX(i)+y(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+y(this.lineWidth),s=this.xLabelRotation>0,o=this.showVerticalLines;0!==i||o||(o=!0),o&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),o&&(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(a,s?this.endPoint+12:this.endPoint+8),t.rotate(-1*b(this.xLabelRotation)),t.font=this.font,t.textAlign=s?"right":"center",t.textBaseline=s?"middle":"top",t.fillText(e,0,0),t.restore()},this))}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=v([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},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=m(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,a,n,s,o,r,h,l,c,u,d=v([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,f=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+a,n=e),t.x-ap&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var a,n=i*(this.drawingArea/this.steps),s=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 o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var a=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var s=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],a.x,a.y)}}}}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var n=0;n1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var n=Date.now(),s=n-t-this.frameDuration,o=s/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&a.requestAnimFrame.call(window,this.digestWrapper)}},a.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()), +p?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barBorderWidth:2,barValueSpacing:5,barDatasetSpacing:1,relativeBars:!1,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Bar",defaults:a,initialize:function(t){this.data=t;var a=this.options,n=this;this.ScaleClass=e.Scale.extend({offsetGridLines:!0,calculateBarBase:function(t,e){var i=0;if(n.options.stacked){var a=n.data.datasets[t].metaData[e];if(a.value<0)for(var s=0;t>s;s++)i+=n.data.datasets[s].metaData[e].values;s++)i+=n.data.datasets[s].metaData[e].value>i?n.data.datasets[s].metaData[e].value:0;return this.calculateY(i)}return i=this.endPoint,this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.calculateY(0),i+=n.options.scaleGridLineWidth):this.min<0&&this.max<0&&(i=this.startPoint),i},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),o=this.calculateX(i)-s/2,r=this.calculateBarWidth(t);return n.options.stacked?o+r/2:o+r*e+e*a.barDatasetSpacing+r/2},calculateBarY:function(t,e,i,a){if(n.options.stacked){for(var s=0,o=0,r=0;e>r;r++)t[r].metaData[i].value<0?o+=t[r].metaData[i].value||0:s+=t[r].metaData[i].value||0;return this.calculateY(0>a?o+a:s+a)}var h=0;for(r=e;ra?i[n]+=a:t[n]+=a}),t.concat(i)):(e.eachValue(function(e,i){t.push(e)}),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 e=i.calculateScaleRange(a(),t,this.fontSize,this.beginAtZero,this.integersOnly);i.extend(this,e)},xLabels:t,font:i.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,showHorizontalLines:this.options.scaleShowHorizontalLines,showVerticalLines:this.options.scaleShowVerticalLines,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.borderWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&i.extend(n,{calculateYRange:i.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)},redraw:function(){var t=this.scale.zeroPoint;this.eachElement(function(e,a,n){i.extend(e,{y:t,base:t})}),this.render()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(e),this.eachElement(function(t,i,a){t.transition(e).draw()},this),this.tooltip.transition(e).draw()}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={segmentShowStroke:!0,segmentStrokeColor:"#fff",borderWidth:2,cutoutPercentage:50,hoverAnimationDuration:400,animationEasing:"easeOutQuart",animateRotate:!0,animateScale:!1,legendTemplate:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};e.Type.extend({name:"Doughnut",defaults:a,initialize:function(t){this.data=t,this.Slice=e.Arc.extend({_chart:this.chart,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,this.onHover),this.data.metaData=[],i.each(this.data.data,function(e,a){var n=new this.Slice;"number"==typeof e?i.extend(n,{value:e}):i.extend(n,e),i.extend(n,{startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(n.value),outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout}),n.backgroundColor||(e.backgroundColor="hsl("+360*a/t.length+", 100%, 50%)"),n.save(),this.data.metaData.push(n)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=this.getSliceAtEvent(t),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length&&(this.lastActive[0].backgroundColor=this.data.data[this.lastActive[0]._index].backgroundColor),this.active.length&&this.options.hoverMode&&(this.active[0].backgroundColor=this.data.data[this.active[0]._index].hoverBackgroundColor||i.color(this.data.data[this.active[0]._index].backgroundColor).saturate(.5).darken(.35).rgbString()),this.options.showTooltips&&(this.tooltip.initialize(),this.active.length?(i.extend(this.tooltip,{opacity:1,_active:this.active}),this.tooltip.update()):i.extend(this.tooltip,{opacity:0})),this.tooltip.pivot(),!this.animating){var e;i.each(this.active,function(t,i){t!==this.lastActive[i]&&(e=!0)},this),(!this.lastActive.length&&this.active.length||this.lastActive.length&&!this.active.length||this.lastActive.length&&this.active.length&&e)&&(this.stop(),this.render(this.options.hoverAnimationDuration))}return this.lastActive=this.active,this},getSliceAtEvent:function(t){var e=[],a=i.getRelativePosition(t);return i.each(this.data.metaData,function(t,i){t.inRange(a.x,a.y)&&e.push(t)},this),e},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},update:function(){this.total=0,i.each(this.data.data,function(t){this.total+=Math.abs(t.value)},this),this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.borderWidth/2)/2,i.each(this.data.metaData,function(t,e){var a=this.data.data[e];i.extend(t,{_index:e,x:this.chart.width/2,y:this.chart.height/2,value:a.value,label:a.label,circumference:this.calculateCircumference(a.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.cutoutPercentage,backgroundColor:a.backgroundColor,hoverBackgroundColor:a.hoverBackgroundColor||a.backgroundColor,borderWidth:this.options.borderWidth,borderColor:this.options.segmentStrokeColor}),i.extend(t,{endAngle:t.startAngle+t.circumference}),0===e&&(t.startAngle=1.5*Math.PI),e<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"Line",defaults:a,initialize:function(){i.bindEvents(this,this.options.events,this.events);var t=this;this.ScaleClass=e.Scale.extend({calculatePointY:function(e,i){var a=t.data.datasets[i].data[e];if(t.options.stacked){for(var n=0,s=0,o=0;i>o;o++)t.data.datasets[o].data[e]<0?s+=t.data.datasets[o].data[e]:n+=t.data.datasets[o].data[e];return this.calculateY(0>a?s+a:n+a)}return this.calculateY(a)}}),this.buildScale(this.data.labels),i.each(this.data.datasets,function(t,a){t.metaDataset=new e.Line,t.metaData=[],i.each(t.data,function(i,a){t.metaData.push(new e.Point)},this)},this),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_points:t.metaData,_datasetIndex:e,_chart:this.chart}),i.extend(t,i.merge(this.options,t)),t.metaDataset.save()},this),this.eachElement(function(t,e,a,n){i.extend(t,{x:this.scale.calculateX(e),y:this.scale.calculateY(0),_datasetIndex:n,_index:e,_chart:this.chart}),i.extend(t,{controlPointPreviousX:this.previousPoint(a,e).x,controlPointPreviousY:this.nextPoint(a,e).y,controlPointNextX:this.previousPoint(a,e).x,controlPointNextY:this.nextPoint(a,e).y}),t.save()},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},nextPoint:function(t,e){return t[e-1]||t[e]},previousPoint:function(t,e){return t[e+1]||t[e]},update:function(){this.scale.update(),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_datasetIndex:e,_points:t.metaData,scaleTop:this.scale.startPoint,scaleBottom:this.scale.endPoint,scaleZero:this.scale.calculateY(0),tension:t.tension||this.options.tension,backgroundColor:t.backgroundColor||this.options.backgroundColor,borderWidth:t.borderWidth||this.options.borderWidth,borderColor:t.borderColor||this.options.borderColor}),t.metaDataset.pivot()}),this.eachElement(function(t,e,a,n){i.extend(t,{_chart:this.chart,_datasetIndex:n,_index:e,label:this.data.labels[e],value:this.data.datasets[n].data[e],datasetLabel:this.data.datasets[n].label,offsetGridLines:this.options.offsetGridLines,x:this.scale.calculateX(e),y:this.scale.calculatePointY(e,n),tension:this.data.datasets[n].metaDataset.tension,radius:this.data.datasets[n].pointRadius||this.options.pointRadius,backgroundColor:this.data.datasets[n].pointBackgroundColor||this.options.pointBackgroundColor,borderWidth:this.data.datasets[n].pointBorderWidth||this.options.pointBorderWidth,hoverRadius:this.data.datasets[n].pointHitRadius||this.options.pointHitRadius})},this),this.eachElement(function(t,e,a,n){var s=i.splineCurve(this.previousPoint(a,e),t,this.nextPoint(a,e),t.tension);t.controlPointPreviousX=s.previous.x,t.controlPointNextX=s.next.x,s.next.y>this.scale.endPoint?t.controlPointNextY=this.scale.endPoint:s.next.ythis.scale.endPoint?t.controlPointPreviousY=this.scale.endPoint:s.previous.ya?i[n]+=a:t[n]+=a}),t.concat(i)):(e.eachValue(function(e,i){t.push(e)}),t)},n={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,offsetGridLines:this.options.offsetGridLines,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 e=i.calculateScaleRange(a(),t,this.fontSize,this.beginAtZero,this.integersOnly);i.extend(this,e)},xLabels:this.data.labels,font:i.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,showHorizontalLines:this.options.scaleShowHorizontalLines,showVerticalLines:this.options.scaleShowVerticalLines,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.pointRadius+this.options.pointBorderWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&i.extend(n,{calculateYRange:i.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)},redraw:function(){},draw:function(t){var e=t||1;this.clear(),this.scale.draw(e);for(var a=this.data.datasets.length-1;a>=0;a--){var n=this.data.datasets[a];i.each(n.metaData,function(t,i){t.transition(e)},this),n.metaDataset.transition(e).draw(),i.each(n.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hoverMode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e;if(this.lastActive.length)switch(this.options.hoverMode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],this.lastActive[0].radius=e.pointRadius,this.lastActive[0].backgroundColor=e.pointBackgroundColor,this.lastActive[0].borderColor=e.pointBorderColor,this.lastActive[0].borderWidth=e.pointBorderWidth;break;case"label":for(var a=0;a<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};e.Type.extend({name:"PolarArea",defaults:a,initialize:function(t){this.data=t,this.segments=[],this.SegmentArc=e.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 e.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(),i.each(t,function(t,e){this.addData(t,e,!0)},this),this.options.showTooltips&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];i.each(this.segments,function(t){t.restore(["fillColor"])}),i.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.render()},getSegmentsAtEvent:function(t){var e=[],a=i.getRelativePosition(t);return i.each(this.segments,function(t){t.inRange(a.x,a.y)&&e.push(t)},this),e},addData:function(t,e,i){var a=e||this.segments.length;this.segments.splice(a,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})),i||(this.reflow(),this.update())},removeData:function(t){var e=i.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,i.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var e=[];i.each(t,function(t){e.push(t.value)});var a=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,a,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.data.length==this.segments.length?i.each(this.data,function(t,e){i.extend(this.segments[e],{fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value})},this):this.initialize(this.data),this.calculateTotal(this.segments),i.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),i.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),i.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.segments,function(t,i){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},e),t.endAngle=t.startAngle+t.circumference,0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.data=t,this.PointClass=e.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&&i.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),i.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),i.each(t.datasets,function(e){var a={label:e.label||null,fillColor:e.fillColor,strokeColor:e.strokeColor,pointColor:e.pointColor,pointStrokeColor:e.pointStrokeColor,points:[]};this.datasets.push(a),i.each(e.data,function(i,n){var s;this.scale.animation||(s=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(i))),a.points.push(new this.PointClass({value:i,label:t.labels[n],datasetLabel:e.label,x:this.options.animation?this.scale.xCenter:s.x,y:this.options.animation?this.scale.yCenter:s.y,strokeColor:e.pointStrokeColor,fillColor:e.pointColor,highlightFill:e.pointHighlightFill||e.pointColor,highlightStroke:e.pointHighlightStroke||e.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){i.each(this.datasets,function(e){i.each(e.points,t,this)},this)},getPointsAtEvent:function(t){var e=i.getRelativePosition(t),a=i.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},e),n=2*Math.PI/this.scale.valuesCount,s=Math.round((a.angle-1.5*Math.PI)/n),o=[];return(s>=this.scale.valuesCount||0>s)&&(s=0),a.distance<=this.scale.drawingArea&&i.each(this.datasets,function(t){o.push(t.points[s])}),o},buildScale:function(t){this.scale=new e.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 e=function(){var e=[];return i.each(t,function(t){t.data?e=e.concat(t.data):i.each(t.points,function(t){e.push(t.value)})}),e}(),a=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}:i.calculateScaleRange(e,i.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);i.extend(this.scale,a)},addData:function(t,e){this.scale.valuesCount++,i.each(t,function(t,i){var a=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[i].points.push(new this.PointClass({value:t,label:e,datasetLabel:this.datasets[i].label,x:a.x,y:a.y,strokeColor:this.datasets[i].pointStrokeColor,fillColor:this.datasets[i].pointColor}))},this),this.scale.labels.push(e),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),i.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){i.each(this.data.datasets,function(t,e){i.extend(this.datasets[e],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),i.each(t.data,function(a,n){i.extend(this.datasets[e].points[n],{value:a,label:this.data.labels[n],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){i.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:i.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 e=t||1,a=this.chart.ctx;this.clear(),this.scale.draw(),i.each(this.datasets,function(t){i.each(t.points,function(t,i){t.hasValue()&&t.transition(this.scale.getPointPosition(i,this.scale.calculateCenterOffset(t.value)),e)},this),a.lineWidth=this.options.datasetStrokeWidth,a.strokeStyle=t.strokeColor,a.beginPath(),i.each(t.points,function(t,e){0===e?a.moveTo(t.x,t.y):a.lineTo(t.x,t.y)},this),a.closePath(),a.stroke(),a.fillStyle=t.fillColor,a.fill(),i.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),!function t(e,i,a){function n(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return n(i?i:t)},c,c.exports,t,e,i,a)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),n=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,s=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function n(t){var e,i,a,n=t[0],s=t[1],o=t[2],r=Math.min(n,s,o),h=Math.max(n,s,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(s-o)/l:s==h?e=2+(o-n)/l:o==h&&(e=4+(n-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],i=t[1],n=t[2],s=a(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[s,100*o,100*n]}function o(t){var e,i,a,n,s=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-s,1-o,1-r),e=(1-s-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,a=(1-r-n)/(1-n)||0,[100*e,100*i,100*a,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var n=.4124*e+.3576*i+.1805*a,s=.2126*e+.7152*i+.0722*a,o=.0193*e+.1192*i+.9505*a;return[100*n,100*s,100*o]}function c(t){var e,i,a,n=l(t),s=n[0],o=n[1],r=n[2];return s/=95.047,o/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(s-o),a=200*(o-r),[e,i,a]}function u(t){return D(c(t))}function d(t){var e,i,a,n,s,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)a=o+1/3*-(l-1),0>a&&a++,a>1&&a--,s=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,n[l]=255*s;return n}function p(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return s*=2,n*=1>=s?s:2-s,i=(s+n)/2,e=2*n/(s+n),[a,100*e,100*i]}function f(t){return s(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function y(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,n=Math.floor(e)%6,s=e-Math.floor(e),o=255*a*(1-i),r=255*a*(1-i*s),h=255*a*(1-i*(1-s)),a=255*a;switch(n){case 0:return[a,h,o];case 1:return[r,a,o];case 2:return[o,a,h];case 3:return[o,r,a];case 4:return[h,o,a];case 5:return[a,o,r]}}function w(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return i=(2-n)*s,e=n*s,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function x(t){return s(y(t))}function S(t){return o(y(t))}function C(t){return h(y(t))}function k(t){var e,i,a,n,s=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*s),i=1-h,a=6*s-e,0!=(1&e)&&(a=1-a),n=o+a*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function P(t){return a(k(t))}function A(t){return n(k(t))}function L(t){return o(k(t))}function M(t){return h(k(t))}function _(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),a=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*a]}function F(t){return a(_(t))}function R(t){return n(_(t))}function W(t){return s(_(t))}function T(t){return h(_(t))}function z(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*s+o*-.4986,i=n*-.9689+1.8758*s+.0415*o,a=.0557*n+s*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function B(t){var e,i,a,n=t[0],s=t[1],o=t[2];return n/=95.047,s/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*s-16,i=500*(n-s),a=200*(s-o),[e,i,a]}function I(t){return D(B(t))}function O(t){var e,i,a,n,s=t[0],o=t[1],r=t[2];return 8>=s?(i=100*s/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),a=.008859>=a/108.883?a=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,a]}function D(t){var e,i,a,n=t[0],s=t[1],o=t[2];return e=Math.atan2(o,s),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(s*s+o*o),[n,a,i]}function E(t){return z(O(t))}function V(t){var e,i,a,n=t[0],s=t[1],o=t[2];return a=o/360*2*Math.PI,e=s*Math.cos(a),i=s*Math.sin(a),[n,e,i]}function H(t){return O(V(t))}function Y(t){return E(V(t))}function q(t){return U[t]}function X(t){return a(q(t))}function N(t){return n(q(t))}function j(t){return s(q(t))}function G(t){return o(q(t))}function Z(t){return c(q(t))}function Q(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:n,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:x,hsv2cmyk:S,hsv2keyword:C,hwb2rgb:k,hwb2hsl:P,hwb2hsv:A,hwb2cmyk:L,hwb2keyword:M,cmyk2rgb:_,cmyk2hsl:F,cmyk2hsv:R,cmyk2hwb:W,cmyk2keyword:T,keyword2rgb:q,keyword2hsl:X,keyword2hsv:N,keyword2hwb:j,keyword2cmyk:G,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:z,xyz2lab:B,xyz2lch:I,lab2xyz:O,lab2rgb:E,lab2lch:D,lch2lab:V,lch2xyz:H,lch2rgb:Y};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var a=t("./conversions"),n=function(){return new l};for(var s in a){n[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return p(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+n+"%)"}function p(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return x[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function y(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var w=t("color-name");e.exports={getRgba:a,getHsla:n,getRgb:o,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var x={};for(var S in w)x[w[S]]=S},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/bower.json b/bower.json index f26f81eef8b..cc8681852a0 100644 --- a/bower.json +++ b/bower.json @@ -7,5 +7,9 @@ "main": [ "Chart.js" ], - "dependencies": {} -} \ No newline at end of file + "devDependencies": { + "angular": "~1.3.15", + "jquery": "~2.1.4", + "flatstrap": "~3.3.1" + } +} diff --git a/package.json b/package.json index 5004db75d86..3f63e7b8599 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "gulp-uglify": "~0.2.x", "gulp-util": "~2.2.x", "inquirer": "^0.5.1", + "jquery": "^2.1.4", "onecolor": "^2.5.0", "semver": "^3.0.1" }, diff --git a/samples/bar.html b/samples/bar.html index eea5b659be7..8b0f1e942fc 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -3,8 +3,8 @@ Bar Chart + - @@ -14,10 +14,10 @@ diff --git a/samples/line.html b/samples/line.html index b6c2ae8e782..eac9b32fee1 100644 --- a/samples/line.html +++ b/samples/line.html @@ -4,7 +4,7 @@ Line Chart - + @@ -16,7 +16,7 @@ + + + + + + diff --git a/samples/playground.js b/samples/playground.js new file mode 100644 index 00000000000..b75824483ba --- /dev/null +++ b/samples/playground.js @@ -0,0 +1,156 @@ +(function() { + + var module = angular.module('app', []); + + module.controller('mainController', function($scope, $timeout) { + angular.extend($scope, { + + chart: {}, + chartTypes: chartTypes(), + + init: init, + randomizeData: randomizeData, + }); + + + init(); + + + + function init() { + if ($scope._chart) { + $scope._chart.destroy(); + } + $scope.ctx = $('canvas')[0].getContext("2d"); + buildData(); + buildChart(); + + $scope.$watch('options', function(val) { + try { + angular.extend($scope.chart.options, JSON.parse(val)); + } catch (e) { + console.log(e); + } + }, true); + + $scope.$watch('chart.options', function() { + if ($scope._chart) { + $scope._chart.update(); + } + }, true); + } + + function chartTypes() { + return [{ + name: 'Line/Scatter', + value: 'Line/Scatter', + selected: true + }, { + name: 'Bar', + value: 'Bar', + }, { + name: 'Pie/Doughnut', + value: 'Pie/Doughnut', + }, { + name: 'Polar', + value: 'Polar', + }, { + name: 'Radar', + value: 'Radar', + }]; + } + + + + function buildData() { + $scope.chart.data = groupData(); + $scope.chart.options = { + stacked: true, + hoverMode: 'label' + }; + $scope.options = stringify($scope.chart.options); + } + + function buildChart() { + $scope._chart = new Chart($scope.ctx)[$scope.chartType || 'Line']($scope.chart); + } + + function stringify(o) { + var cache = []; + var result = JSON.stringify(o, function(key, value) { + if (typeof value === 'object' && value !== null) { + if (cache.indexOf(value) !== -1) { + // Circular reference found, discard key + return; + } + // Store value in our collection + cache.push(value); + } + return value; + }, 1); + cache = null; // Enable garbage collection + return result; + } + + + function groupData() { + return { + labels: ["January", "February", "March", "April", "May", "June", "July"], + datasets: [{ + label: "Dataset 1", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + backgroundColor: randomColor(0.8), + }, { + label: "Dataset 2", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + backgroundColor: randomColor(0.8), + }, { + label: "Dataset 3", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + backgroundColor: randomColor(0.8), + }] + }; + } + + function flatData() { + return { + labels: ["January", "February", "March", "April", "May", "June", "July"], + datasets: [{ + label: "My First dataset", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + }, { + label: "My Second dataset", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + }] + }; + } + + function randomizeData() { + + angular.forEach($scope.chart.data.datasets, function(dataset) { + + dataset.data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; + dataset.backgroundColor = randomColor(.8); + dataset.borderColor = randomColor(0.7); + dataset.pointBackgroundColor = randomColor(1); + dataset.pointBorderColor = randomColor(1); + + + $scope._chart.update(); + }); + } + + + + + function randomScalingFactor() { + return Math.round(Math.random() * 100 * (Math.random() > 0.5 ? -1 : 1)); + } + + function randomColor(opacity) { + return 'rgba(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + (typeof opacity != "undefined" ? opacity : '.3') + ')'; + } + + }); + +})(); diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 8eb436a4db2..ee9c7921ed8 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -34,6 +34,9 @@ //Number - Spacing between data sets within X values barDatasetSpacing: 1, + //Boolean - Whether bars should be rendered on a percentage base + relativeBars: false, + //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " @@ -50,26 +53,109 @@ var options = this.options; + var _this = this; + // Custom Scale Methods and Options this.ScaleClass = Chart.Scale.extend({ offsetGridLines: true, + calculateBarBase: function(datasetIndex, index) { + + var base = 0; + + if (_this.options.stacked) { + var bar = _this.data.datasets[datasetIndex].metaData[index]; + if (bar.value < 0) { + for (var i = 0; i < datasetIndex; i++) { + base += _this.data.datasets[i].metaData[index].value < base ? _this.data.datasets[i].metaData[index].value : 0; + } + } else { + for (var i = 0; i < datasetIndex; i++) { + base += _this.data.datasets[i].metaData[index].value > base ? _this.data.datasets[i].metaData[index].value : 0; + } + } + return this.calculateY(base); + } + + base = this.endPoint; + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.calculateY(0); + base += _this.options.scaleGridLineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.startPoint; + } + + return base; + + }, calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar var xWidth = this.calculateBaseWidth(), xAbsolute = this.calculateX(elementIndex) - (xWidth / 2), barWidth = this.calculateBarWidth(datasetCount); + if (_this.options.stacked) { + return xAbsolute + barWidth / 2; + } + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth / 2; }, + calculateBarY: function(datasets, datasetIndex, barIndex, value) { + + if (_this.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (datasets[i].metaData[barIndex].value < 0) { + sumNeg += datasets[i].metaData[barIndex].value || 0; + } else { + sumPos += datasets[i].metaData[barIndex].value || 0; + } + } + + if (value < 0) { + return this.calculateY(sumNeg + value); + } else { + return this.calculateY(sumPos + value); + } + + /*if (options.relativeBars) { + offset = offset / sum * 100; + }*/ + + return this.calculateY(0); + } + + var offset = 0; + + for (i = datasetIndex; i < datasets.length; i++) { + if (i === datasetIndex && value) { + offset += value; + } else { + offset = offset + (datasets[i].metaData[barIndex].value); + } + } + + return this.calculateY(value); + }, calculateBaseWidth: function() { return (this.calculateX(1) - this.calculateX(0)) - (2 * options.barValueSpacing); }, + calculateBaseHeight: function() { + return (this.calculateY(1) - this.calculateY(0)); + }, calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); + if (_this.options.stacked) { + return baseWidth; + } return (baseWidth / datasetCount); - } + }, }); // Events @@ -92,11 +178,12 @@ }, this); // Set defaults for bars - this.eachElement(function(bar, index, datasetIndex) { + this.eachElement(function(bar, index, dataset, datasetIndex) { helpers.extend(bar, { + base: this.scale.zeroPoint, width: this.scale.calculateBarWidth(this.data.datasets.length), x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.calculateBaseY(), + y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), _datasetIndex: datasetIndex, _index: index, }); @@ -167,13 +254,13 @@ if (this.active.length && this.options.hoverMode) { switch (this.options.hoverMode) { case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.8).darken(0.2).rgbString(); + this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.8).darken(0.2).rgbString(); break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.8).darken(0.2).rgbString(); + this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.8).darken(0.2).rgbString(); } break; case 'dataset': @@ -233,30 +320,23 @@ this.lastActive = this.active; return this; }, - // Calculate the base point for the bar. - calculateBaseY: function() { - var base = this.scale.endPoint; - - if (this.scale.beginAtZero || ((this.scale.min <= 0 && this.scale.max >= 0) || (this.scale.min >= 0 && this.scale.max <= 0))) { - base = this.scale.calculateY(0); - base += this.options.scaleGridLineWidth; - } else if (this.scale.min < 0 && this.scale.max < 0) { - // All values are negative. Use the top as the base - base = this.scale.startPoint; - } - - return base; - }, update: function() { this.scale.update(); this.eachElement(function(bar, index, dataset, datasetIndex) { helpers.extend(bar, { - width: this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), value: this.data.datasets[datasetIndex].data[index], + }); + bar.pivot(); + }, this); + + this.eachElement(function(bar, index, dataset, datasetIndex) { + helpers.extend(bar, { + base: this.scale.calculateBarBase(datasetIndex, index), + x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), + width: this.scale.calculateBarWidth(this.data.datasets.length), label: this.data.labels[index], datasetLabel: this.data.datasets[datasetIndex].label, borderColor: this.data.datasets[datasetIndex].borderColor, @@ -275,10 +355,31 @@ var dataTotal = function() { var values = []; - self.eachValue(function(value) { + var negativeValues = []; + + if (self.options.stacked) { + self.eachValue(function(value, index) { + values[index] = values[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + if (self.options.relativeBars) { + values[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + values[index] += value; + } + } + }); + return values.concat(negativeValues); + } + + self.eachValue(function(value, index) { values.push(value); }); + return values; + }; var scaleOptions = { @@ -330,7 +431,7 @@ }, // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function redraw: function() { - var base = this.calculateBaseY(); + var base = this.scale.zeroPoint; this.eachElement(function(element, index, datasetIndex) { helpers.extend(element, { y: base, @@ -348,12 +449,7 @@ //Draw all the bars for each dataset this.eachElement(function(bar, index, datasetIndex) { - if (bar.hasValue()) { - // Update the bar basepoint - bar.base = this.calculateBaseY(); - //Transition - bar.transition(easingDecimal).draw(); - } + bar.transition(easingDecimal).draw(); }, this); // Finally draw the tooltip diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 939fecf2910..9d23a580158 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -113,9 +113,12 @@ //String / Boolean - Hover mode for events. hoverMode: 'single', // 'label', 'dataset', 'false' - //Function - Custom hover handler + //Function(event) - Custom hover handler onHover: null, + //Function(event, clickedElements) - Custom click handler + onClick: null, + //Function - Custom hover handler hoverAnimationDuration: 400, @@ -125,8 +128,8 @@ // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function customTooltips: false, - // Array - Array of string names to attach tooltip events - tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], + // Array - Array of string names to attach interaction events + events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], // String - Tooltip background colour tooltipBackgroundColor: "rgba(0,0,0,0.8)", @@ -186,7 +189,7 @@ onAnimationComplete: function() {}, // Color String - Used for undefined Colros - colorFallback: 'rgba(0,0,0,0.1)', + defaultColor: 'rgba(0,0,0,0.1)', } }; @@ -910,19 +913,20 @@ //Destroy method on the chart will remove the instance of the chart from this reference. Chart.instances = {}; - Chart.Type = function(data, options, chart) { - this.options = options; - this.chart = chart; + Chart.Type = function(config, instance) { + this.data = config.data; + this.options = config.options; + this.chart = instance; this.id = uid(); //Add the chart instance to the global namespace Chart.instances[this.id] = this; // Initialize is always called when a chart type is created // By default it is a no op, but it should be extended - if (options.responsive) { + if (this.options.responsive) { this.resize(); } - this.initialize.call(this, data); + this.initialize.call(this); }; //Core methods that'll be a part of every chart type @@ -1087,9 +1091,9 @@ Chart.types[chartName] = ChartType; //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(data, options) { - var config = merge(Chart.defaults.global, Chart.defaults[chartName], options || {}); - return new ChartType(data, config, this); + Chart.prototype[chartName] = function(config) { + helpers.extend(config.options, merge(Chart.defaults.global, Chart.defaults[chartName], config.options || {})); + return new ChartType(config, this); }; } else { warn("Name not provided for this chart, so it hasn't been registered"); @@ -1196,7 +1200,8 @@ var vm = this._vm; return { x: vm.x, - y: vm.y + y: vm.y, + padding: vm.radius + vm.borderWidth }; }, draw: function() { @@ -1211,10 +1216,10 @@ ctx.arc(vm.x, vm.y, vm.radius, 0, Math.PI * 2); ctx.closePath(); - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.fill(); ctx.stroke(); @@ -1229,11 +1234,7 @@ var vm = this._vm; var ctx = this._chart.ctx; - //Draw the line between all the points - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.colorFallback; - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.colorFallback; - ctx.beginPath(); - + // Draw the background first (so the border is always on top) helpers.each(vm._points, function(point, index) { if (index === 0) { ctx.moveTo(point._vm.x, point._vm.y); @@ -1255,16 +1256,45 @@ } }, this); - ctx.stroke(); - if (vm._points.length > 0) { //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleBottom); - ctx.lineTo(vm._points[0].x, vm.scaleBottom); - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.colorFallback; + ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleZero); + ctx.lineTo(vm._points[0].x, vm.scaleZero); + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.closePath(); ctx.fill(); } + + + // Now draw the line between all the points with any borders + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.beginPath(); + + helpers.each(vm._points, function(point, index) { + if (index === 0) { + ctx.moveTo(point._vm.x, point._vm.y); + } else { + if (vm._tension > 0 || 1) { + var previous = this.previousPoint(point, vm._points, index); + + ctx.bezierCurveTo( + previous._vm.controlPointNextX, + previous._vm.controlPointNextY, + point._vm.controlPointPreviousX, + point._vm.controlPointPreviousY, + point._vm.x, + point._vm.y + ); + } else { + ctx.lineTo(point._vm.x, point._vm.y); + } + } + }, this); + + + ctx.stroke(); + }, previousPoint: function(point, collection, index) { return helpers.findPreviousWhere(collection, function() { @@ -1442,6 +1472,7 @@ helpers.extend(this, { x: Math.round(tooltipPosition.x), y: Math.round(tooltipPosition.y), + caretPadding: tooltipPosition.padding }); break; @@ -1562,7 +1593,7 @@ vm.yAlign = "above"; //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding = 2; + var caretPadding = vm.caretPadding || 2; var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, @@ -1723,14 +1754,14 @@ // Build the current yLabels so we have an idea of what size they'll be to start /* - * This sets what is returned from calculateScaleRange as static properties of this class: - * - this.steps; - this.stepValue; - this.min; - this.max; - * - */ + * This sets what is returned from calculateScaleRange as static properties of this class: + * + this.steps; + this.stepValue; + this.min; + this.max; + * + */ this.calculateYRange(cachedHeight); // With these properties set we can now build the array of yLabels diff --git a/src/Chart.Line.js b/src/Chart.Line.js index e328b0a68be..f02b63c4950 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -9,39 +9,50 @@ ///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 to show horizontal lines (except X axis) scaleShowHorizontalLines: true, - //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines: true, + //Boolean - Whether to horizontally center the label and point dot inside the grid + offsetGridLines: false, + + + + //Boolean - Whether to stack the lines essentially creating a stacked area chart. + stacked: false, + //Number - Tension of the bezier curve between points tension: 0.4, - //Number - Radius of each point dot in pixels - pointRadius: 4, + //Number - Radius of each point dot in pixels + pointRadius: 3, //Number - Pixel width of point dot border pointBorderWidth: 1, + //Number - Pixel width of point on hover + pointHoverRadius: 5, + //Number - Pixel width of point dot border on hover + pointHoverBorderWidth: 2, + pointBackgroundColor: Chart.defaults.global.defaultColor, + pointBorderColor: Chart.defaults.global.defaultColor, //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHoverRadius: 20, + pointHitRadius: 6, //Number - Pixel width of dataset border borderWidth: 2, + //Number - Pixel width of dataset border on hover + hoverBorderWidth: 2, //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - //Boolean - Whether to horizontally center the label and point dot inside the grid - offsetGridLines: false + }; @@ -49,23 +60,39 @@ Chart.Type.extend({ name: "Line", defaults: defaultConfig, - initialize: function(data) { - // Save data as a source for updating of values & methods - this.data = data; - - //Custom Point Defaults - this.PointClass = Chart.Point.extend({ - _chart: this.chart, - offsetGridLines: this.options.offsetGridLines, - borderWidth: this.options.pointBorderWidth, - radius: this.options.pointRadius, - hoverRadius: this.options.pointHoverRadius, - }); + initialize: function() { // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + helpers.bindEvents(this, this.options.events, this.events); + + var _this = this; // Build Scale + this.ScaleClass = Chart.Scale.extend({ + calculatePointY: function(index, datasetIndex) { + + var value = _this.data.datasets[datasetIndex].data[index]; + + if (_this.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + for (var i = 0; i < datasetIndex; i++) { + if (_this.data.datasets[i].data[index] < 0) { + offsetNeg += _this.data.datasets[i].data[index]; + } else { + offsetPos += _this.data.datasets[i].data[index]; + } + } + if (value < 0) { + return this.calculateY(offsetNeg + value); + } else { + return this.calculateY(offsetPos + value); + } + } + + return this.calculateY(value); + } + }); this.buildScale(this.data.labels); @@ -74,19 +101,20 @@ dataset.metaDataset = new Chart.Line(); dataset.metaData = []; helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new this.PointClass()); + dataset.metaData.push(new Chart.Point()); }, this); }, this); // Set defaults for lines this.eachDataset(function(dataset, datasetIndex) { - dataset = helpers.merge(this.options, dataset); helpers.extend(dataset.metaDataset, { _points: dataset.metaData, _datasetIndex: datasetIndex, _chart: this.chart, }); - // Copy to view model + // Fill in dataset defaults from options + helpers.extend(dataset, helpers.merge(this.options, dataset)); + // Copy to view modele dataset.metaDataset.save(); }, this); @@ -94,7 +122,7 @@ this.eachElement(function(point, index, dataset, datasetIndex) { helpers.extend(point, { x: this.scale.calculateX(index), - y: this.scale.endPoint, + y: this.scale.calculateY(0), _datasetIndex: datasetIndex, _index: index, _chart: this.chart @@ -126,145 +154,27 @@ previousPoint: function(collection, index) { return collection[index + 1] || collection[index]; }, - onHover: function(e) { - - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hoverMode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); - } - - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hoverMode) { - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; - this.lastActive[0].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBackgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBorderColor; - this.lastActive[i].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderWidth = this.data.datasets[this.active[0]._datasetIndex].borderWidth + 10; - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderWidth = this.data.datasets[this.active[i]._datasetIndex].borderWidth + 2; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.showTooltips) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - - }, update: function() { + // Update the scale this.scale.update(); // Update the lines this.eachDataset(function(dataset, datasetIndex) { helpers.extend(dataset.metaDataset, { + // Utility + _datasetIndex: datasetIndex, + // Data + _points: dataset.metaData, + // Geometry + scaleTop: this.scale.startPoint, + scaleBottom: this.scale.endPoint, + scaleZero: this.scale.calculateY(0), + // Appearance + tension: dataset.tension || this.options.tension, backgroundColor: dataset.backgroundColor || this.options.backgroundColor, borderWidth: dataset.borderWidth || this.options.borderWidth, borderColor: dataset.borderColor || this.options.borderColor, - tension: dataset.tension || this.options.tension, - scaleTop: this.scale.startPoint, - scaleBottom: this.scale.endPoint, - _points: dataset.metaData, - _datasetIndex: datasetIndex, }); dataset.metaDataset.pivot(); }); @@ -272,22 +182,25 @@ // Update the points this.eachElement(function(point, index, dataset, datasetIndex) { helpers.extend(point, { - x: this.scale.calculateX(index), - y: this.scale.calculateY(this.data.datasets[datasetIndex].data[index]), - value: this.data.datasets[datasetIndex].data[index], + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + // Data label: this.data.labels[index], + value: this.data.datasets[datasetIndex].data[index], datasetLabel: this.data.datasets[datasetIndex].label, - // Appearance - hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, - hoverBorderColor: this.data.datasets[datasetIndex].pointHoverBorderColor || this.options.pointHoverBorderColor, - hoverRadius: this.data.datasets[datasetIndex].pointHoverRadius || this.options.pointHoverRadius, + // Geometry + offsetGridLines: this.options.offsetGridLines, + x: this.scale.calculateX(index), + y: this.scale.calculatePointY(index, datasetIndex), + tension: this.data.datasets[datasetIndex].metaDataset.tension, + // Appearnce radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, - borderColor: this.data.datasets[datasetIndex].pointBorderColor || this.options.pointBorderColor, backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, - tension: this.data.datasets[datasetIndex].metaDataset.tension, - _datasetIndex: datasetIndex, - _index: index, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, + // Tooltip + hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.pointHitRadius, }); }, this); @@ -304,7 +217,6 @@ point.controlPointNextX = controlPoints.next.x; // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.scale.endPoint) { point.controlPointNextY = this.scale.endPoint; @@ -333,11 +245,31 @@ var dataTotal = function() { var values = []; - self.eachValue(function(value) { + var negativeValues = []; + + if (self.options.stacked) { + self.eachValue(function(value, index) { + values[index] = values[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + if (self.options.relativePoints) { + values[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + values[index] += value; + } + } + }); + return values.concat(negativeValues); + } + + self.eachValue(function(value, index) { values.push(value); }); return values; + }; var scaleOptions = { @@ -386,7 +318,7 @@ }); } - this.scale = new Chart.Scale(scaleOptions); + this.scale = new this.ScaleClass(scaleOptions); }, redraw: function() { @@ -398,7 +330,11 @@ this.scale.draw(easingDecimal); - this.eachDataset(function(dataset, datasetIndex) { + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + var datasetIndex = i; // Transition Point Locations helpers.each(dataset.metaData, function(point, index) { @@ -412,11 +348,152 @@ helpers.each(dataset.metaData, function(point) { point.draw(); }); - }, this); + } // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); - } + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hoverMode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hoverMode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + + this.lastActive[0].radius = dataset.pointRadius; + this.lastActive[0].backgroundColor = dataset.pointBackgroundColor; + this.lastActive[0].borderColor = dataset.pointBorderColor; + this.lastActive[0].borderWidth = dataset.pointBorderWidth; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + + this.lastActive[i].radius = dataset.pointRadius; + this.lastActive[i].backgroundColor = dataset.pointBackgroundColor; + this.lastActive[i].borderColor = dataset.pointBorderColor; + this.lastActive[i].borderWidth = dataset.pointBorderWidth; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hoverMode) { + switch (this.options.hoverMode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + + this.active[0].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; + this.active[0].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + + this.active[i].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; + this.active[i].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.showTooltips) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, }); From ed4b9945f8e428c46c303f5ba6b2228e7485f715 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 20 May 2015 08:33:26 -0400 Subject: [PATCH 048/424] Initial dataset scale class --- src/Chart.Scale.js | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index b7db8c1bae4..71f4a582641 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -605,4 +605,102 @@ } }); Chart.scales.registerScaleType("linear", LinearScale); + + var DatasetScale = Chart.Element.extend({ + // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset + calculateRange: helpers.noop, + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + + }, + getPixelForValue: function(value, datasetIndex) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + + } else { + + } + + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.max - ((this.options.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.offsetGridLines) { + valueOffset += (valueWidth / 2); + } + + return Math.round(valueOffset); + + }, + calculateXLabelRotation: function() { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + + this.ctx.font = this.font; + + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + var firstRotated; + var lastRotated; + + + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; + + this.xLabelRotation = 0; + if (this.display) { + var originalLabelWidth = longestText(this.ctx, this.font, this.labels), + cosRotation, + firstRotatedWidth; + this.xLabelWidth = originalLabelWidth; + //Allow 3 pixels x2 padding either side for label readability + var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; + + //Max label rotate should be 90 - also act as a loop counter + while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)) { + cosRotation = Math.cos(toRadians(this.xLabelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.fontSize / 2 > this.yLabelWidth) { + this.xScalePaddingLeft = firstRotated + this.fontSize / 2; + } + this.xScalePaddingRight = this.fontSize / 2; + + + this.xLabelRotation++; + this.xLabelWidth = cosRotation * originalLabelWidth; + + } + if (this.xLabelRotation > 0) { + this.endPoint -= Math.sin(toRadians(this.xLabelRotation)) * originalLabelWidth + 3; + } + } else { + this.xLabelWidth = 0; + this.xScalePaddingRight = this.padding; + this.xScalePaddingLeft = this.padding; + } + + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + } + }); + Chart.scales.registerScaleType("dataset", DatasetScale); }).call(this); \ No newline at end of file From b7606c7a8de2ad9fa5b8438d34f1956574c3a7b8 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 15:15:04 -0400 Subject: [PATCH 049/424] Rename onHover to events to match the line chart --- src/Chart.Scatter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index d7318ad9c0c..5ac3d120e48 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -114,7 +114,7 @@ }); // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + helpers.bindEvents(this, this.options.tooltipEvents, this.events); // Build Scale this.buildScale(); @@ -188,7 +188,7 @@ previousPoint: function(collection, index) { return collection[index + 1] || collection[index]; }, - onHover: function(e) { + events: function(e) { // If exiting chart if (e.type == 'mouseout') { return this; From c66edc91699e2e8275d36c53bb1d15a19de4cd5b Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 15:18:08 -0400 Subject: [PATCH 050/424] dataset axis to be used in the line chart and the bar chart --- src/Chart.Scale.js | 184 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 140 insertions(+), 44 deletions(-) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 71f4a582641..2809287702f 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -612,81 +612,81 @@ isHorizontal: function() { return this.options.position == "top" || this.options.position == "bottom"; }, - buildLabels: function() { - // We assume that this has been run after ticks have been generated. We try to figure out - // a label for each tick. - - }, - getPixelForValue: function(value, datasetIndex) { + getPixelForValue: function(value, index, includeOffset) { // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; - } else { + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.max)); } - - var isRotated = (this.labelRotation > 0); - var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.max - ((this.options.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; - - if (this.options.offsetGridLines) { - valueOffset += (valueWidth / 2); - } - - return Math.round(valueOffset); - }, - calculateXLabelRotation: function() { + calculateLabelRotation: function(maxHeight) { //Get the width of each grid by calculating the difference //between x offsets between 0 and 1. - - this.ctx.font = this.font; + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; var firstWidth = this.ctx.measureText(this.labels[0]).width; var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; var firstRotated; var lastRotated; - this.paddingRight = lastWidth / 2 + 3; this.paddingLeft = firstWidth / 2 + 3; - this.xLabelRotation = 0; - if (this.display) { - var originalLabelWidth = longestText(this.ctx, this.font, this.labels), - cosRotation, - firstRotatedWidth; - this.xLabelWidth = originalLabelWidth; + this.labelRotation = 0; + + if (this.options.show) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; + + this.labelWidth = originalLabelWidth; + //Allow 3 pixels x2 padding either side for label readability - var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; + // only the index matters for a dataset scale, but we want a consistent interface between scales + var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; //Max label rotate should be 90 - also act as a loop counter - while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)) { - cosRotation = Math.cos(toRadians(this.xLabelRotation)); + while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); firstRotated = cosRotation * firstWidth; lastRotated = cosRotation * lastWidth; // We're right aligning the text now. - if (firstRotated + this.fontSize / 2 > this.yLabelWidth) { - this.xScalePaddingLeft = firstRotated + this.fontSize / 2; + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; } - this.xScalePaddingRight = this.fontSize / 2; + this.paddingRight = this.options.labels.fontSize / 2; - this.xLabelRotation++; - this.xLabelWidth = cosRotation * originalLabelWidth; + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } + + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; - } - if (this.xLabelRotation > 0) { - this.endPoint -= Math.sin(toRadians(this.xLabelRotation)) * originalLabelWidth + 3; } } else { - this.xLabelWidth = 0; - this.xScalePaddingRight = this.padding; - this.xScalePaddingLeft = this.padding; + this.labelWidth = 0; + this.paddingRight = this.padding; + this.paddingLeft = this.padding; } }, @@ -695,11 +695,107 @@ // @param {number} maxHeight: the max height the axis can be // @return {object} minSize : the minimum size needed to draw the axis fit: function(maxWidth, maxHeight) { - + this.calculateRange(); + this.calculateLabelRotation(); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (this.isHorizontal()) { + minSize.width = maxWidth; + this.width = maxWidth; + + var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else { + minSize.height = maxHeight; + this.height = maxHeight; + + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; }, // Actualy draw the scale on the canvas // @param {rectangle} chartArea : the area of the chart to draw full grid lines on draw: function(chartArea) { + if (this.options.show) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + + helpers.each(this.labels, function(label, index) { + var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines + var xLabelValue= this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } + + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) { + } + + if (this.options.labels.show) { + // Draw the labels + } + } + } } }); Chart.scales.registerScaleType("dataset", DatasetScale); From a559ab85cd16a1e18e14f4aacbbc0fd6f7f75cbd Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 15:18:33 -0400 Subject: [PATCH 051/424] Ensure consistency in the helpers.toRadians name --- src/Chart.Core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 0121b11a11a..66f3d1e2997 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -402,7 +402,7 @@ return 0; } }, - toRadians = helpers.radians = function(degrees) { + toRadians = helpers.toRadians = function(degrees) { return degrees * (Math.PI / 180); }, toDegrees = helpers.toDegrees = function(radians) { From d998c803d36f8a96090dacecbf7c8e330d9b5cbe Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 15:19:30 -0400 Subject: [PATCH 052/424] Move line chart over to use new scale config. This adds support for multiple y axes. Added an example demonstrating this. --- samples/line-multi-axis.html | 142 +++++++++++++++ samples/line.html | 11 +- src/Chart.Line.js | 335 +++++++++++++++++++++-------------- 3 files changed, 356 insertions(+), 132 deletions(-) create mode 100644 samples/line-multi-axis.html diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html new file mode 100644 index 00000000000..85a518cbe94 --- /dev/null +++ b/samples/line-multi-axis.html @@ -0,0 +1,142 @@ + + + + + Line Chart + + + + + +
    +
    + +
    +
    + + + + + diff --git a/samples/line.html b/samples/line.html index 970c66c12bc..826a568668c 100644 --- a/samples/line.html +++ b/samples/line.html @@ -8,7 +8,7 @@ -
    +
    @@ -50,7 +50,14 @@ options: { responsive: true, hoverMode: 'label', - stacked: true + stacked: false, + scales: { + xAxes: [{ + gridLines: { + offsetGridLines: false + } + }] + } } }); }; diff --git a/src/Chart.Line.js b/src/Chart.Line.js index f02b63c4950..ed3eae22554 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -7,29 +7,82 @@ var defaultConfig = { - ///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 to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, - //Boolean - Whether to horizontally center the label and point dot inside the grid - offsetGridLines: false, + scales: { + xAxes: [{ + scaleType: "dataset", // scatter should not use a dataset axis + show: true, + position: "bottom", + horizontal: true, + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + show: true, + position: "left", + horizontal: false, + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, //Boolean - Whether to stack the lines essentially creating a stacked area chart. stacked: false, - //Number - Tension of the bezier curve between points tension: 0.4, - //Number - Radius of each point dot in pixels pointRadius: 3, //Number - Pixel width of point dot border @@ -51,9 +104,6 @@ //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - - - }; @@ -67,35 +117,6 @@ var _this = this; - // Build Scale - this.ScaleClass = Chart.Scale.extend({ - calculatePointY: function(index, datasetIndex) { - - var value = _this.data.datasets[datasetIndex].data[index]; - - if (_this.options.stacked) { - var offsetPos = 0; - var offsetNeg = 0; - for (var i = 0; i < datasetIndex; i++) { - if (_this.data.datasets[i].data[index] < 0) { - offsetNeg += _this.data.datasets[i].data[index]; - } else { - offsetPos += _this.data.datasets[i].data[index]; - } - } - if (value < 0) { - return this.calculateY(offsetNeg + value); - } else { - return this.calculateY(offsetPos + value); - } - } - - return this.calculateY(value); - } - }); - this.buildScale(this.data.labels); - - //Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.metaDataset = new Chart.Line(); @@ -103,8 +124,19 @@ helpers.each(dataset.data, function(dataPoint, index) { dataset.metaData.push(new Chart.Point()); }, this); + + // The line chart only supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; + + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } }, this); + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + // Set defaults for lines this.eachDataset(function(dataset, datasetIndex) { helpers.extend(dataset.metaDataset, { @@ -120,9 +152,11 @@ // Set defaults for points this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + helpers.extend(point, { - x: this.scale.calculateX(index), - y: this.scale.calculateY(0), + x: xScale.getPixelForValue(null, index, true), + y: this.chartArea.bottom, _datasetIndex: datasetIndex, _index: index, _chart: this.chart @@ -155,21 +189,24 @@ return collection[index + 1] || collection[index]; }, update: function() { - - // Update the scale - this.scale.update(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines this.eachDataset(function(dataset, datasetIndex) { + var yScale = this.scales[dataset.yAxisID]; + helpers.extend(dataset.metaDataset, { // Utility _datasetIndex: datasetIndex, + // Data _points: dataset.metaData, + // Geometry - scaleTop: this.scale.startPoint, - scaleBottom: this.scale.endPoint, - scaleZero: this.scale.calculateY(0), + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: yScale.getPixelForValue(0), + // Appearance tension: dataset.tension || this.options.tension, backgroundColor: dataset.backgroundColor || this.options.backgroundColor, @@ -181,24 +218,31 @@ // Update the points this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + helpers.extend(point, { // Utility _chart: this.chart, _datasetIndex: datasetIndex, _index: index, + // Data label: this.data.labels[index], value: this.data.datasets[datasetIndex].data[index], datasetLabel: this.data.datasets[datasetIndex].label, + // Geometry offsetGridLines: this.options.offsetGridLines, - x: this.scale.calculateX(index), - y: this.scale.calculatePointY(index, datasetIndex), + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), tension: this.data.datasets[datasetIndex].metaDataset.tension, + // Appearnce radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, + // Tooltip hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.pointHitRadius, }); @@ -217,20 +261,21 @@ point.controlPointNextX = controlPoints.next.x; // Prevent the bezier going outside of the bounds of the graph + // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.scale.endPoint) { - point.controlPointNextY = this.scale.endPoint; - } else if (controlPoints.next.y < this.scale.startPoint) { - point.controlPointNextY = this.scale.startPoint; + if (controlPoints.next.y > this.chartArea.bottom) { + point.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point.controlPointNextY = this.chartArea.top; } else { point.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.scale.endPoint) { - point.controlPointPreviousY = this.scale.endPoint; - } else if (controlPoints.previous.y < this.scale.startPoint) { - point.controlPointPreviousY = this.scale.startPoint; + if (controlPoints.previous.y > this.chartArea.bottom) { + point.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point.controlPointPreviousY = this.chartArea.top; } else { point.controlPointPreviousY = controlPoints.previous.y; } @@ -240,85 +285,112 @@ this.render(); }, - buildScale: function(labels) { + buildScale: function() { var self = this; - var dataTotal = function() { - var values = []; + // Function to determine the range of all the + var calculateYRange = function() { + this.min = null; + this.max = null; + + var positiveValues = []; var negativeValues = []; if (self.options.stacked) { - self.eachValue(function(value, index) { - values[index] = values[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - if (self.options.relativePoints) { - values[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - values[index] += value; - } + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + + if (self.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); } - }); - return values.concat(negativeValues); - } - - self.eachValue(function(value, index) { - values.push(value); - }); - - return values; + }, this); + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); + } else { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } }; - var scaleOptions = { - templateString: this.options.scaleLabel, - height: this.chart.height, - width: this.chart.width, + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); + var xScale = new ScaleClass({ ctx: this.chart.ctx, - textColor: this.options.scaleFontColor, - offsetGridLines: this.options.offsetGridLines, - fontSize: this.options.scaleFontSize, - fontStyle: this.options.scaleFontStyle, - fontFamily: this.options.scaleFontFamily, - valuesCount: labels.length, - beginAtZero: this.options.scaleBeginAtZero, - integersOnly: this.options.scaleIntegersOnly, - calculateYRange: function(currentHeight) { - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); + options: this.options.scales.xAxes[0], + calculateRange: function() { + this.labels = self.data.labels; + this.min = 0; + this.max = this.labels.length; }, - xLabels: this.data.labels, - font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth: this.options.scaleLineWidth, - lineColor: this.options.scaleLineColor, - showHorizontalLines: this.options.scaleShowHorizontalLines, - showVerticalLines: this.options.scaleShowVerticalLines, - 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.pointRadius + this.options.pointBorderWidth, - showLabels: this.options.scaleShowLabels, - display: this.options.showScale - }; + id: this.options.scales.xAxes[0].id, + }); + this.scales[xScale.id] = xScale; + + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + calculateRange: calculateYRange, + getPointPixelForValue: function(value, index, datasetIndex) { + if (self.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + + for (var i = 0; i < datasetIndex; ++i) { + if (self.data.datasets[i].data[index] < 0) { + offsetNeg += self.data.datasets[i].data[index]; + } else { + offsetPos += self.data.datasets[i].data[index]; + } + } - if (this.options.scaleOverride) { - helpers.extend(scaleOptions, { - calculateYRange: helpers.noop, - steps: this.options.scaleSteps, - stepValue: this.options.scaleStepWidth, - min: this.options.scaleStartValue, - max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth) + if (value < 0) { + return this.getPixelForValue(offsetNeg + value); + } else { + return this.getPixelForValue(offsetPos + value); + } + } else { + return this.getPixelForValue(value); + } + }, + id: yAxisOptions.id, }); - } - this.scale = new this.ScaleClass(scaleOptions); + this.scales[scale.id] = scale; + }, this); }, redraw: function() { @@ -328,7 +400,10 @@ var easingDecimal = ease || 1; this.clear(); - this.scale.draw(easingDecimal); + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); // reverse for-loop for proper stacking for (var i = this.data.datasets.length - 1; i >= 0; i--) { From 181e8661752b48f5d1a9e26eb372fdd00d172a02 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 17:50:27 -0400 Subject: [PATCH 053/424] Fix line chart multi axis sample title --- samples/line-multi-axis.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html index 85a518cbe94..d1f9e61959f 100644 --- a/samples/line-multi-axis.html +++ b/samples/line-multi-axis.html @@ -2,7 +2,7 @@ - Line Chart + Line Chart Multiple Axes From a10e245e5ad743686f691d549b2ec3257c7650cb Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 18:15:57 -0400 Subject: [PATCH 054/424] Use correct tooltip events in each chart --- src/Chart.Doughnut.js | 2 +- src/Chart.PolarArea.js | 2 +- src/Chart.Radar.js | 2 +- src/Chart.Scatter.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index c3530650159..b25f48f47b6 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -53,7 +53,7 @@ //Set up tooltip events on the chart if (this.options.showTooltips) { - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + helpers.bindEvents(this, this.options.events, this.onHover); } // Create new slice for each piece of data diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index 4bfec4f4697..eb48a9f0f19 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -103,7 +103,7 @@ //Set up tooltip events on the chart if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ + helpers.bindEvents(this, this.options.events, function(evt){ var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : []; helpers.each(this.segments,function(segment){ segment.restore(["fillColor"]); diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index ddf12388f92..636681adc4b 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -81,7 +81,7 @@ //Set up tooltip events on the chart if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ + helpers.bindEvents(this, this.options.events, function(evt){ var activePointsCollection = (evt.type !== 'mouseout') ? this.getPointsAtEvent(evt) : []; this.eachPoints(function(point){ diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 5ac3d120e48..127b4294e83 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -114,7 +114,7 @@ }); // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.events); + helpers.bindEvents(this, this.options.events, this.events); // Build Scale this.buildScale(); From b67afcd727dd1656b531154dd1f2db7cfa5d147c Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 18:26:34 -0400 Subject: [PATCH 055/424] Bar chart converted to new scale system. Added bar chart multi axis sample. --- samples/bar-multi-axis.html | 134 ++++++++++ samples/bar.html | 2 +- src/Chart.Bar.js | 485 +++++++++++++++++++++--------------- 3 files changed, 419 insertions(+), 202 deletions(-) create mode 100644 samples/bar-multi-axis.html diff --git a/samples/bar-multi-axis.html b/samples/bar-multi-axis.html new file mode 100644 index 00000000000..4a7ccb84892 --- /dev/null +++ b/samples/bar-multi-axis.html @@ -0,0 +1,134 @@ + + + + + Bar Chart Multi Axis + + + + + +
    + +
    + + + + + diff --git a/samples/bar.html b/samples/bar.html index b0f82cf1bf9..d9a5dc4d166 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -8,7 +8,7 @@ -
    +
    diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index e181be4fc8f..a7d3f0e98f7 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -7,23 +7,75 @@ var defaultConfig = { - //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, + scales: { + xAxes: [{ + scaleType: "dataset", // scatter should not use a dataset axis + show: true, + position: "bottom", + horizontal: true, + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: true, + }, - //Boolean - Whether to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + show: true, + position: "left", + horizontal: false, + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, //Number - Pixel width of the bar border barBorderWidth: 2, @@ -47,139 +99,43 @@ name: "Bar", defaults: defaultConfig, initialize: function() { - var options = this.options; - - var _this = this; - - // Custom Scale Methods and Options - this.ScaleClass = Chart.Scale.extend({ - offsetGridLines: true, - calculateBarBase: function(datasetIndex, index) { - - var base = 0; - - if (_this.options.stacked) { - var bar = _this.data.datasets[datasetIndex].metaData[index]; - if (bar.value < 0) { - for (var i = 0; i < datasetIndex; i++) { - base += _this.data.datasets[i].metaData[index].value < base ? _this.data.datasets[i].metaData[index].value : 0; - } - } else { - for (var i = 0; i < datasetIndex; i++) { - base += _this.data.datasets[i].metaData[index].value > base ? _this.data.datasets[i].metaData[index].value : 0; - } - } - return this.calculateY(base); - } - - base = this.endPoint; - - if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { - base = this.calculateY(0); - base += _this.options.scaleGridLineWidth; - } else if (this.min < 0 && this.max < 0) { - // All values are negative. Use the top as the base - base = this.startPoint; - } - - return base; - - }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.calculateX(elementIndex) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); - - if (_this.options.stacked) { - return xAbsolute + barWidth / 2; - } - - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth / 2; - }, - calculateBarY: function(datasets, datasetIndex, barIndex, value) { - - if (_this.options.stacked) { - - var sumPos = 0, - sumNeg = 0; - - for (var i = 0; i < datasetIndex; i++) { - if (datasets[i].metaData[barIndex].value < 0) { - sumNeg += datasets[i].metaData[barIndex].value || 0; - } else { - sumPos += datasets[i].metaData[barIndex].value || 0; - } - } - - if (value < 0) { - return this.calculateY(sumNeg + value); - } else { - return this.calculateY(sumPos + value); - } - - /*if (options.relativeBars) { - offset = offset / sum * 100; - }*/ - - return this.calculateY(0); - } - - var offset = 0; - - for (i = datasetIndex; i < datasets.length; i++) { - if (i === datasetIndex && value) { - offset += value; - } else { - offset = offset + (datasets[i].metaData[barIndex].value); - } - } - - return this.calculateY(value); - }, - calculateBaseWidth: function() { - return (this.calculateX(1) - this.calculateX(0)) - (2 * options.barValueSpacing); - }, - calculateBaseHeight: function() { - return (this.calculateY(1) - this.calculateY(0)); - }, - calculateBarWidth: function(datasetCount) { - - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); - - if (_this.options.stacked) { - return baseWidth; - } - return (baseWidth / datasetCount); - }, - }); - // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + helpers.bindEvents(this, this.options.events, this.onHover); //Declare the extension of the default point, to cater for the options passed in to the constructor this.BarClass = Chart.Rectangle.extend({ ctx: this.chart.ctx, }); - // Build Scale - this.buildScale(this.data.labels); - //Create a new bar for each piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.metaData = []; helpers.each(dataset.data, function(dataPoint, index) { dataset.metaData.push(new this.BarClass()); }, this); + + // The bar chart only supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; + + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } }, this); + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + // Set defaults for bars this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + helpers.extend(bar, { - base: this.scale.zeroPoint, - width: this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), + base: yScale.getPixelForValue(0), + width: xScale.calculateBarWidth(this.data.datasets.length), + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), _datasetIndex: datasetIndex, _index: index, }); @@ -317,22 +273,26 @@ return this; }, update: function() { - - this.scale.update(); + // Update the scale sizes + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); this.eachElement(function(bar, index, dataset, datasetIndex) { helpers.extend(bar, { value: this.data.datasets[datasetIndex].data[index], }); + bar.pivot(); }, this); this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + helpers.extend(bar, { - base: this.scale.calculateBarBase(datasetIndex, index), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), - width: this.scale.calculateBarWidth(this.data.datasets.length), + base: yScale.calculateBarBase(datasetIndex, index), + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), + width: xScale.calculateBarWidth(this.data.datasets.length), label: this.data.labels[index], datasetLabel: this.data.datasets[datasetIndex].label, borderColor: this.data.datasets[datasetIndex].borderColor, @@ -341,94 +301,214 @@ _datasetIndex: datasetIndex, _index: index, }); + bar.pivot(); }, this); this.render(); }, buildScale: function(labels) { - var self = this; + var self = this; - var dataTotal = function() { - var values = []; + // Function to determine the range of all the + var calculateYRange = function() { + this.min = null; + this.max = null; + + var positiveValues = []; var negativeValues = []; if (self.options.stacked) { - self.eachValue(function(value, index) { - values[index] = values[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - if (self.options.relativeBars) { - values[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - values[index] += value; - } + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + + if (self.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); } - }); - return values.concat(negativeValues); + }, this); + + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); + } else { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); } + }; - self.eachValue(function(value, index) { - values.push(value); - }); + // Map of scale ID to scale object so we can lookup later + this.scales = {}; - return values; + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); + var xScale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scales.xAxes[0], + id: this.options.scales.xAxes[0].id, + calculateRange: function() { + this.labels = self.data.labels; + this.min = 0; + this.max = this.labels.length; + }, + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.barValueSpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.barDatasetSpacing); - }; + if (self.options.stacked) { + return baseWidth; + } + return (baseWidth / datasetCount); + }, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); - var scaleOptions = { - 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: labels.length, - beginAtZero: this.options.scaleBeginAtZero, - integersOnly: this.options.scaleIntegersOnly, - calculateYRange: function(currentHeight) { - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); + if (self.options.stacked) { + return xAbsolute + barWidth / 2; + } + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.barDatasetSpacing) + barWidth / 2; }, - xLabels: labels, - font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth: this.options.scaleLineWidth, - lineColor: this.options.scaleLineColor, - showHorizontalLines: this.options.scaleShowHorizontalLines, - showVerticalLines: this.options.scaleShowVerticalLines, - 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.borderWidth, - showLabels: this.options.scaleShowLabels, - display: this.options.showScale - }; + }); + this.scales[xScale.id] = xScale; + + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + calculateRange: calculateYRange, + calculateBarBase: function(datasetIndex, index) { + var base = 0; + + if (self.options.stacked) { + var bar = self.data.datasets[datasetIndex].metaData[index]; + + if (bar.value < 0) { + for (var i = 0; i < datasetIndex; i++) { + if (self.data.datasets[i].yAxisID === this.id) { + base += self.data.datasets[i].metaData[index].value < base ? self.data.datasets[i].metaData[index].value : 0; + } + } + } else { + for (var i = 0; i < datasetIndex; i++) { + if (self.data.datasets[i].yAxisID === this.id) { + base += self.data.datasets[i].metaData[index].value > base ? self.data.datasets[i].metaData[index].value : 0; + } + } + } + + return this.getPixelForValue(base); + } + + base = this.getPixelForValue(this.min); + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.getPixelForValue(0); + base += this.options.gridLines.lineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.getPixelForValue(this.max); + } - if (this.options.scaleOverride) { - helpers.extend(scaleOptions, { - calculateYRange: helpers.noop, - steps: this.options.scaleSteps, - stepValue: this.options.scaleStepWidth, - min: this.options.scaleStartValue, - max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth) + return base; + + }, + calculateBarY: function(datasets, datasetIndex, barIndex, value) { + + if (self.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (datasets[i].metaData[barIndex].value < 0) { + sumNeg += datasets[i].metaData[barIndex].value || 0; + } else { + sumPos += datasets[i].metaData[barIndex].value || 0; + } + } + + if (value < 0) { + return this.getPixelForValue(sumNeg + value); + } else { + return this.getPixelForValue(sumPos + value); + } + + /*if (options.relativeBars) { + offset = offset / sum * 100; + }*/ + + return this.getPixelForValue(0); + } + + var offset = 0; + + for (i = datasetIndex; i < datasets.length; i++) { + if (i === datasetIndex && value) { + offset += value; + } else { + offset = offset + (datasets[i].metaData[barIndex].value); + } + } + + return this.getPixelForValue(value); + }, + + calculateBaseHeight: function() { + return (this.getPixelForValue(1) - this.getPixelForValue(0)); + }, + id: yAxisOptions.id, }); - } - this.scale = new this.ScaleClass(scaleOptions); + this.scales[scale.id] = scale; + }, this); }, // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function redraw: function() { - var base = this.scale.zeroPoint; this.eachElement(function(element, index, datasetIndex) { + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + var base = yScale.getPixelForValue(yScale.min); + + if (yScale.min <= 0 && yScale.max >= 0) { + // have a 0 point + base = yScale.getPixelForValue(0); + } else if (yScale.min < 0 && yScale.max < 0) { + // all megative + base = yScale.getPixelForValue(yScale.max); + } + helpers.extend(element, { y: base, base: base @@ -441,7 +521,10 @@ var easingDecimal = ease || 1; this.clear(); - this.scale.draw(easingDecimal); + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); //Draw all the bars for each dataset this.eachElement(function(bar, index, datasetIndex) { From 73b579c9626b0f5f5d2ea4d24c36901a8d785cef Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 21:21:40 -0400 Subject: [PATCH 056/424] Remove old linear scale --- src/Chart.Core.js | 273 ---------------------------------------------- 1 file changed, 273 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 66f3d1e2997..2b6e8a01930 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1782,279 +1782,6 @@ }, }); - Chart.Scale = Chart.Element.extend({ - initialize: function() { - this.fit(); - }, - buildYLabels: function() { - this.yLabels = []; - - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); - - 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) + 10 : 0; - }, - addXLabel: function(label) { - this.xLabels.push(label); - this.valuesCount++; - this.fit(); - }, - removeXLabel: function() { - this.xLabels.shift(); - this.valuesCount--; - this.fit(); - }, - // Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use - fit: function() { - // First we need the width of the yLabels, assuming the xLabels aren't rotated - - // To do that we need the base line at the top and base of the chart, assuming there is no x label rotation - this.startPoint = (this.display) ? this.fontSize : 0; - this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels - - // Apply padding settings to the start and end point. - this.startPoint += this.padding; - this.endPoint -= this.padding; - - // Cache the starting endpoint, excluding the space for x labels - var cachedEndPoint = this.endPoint; - - // Cache the starting height, so can determine if we need to recalculate the scale yAxis - var cachedHeight = this.endPoint - this.startPoint, - cachedYLabelWidth; - - // Build the current yLabels so we have an idea of what size they'll be to start - /* - * This sets what is returned from calculateScaleRange as static properties of this class: - * - this.steps; - this.stepValue; - this.min; - this.max; - * - */ - this.calculateYRange(cachedHeight); - - // With these properties set we can now build the array of yLabels - // and also the width of the largest yLabel - this.buildYLabels(); - - this.calculateXLabelRotation(); - - while ((cachedHeight > this.endPoint - this.startPoint)) { - cachedHeight = this.endPoint - this.startPoint; - cachedYLabelWidth = this.yLabelWidth; - - this.calculateYRange(cachedHeight); - this.buildYLabels(); - - // Only go through the xLabel loop again if the yLabel width has changed - if (cachedYLabelWidth < this.yLabelWidth) { - this.endPoint = cachedEndPoint; - this.calculateXLabelRotation(); - } - } - - }, - calculateXLabelRotation: function() { - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - - this.ctx.font = this.font; - - var firstWidth = this.ctx.measureText(this.xLabels[0]).width, - lastWidth = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width, - firstRotated, - lastRotated; - - - this.xScalePaddingRight = lastWidth / 2 + 3; - this.xScalePaddingLeft = (firstWidth / 2 > this.yLabelWidth) ? firstWidth / 2 : this.yLabelWidth; - - this.xLabelRotation = 0; - if (this.display) { - var originalLabelWidth = longestText(this.ctx, this.font, this.xLabels), - cosRotation, - firstRotatedWidth; - this.xLabelWidth = originalLabelWidth; - //Allow 3 pixels x2 padding either side for label readability - var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; - - //Max label rotate should be 90 - also act as a loop counter - while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)) { - cosRotation = Math.cos(toRadians(this.xLabelRotation)); - - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; - - // We're right aligning the text now. - if (firstRotated + this.fontSize / 2 > this.yLabelWidth) { - this.xScalePaddingLeft = firstRotated + this.fontSize / 2; - } - this.xScalePaddingRight = this.fontSize / 2; - - - this.xLabelRotation++; - this.xLabelWidth = cosRotation * originalLabelWidth; - - } - if (this.xLabelRotation > 0) { - this.endPoint -= Math.sin(toRadians(this.xLabelRotation)) * originalLabelWidth + 3; - } - } else { - this.xLabelWidth = 0; - this.xScalePaddingRight = this.padding; - this.xScalePaddingLeft = this.padding; - } - - }, - // Needs to be overidden in each Chart type - // Otherwise we need to pass all the data into the scale class - calculateYRange: noop, - drawingArea: function() { - return this.startPoint - this.endPoint; - }, - calculateY: function(value) { - var scalingFactor = this.drawingArea() / (this.min - this.max); - return this.endPoint - (scalingFactor * (value - this.min)); - }, - calculateX: function(index) { - var isRotated = (this.xLabelRotation > 0), - // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding, - innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight), - valueWidth = innerWidth / Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1), - valueOffset = (valueWidth * index) + this.xScalePaddingLeft; - - if (this.offsetGridLines) { - valueOffset += (valueWidth / 2); - } - - return Math.round(valueOffset); - }, - update: function(newProps) { - helpers.extend(this, newProps); - this.fit(); - }, - draw: function() { - var ctx = this.ctx, - yLabelGap = (this.endPoint - this.startPoint) / this.steps, - xStart = Math.round(this.xScalePaddingLeft); - if (this.display) { - ctx.fillStyle = this.textColor; - ctx.font = this.font; - each(this.yLabels, function(labelString, index) { - var yLabelCenter = this.endPoint - (yLabelGap * index), - linePositionY = Math.round(yLabelCenter), - drawHorizontalLine = this.showHorizontalLines; - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - if (this.showLabels) { - ctx.fillText(labelString, xStart - 10, yLabelCenter); - } - - // This is X axis, so draw it - if (index === 0 && !drawHorizontalLine) { - drawHorizontalLine = true; - } - - if (drawHorizontalLine) { - ctx.beginPath(); - } - - if (index > 0) { - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } - - linePositionY += helpers.aliasPixel(ctx.lineWidth); - - if (drawHorizontalLine) { - ctx.moveTo(xStart, linePositionY); - ctx.lineTo(this.width, linePositionY); - ctx.stroke(); - ctx.closePath(); - } - - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - ctx.beginPath(); - ctx.moveTo(xStart - 5, linePositionY); - ctx.lineTo(xStart, linePositionY); - ctx.stroke(); - ctx.closePath(); - - }, this); - - each(this.xLabels, function(label, index) { - var xPos = this.calculateX(index) + aliasPixel(this.lineWidth), - // Check to see if line/bar here and decide where to place the line - linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth), - isRotated = (this.xLabelRotation > 0), - drawVerticalLine = this.showVerticalLines; - - // This is Y axis, so draw it - if (index === 0 && !drawVerticalLine) { - drawVerticalLine = true; - } - - if (drawVerticalLine) { - ctx.beginPath(); - } - - if (index > 0) { - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } - - if (drawVerticalLine) { - ctx.moveTo(linePos, this.endPoint); - ctx.lineTo(linePos, this.startPoint - 3); - ctx.stroke(); - ctx.closePath(); - } - - - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - - - // Small lines at the bottom of the base grid line - ctx.beginPath(); - ctx.moveTo(linePos, this.endPoint); - ctx.lineTo(linePos, this.endPoint + 5); - ctx.stroke(); - ctx.closePath(); - - ctx.save(); - ctx.translate(xPos, (isRotated) ? this.endPoint + 12 : this.endPoint + 8); - ctx.rotate(toRadians(this.xLabelRotation) * -1); - ctx.font = this.font; - ctx.textAlign = (isRotated) ? "right" : "center"; - ctx.textBaseline = (isRotated) ? "middle" : "top"; - ctx.fillText(label, 0, 0); - ctx.restore(); - }, this); - - } - } - - }); - Chart.RadialScale = Chart.Element.extend({ initialize: function() { this.size = min([this.height, this.width]); From d4e7765a50ce96ca2dd58ad3657ed310aac9d032 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 21:44:50 -0400 Subject: [PATCH 057/424] Clean up some unused config options. Renamed 'show' to 'display' for scales since that was clearer and maintains backwards compatibility. --- samples/bar-multi-axis.html | 2 -- samples/line-multi-axis.html | 2 -- samples/scatter-multi-axis.html | 2 -- src/Chart.Bar.js | 4 +--- src/Chart.Line.js | 4 +--- src/Chart.Scale.js | 6 +++--- src/Chart.Scatter.js | 4 +--- 7 files changed, 6 insertions(+), 18 deletions(-) diff --git a/samples/bar-multi-axis.html b/samples/bar-multi-axis.html index 4a7ccb84892..7a54ae0d7cb 100644 --- a/samples/bar-multi-axis.html +++ b/samples/bar-multi-axis.html @@ -54,7 +54,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "left", - horizontal: false, id: "y-axis-1", // grid line settings @@ -86,7 +85,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "right", - horizontal: false, id: "y-axis-2", // grid line settings diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html index d1f9e61959f..143bc9abc21 100644 --- a/samples/line-multi-axis.html +++ b/samples/line-multi-axis.html @@ -63,7 +63,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "left", - horizontal: false, id: "y-axis-1", // grid line settings @@ -95,7 +94,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "right", - horizontal: false, id: "y-axis-2", // grid line settings diff --git a/samples/scatter-multi-axis.html b/samples/scatter-multi-axis.html index a7ca3f96e96..33f00512559 100644 --- a/samples/scatter-multi-axis.html +++ b/samples/scatter-multi-axis.html @@ -106,7 +106,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "left", - horizontal: false, id: "y-axis-1", // grid line settings @@ -138,7 +137,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "right", - horizontal: false, id: "y-axis-2", // grid line settings diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index a7d3f0e98f7..4d737ddb4b2 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -10,9 +10,8 @@ scales: { xAxes: [{ scaleType: "dataset", // scatter should not use a dataset axis - show: true, + display: true, position: "bottom", - horizontal: true, id: "x-axis-1", // need an ID so datasets can reference the scale // grid line settings @@ -46,7 +45,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "left", - horizontal: false, id: "y-axis-1", // grid line settings diff --git a/src/Chart.Line.js b/src/Chart.Line.js index ed3eae22554..3663843671a 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -10,9 +10,8 @@ scales: { xAxes: [{ scaleType: "dataset", // scatter should not use a dataset axis - show: true, + display: true, position: "bottom", - horizontal: true, id: "x-axis-1", // need an ID so datasets can reference the scale // grid line settings @@ -46,7 +45,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "left", - horizontal: false, id: "y-axis-1", // grid line settings diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 2809287702f..7d6436c757b 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -460,7 +460,7 @@ // Actualy draw the scale on the canvas // @param {rectangle} chartArea : the area of the chart to draw full grid lines on draw: function(chartArea) { - if (this.options.show) { + if (this.options.display) { var setContextLineSettings; var hasZero; @@ -646,7 +646,7 @@ this.labelRotation = 0; - if (this.options.show) { + if (this.options.display) { var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); var cosRotation; var sinRotation; @@ -726,7 +726,7 @@ // Actualy draw the scale on the canvas // @param {rectangle} chartArea : the area of the chart to draw full grid lines on draw: function(chartArea) { - if (this.options.show) { + if (this.options.display) { var setContextLineSettings; diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 127b4294e83..0211c74fc4c 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -10,9 +10,8 @@ scales: { xAxes: [{ scaleType: "linear", // scatter should not use a dataset axis - show: true, + display: true, position: "bottom", - horizontal: true, id: "x-axis-1", // need an ID so datasets can reference the scale // grid line settings @@ -45,7 +44,6 @@ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance show: true, position: "left", - horizontal: false, id: "y-axis-1", // grid line settings From 1352dfeb0fbecde79e9ef0fc17f14026c90b878c Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 23 May 2015 21:49:01 -0400 Subject: [PATCH 058/424] Fix the y scales that were missed in the previous check in --- samples/bar-multi-axis.html | 4 ++-- samples/line-multi-axis.html | 4 ++-- samples/scatter-multi-axis.html | 4 ++-- src/Chart.Bar.js | 2 +- src/Chart.Line.js | 2 +- src/Chart.Scatter.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/samples/bar-multi-axis.html b/samples/bar-multi-axis.html index 7a54ae0d7cb..6ae6eca4590 100644 --- a/samples/bar-multi-axis.html +++ b/samples/bar-multi-axis.html @@ -52,7 +52,7 @@ scales: { yAxes: [{ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "left", id: "y-axis-1", @@ -83,7 +83,7 @@ } }, { scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "right", id: "y-axis-2", diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html index 143bc9abc21..bb4b58a7791 100644 --- a/samples/line-multi-axis.html +++ b/samples/line-multi-axis.html @@ -61,7 +61,7 @@ }], yAxes: [{ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "left", id: "y-axis-1", @@ -92,7 +92,7 @@ } }, { scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "right", id: "y-axis-2", diff --git a/samples/scatter-multi-axis.html b/samples/scatter-multi-axis.html index 33f00512559..7a85feb4795 100644 --- a/samples/scatter-multi-axis.html +++ b/samples/scatter-multi-axis.html @@ -104,7 +104,7 @@ }], yAxes: [{ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "left", id: "y-axis-1", @@ -135,7 +135,7 @@ } }, { scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "right", id: "y-axis-2", diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 4d737ddb4b2..6cc891b4ac3 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -43,7 +43,7 @@ }], yAxes: [{ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "left", id: "y-axis-1", diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 3663843671a..ecc87e97f30 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -43,7 +43,7 @@ }], yAxes: [{ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "left", id: "y-axis-1", diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 0211c74fc4c..240160b7ae7 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -42,7 +42,7 @@ }], yAxes: [{ scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - show: true, + display: true, position: "left", id: "y-axis-1", From a2d477ac5ef8e1ffc6c41a8cbcfe158fa591c646 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 24 May 2015 14:33:12 -0400 Subject: [PATCH 059/424] Moved radial scale into Chat.Scale.js. Registered as "radialLinear" which will allow radialLogarithmic, etc in the future. Updated the polar area and radar charts to use the new scale config. The scales draw, but the points do not. This is no different than the current v2.0 branch --- src/Chart.Core.js | 265 +----------------------------- src/Chart.PolarArea.js | 161 ++++++++++--------- src/Chart.Radar.js | 220 +++++++++++++------------ src/Chart.Scale.js | 357 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 562 insertions(+), 441 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 2b6e8a01930..a5588028b5c 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1407,7 +1407,7 @@ }, draw: function() { - var ctx = this._chart.ctx; + var ctx = this.ctx; var vm = this._vm; ctx.beginPath(); @@ -1782,269 +1782,6 @@ }, }); - Chart.RadialScale = Chart.Element.extend({ - initialize: function() { - this.size = min([this.height, this.width]); - this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); - }, - calculateCenterOffset: function(value) { - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); - - return (value - this.min) * scalingFactor; - }, - update: function() { - if (!this.lineArc) { - this.setScaleSize(); - } else { - this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); - } - this.buildYLabels(); - }, - buildYLabels: function() { - this.yLabels = []; - - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); - - for (var i = 0; i <= this.steps; i++) { - this.yLabels.push(template(this.templateString, { - value: (this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces) - })); - } - }, - getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); - }, - setScaleSize: function() { - /* - * Right, this is really confusing and there is a lot of maths going on here - * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 - * - * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif - * - * Solution: - * - * We assume the radius of the polygon is half the size of the canvas at first - * at each index we check if the text overlaps. - * - * Where it does, we store that angle and that index. - * - * After finding the largest index and angle we calculate how much we need to remove - * from the shape radius to move the point inwards by that x. - * - * We average the left and right distances to get the maximum shape radius that can fit in the box - * along with labels. - * - * Once we have that, we can find the centre point for the chart, by taking the x text protrusion - * on each side, removing that from the size, halving it and adding the left x protrusion width. - * - * This will mean we have a shape fitted to the canvas, as large as it can be with the labels - * and position it in the most space efficient manner - * - * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - */ - - - // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points - var largestPossibleRadius = min([(this.height / 2 - this.pointLabelFontSize - 5), this.width / 2]), - pointPosition, - i, - textWidth, - halfTextWidth, - furthestRight = this.width, - furthestRightIndex, - furthestRightAngle, - furthestLeft = 0, - furthestLeftIndex, - furthestLeftAngle, - xProtrusionLeft, - xProtrusionRight, - radiusReductionRight, - radiusReductionLeft, - maxWidthRadius; - this.ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); - for (i = 0; i < this.valuesCount; i++) { - // 5px to space the text slightly out - similar to what we do in the draw function. - pointPosition = this.getPointPosition(i, largestPossibleRadius); - textWidth = this.ctx.measureText(template(this.templateString, { - value: this.labels[i] - })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { - // If we're at index zero, or exactly the middle, we're at exactly the top/bottom - // of the radar chart, so text will be aligned centrally, so we'll half it and compare - // w/left and right text sizes - halfTextWidth = textWidth / 2; - if (pointPosition.x + halfTextWidth > furthestRight) { - furthestRight = pointPosition.x + halfTextWidth; - furthestRightIndex = i; - } - if (pointPosition.x - halfTextWidth < furthestLeft) { - furthestLeft = pointPosition.x - halfTextWidth; - furthestLeftIndex = i; - } - } else if (i < this.valuesCount / 2) { - // Less than half the values means we'll left align the text - if (pointPosition.x + textWidth > furthestRight) { - furthestRight = pointPosition.x + textWidth; - furthestRightIndex = i; - } - } else if (i > this.valuesCount / 2) { - // More than half the values means we'll right align the text - if (pointPosition.x - textWidth < furthestLeft) { - furthestLeft = pointPosition.x - textWidth; - furthestLeftIndex = i; - } - } - } - - xProtrusionLeft = furthestLeft; - - xProtrusionRight = Math.ceil(furthestRight - this.width); - - furthestRightAngle = this.getIndexAngle(furthestRightIndex); - - furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); - - radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); - - radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); - - // Ensure we actually need to reduce the size of the chart - radiusReductionRight = (isNumber(radiusReductionRight)) ? radiusReductionRight : 0; - radiusReductionLeft = (isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; - - this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; - - //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) - this.setCenterPoint(radiusReductionLeft, radiusReductionRight); - - }, - setCenterPoint: function(leftMovement, rightMovement) { - - var maxRight = this.width - rightMovement - this.drawingArea, - maxLeft = leftMovement + this.drawingArea; - - this.xCenter = (maxLeft + maxRight) / 2; - // Always vertically in the centre as the text height doesn't change - this.yCenter = (this.height / 2); - }, - - getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; - // Start from the top instead of right, so remove a quarter of the circle - - return index * angleMultiplier - (Math.PI / 2); - }, - getPointPosition: function(index, distanceFromCenter) { - var thisAngle = this.getIndexAngle(index); - return { - x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, - y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter - }; - }, - draw: function() { - if (this.display) { - var ctx = this.ctx; - each(this.yLabels, function(label, index) { - // Don't draw a centre value - if (index > 0) { - var yCenterOffset = index * (this.drawingArea / this.steps), - yHeight = this.yCenter - yCenterOffset, - pointPosition; - - // Draw circular lines around the scale - if (this.lineWidth > 0) { - ctx.strokeStyle = this.lineColor; - ctx.lineWidth = this.lineWidth; - - if (this.lineArc) { - ctx.beginPath(); - ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); - ctx.closePath(); - ctx.stroke(); - } else { - ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { - pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.min + (index * this.stepValue))); - if (i === 0) { - ctx.moveTo(pointPosition.x, pointPosition.y); - } else { - ctx.lineTo(pointPosition.x, pointPosition.y); - } - } - ctx.closePath(); - ctx.stroke(); - } - } - if (this.showLabels) { - ctx.font = fontString(this.fontSize, this._fontStyle, this._fontFamily); - if (this.showLabelBackdrop) { - var labelWidth = ctx.measureText(label).width; - ctx.fillStyle = this.backdropColor; - ctx.fillRect( - this.xCenter - labelWidth / 2 - this.backdropPaddingX, - yHeight - this.fontSize / 2 - this.backdropPaddingY, - labelWidth + this.backdropPaddingX * 2, - this.fontSize + this.backdropPaddingY * 2 - ); - } - ctx.textAlign = 'center'; - ctx.textBaseline = "middle"; - ctx.fillStyle = this.fontColor; - ctx.fillText(label, this.xCenter, yHeight); - } - } - }, this); - - if (!this.lineArc) { - ctx.lineWidth = this.angleLineWidth; - ctx.strokeStyle = this.angleLineColor; - for (var i = this.valuesCount - 1; i >= 0; i--) { - if (this.angleLineWidth > 0) { - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); - ctx.beginPath(); - ctx.moveTo(this.xCenter, this.yCenter); - ctx.lineTo(outerPosition.x, outerPosition.y); - ctx.stroke(); - ctx.closePath(); - } - // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); - ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); - ctx.fillStyle = this.pointLabelFontColor; - - var labelsCount = this.labels.length, - halfLabelsCount = this.labels.length / 2, - quarterLabelsCount = halfLabelsCount / 2, - upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), - exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); - if (i === 0) { - ctx.textAlign = 'center'; - } else if (i === halfLabelsCount) { - ctx.textAlign = 'center'; - } else if (i < halfLabelsCount) { - ctx.textAlign = 'left'; - } else { - ctx.textAlign = 'right'; - } - - // Set the correct text baseline based on outer positioning - if (exactQuarter) { - ctx.textBaseline = 'middle'; - } else if (upperHalf) { - ctx.textBaseline = 'bottom'; - } else { - ctx.textBaseline = 'top'; - } - - ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); - } - } - } - } - }); - Chart.animationService = { frameDuration: 17, animations: [], diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index eb48a9f0f19..49fe2424e16 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -7,24 +7,6 @@ helpers = Chart.helpers; var defaultConfig = { - //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, @@ -34,6 +16,48 @@ //Number - The width of the stroke value in pixels segmentStrokeWidth : 2, + scale: { + scaleType: "radialLinear", + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate : false, + + lineArc: true, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop : true, + + //String - The colour of the label backdrop + backdropColor : "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY : 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX : 2, + } + }, + //Number - Amount of animation steps animationSteps : 100, @@ -43,9 +67,6 @@ //Boolean - Whether to animate the rotation of the chart animateRotate : true, - //Boolean - Whether to animate scaling the chart from the centre - animateScale : false, - //String - A legend template legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " }; @@ -70,32 +91,42 @@ x : this.chart.width/2, y : this.chart.height/2 }); - this.scale = new Chart.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, + + var self = this; + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleClass({ + options: this.options.scale, lineArc: true, 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: this.data.length + valuesCount: this.data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data, function(data) { + if (this.min === null) { + this.min = data.value; + } else if (data.value < this.min) { + this.min = data.value; + } + + if (this.max === null) { + this.max = data.value; + } else if (data.value > this.max) { + this.max = data.value; + } + }, this); + } }); - this.updateScaleRange(this.data); - - this.scale.update(); + this.updateScaleRange(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); helpers.each(this.data,function(segment,index){ this.addData(segment,index,true); @@ -108,9 +139,11 @@ helpers.each(this.segments,function(segment){ segment.restore(["fillColor"]); }); + helpers.each(activeSegments,function(activeSegment){ activeSegment.fillColor = activeSegment.highlightColor; }); + this.showTooltip(activeSegments); }); } @@ -119,12 +152,12 @@ }, getSegmentsAtEvent : function(e){ var segmentsArray = []; - var location = helpers.getRelativePosition(e); helpers.each(this.segments,function(segment){ if (segment.inRange(location.x,location.y)) segmentsArray.push(segment); },this); + return segmentsArray; }, addData : function(segment, atIndex, silent){ @@ -157,37 +190,13 @@ },this); this.scale.valuesCount = this.segments.length; }, - updateScaleRange: function(datapoints){ - var valuesArray = []; - helpers.each(datapoints,function(segment){ - valuesArray.push(segment.value); + updateScaleRange: function(){ + helpers.extend(this.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width/2, + yCenter: this.chart.height/2 }); - var scaleSizes = (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) - } : - helpers.calculateScaleRange( - valuesArray, - helpers.min([this.chart.width, this.chart.height])/2, - this.options.scaleFontSize, - this.options.scaleBeginAtZero, - this.options.scaleIntegersOnly - ); - - helpers.extend( - this.scale, - scaleSizes, - { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width/2, - yCenter: this.chart.height/2 - } - ); - }, update : function(){ @@ -220,8 +229,11 @@ x : this.chart.width/2, y : this.chart.height/2 }); - this.updateScaleRange(this.segments); - this.scale.update(); + + this.updateScaleRange(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); helpers.extend(this.scale,{ xCenter: this.chart.width/2, @@ -229,8 +241,11 @@ }); helpers.each(this.segments, function(segment){ - segment.update({ - outerRadius : this.scale.calculateCenterOffset(segment.value) + //segment.update({ + // outerRadius : this.scale.calculateCenterOffset(segment.value) + //}); + helpers.extend(segment, { + outerRadius: this.scale.calculateCenterOffset(segment.value) }); }, this); diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index 636681adc4b..51795b695f1 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -10,47 +10,88 @@ Chart.Type.extend({ name: "Radar", defaults:{ - //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", + scale: { + scaleType: "radialLinear", + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate : false, + + lineArc: false, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, + + angleLines: { + show: true, + color: "rgba(0,0,0,.1)", + lineWidth: 1 + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop : true, + + //String - The colour of the label backdrop + backdropColor : "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY : 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX : 2, + }, + + pointLabels: { + //String - Point label font declaration + fontFamily : "'Arial'", + + //String - Point label font weight + fontStyle : "normal", + + //Number - Point label font size in pixels + fontSize : 10, + + //String - Point label font colour + fontColor : "#666", + }, + }, //Boolean - Whether to show a dot for each point pointDot : true, //Number - Radius of each point dot in pixels - pointDotRadius : 3, + pointRadius: 3, + + //Number - Pixel width of point dot border + pointBorderWidth: 1, + + //Number - Pixel width of point on hover + pointHoverRadius: 5, - //Number - Pixel width of point dot stroke - pointDotStrokeWidth : 1, + //Number - Pixel width of point dot border on hover + pointHoverBorderWidth: 2, + pointBackgroundColor: Chart.defaults.global.defaultColor, + pointBorderColor: Chart.defaults.global.defaultColor, - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHitDetectionRadius : 20, + //Number - amount extra to add to the radius to cater for hit detection outside the drawn point + pointHitRadius: 20, //Boolean - Whether to show a stroke for datasets datasetStroke : true, @@ -68,11 +109,8 @@ initialize: function(){ this.PointClass = Chart.Point.extend({ - strokeWidth : this.options.pointDotStrokeWidth, - radius : this.options.pointDotRadius, display: this.options.pointDot, - hitDetectionRadius : this.options.pointHitDetectionRadius, - ctx : this.chart.ctx + _chart: this.chart }); this.datasets = []; @@ -125,7 +163,15 @@ strokeColor : dataset.pointStrokeColor, fillColor : dataset.pointColor, highlightFill : dataset.pointHighlightFill || dataset.pointColor, - highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor + highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor, + + // Appearance + radius: dataset.pointRadius || this.options.pointRadius, + backgroundColor: dataset.pointBackgroundColor || this.options.pointBackgroundColor, + borderWidth: dataset.pointBorderWidth || this.options.pointBorderWidth, + + // Tooltip + hoverRadius: dataset.pointHitRadius || this.options.pointHitRadius, })); },this); @@ -165,78 +211,47 @@ }, buildScale : function(data){ - this.scale = new Chart.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, - // Point labels at the edge of each line - pointLabelFontColor : this.options.pointLabelFontColor, - pointLabelFontSize : this.options.pointLabelFontSize, - pointLabelFontFamily : this.options.pointLabelFontFamily, - pointLabelFontStyle : this.options.pointLabelFontStyle, + var self = this; + + var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleConstructor({ + options: this.options.scale, 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: data.labels, - valuesCount: data.datasets[0].data.length + valuesCount: data.datasets[0].data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } }); this.scale.setScaleSize(); - this.updateScaleRange(data.datasets); + this.scale.calculateRange(); + this.scale.generateTicks(); this.scale.buildYLabels(); }, - updateScaleRange: function(datasets){ - var valuesArray = (function(){ - var totalDataArray = []; - helpers.each(datasets,function(dataset){ - if (dataset.data){ - totalDataArray = totalDataArray.concat(dataset.data); - } - else { - helpers.each(dataset.points, function(point){ - totalDataArray.push(point.value); - }); - } - }); - return totalDataArray; - })(); - - - var scaleSizes = (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) - } : - helpers.calculateScaleRange( - valuesArray, - helpers.min([this.chart.width, this.chart.height])/2, - this.options.scaleFontSize, - this.options.scaleBeginAtZero, - this.options.scaleIntegersOnly - ); - - helpers.extend( - this.scale, - scaleSizes - ); - - }, addData : function(valuesArray,label){ //Map the values array for each of the datasets this.scale.valuesCount++; @@ -308,8 +323,9 @@ xCenter: this.chart.width/2, yCenter: this.chart.height/2 }); - this.updateScaleRange(this.datasets); - this.scale.setScaleSize(); + + this.scale.calculateRange(); + this.scale.generateTicks(); this.scale.buildYLabels(); }, draw : function(ease){ @@ -323,7 +339,7 @@ //Transition each point first so that the line and point drawing isn't out of sync helpers.each(dataset.points,function(point,index){ if (point.hasValue()){ - point.transition(this.scale.getPointPosition(index, this.scale.calculateCenterOffset(point.value)), easeDecimal); + point.transition(easeDecimal); } },this); diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 7d6436c757b..b0313e4c057 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -358,9 +358,9 @@ helpers.each(this.ticks, function(tick, index, ticks) { var label; - if (this.options.labelCallback) { + if (this.options.labels.userCallback) { // If the user provided a callback for label generation, use that as first priority - label = this.options.labelCallback(tick, index, ticks); + label = this.options.lables.userCallback(tick, index, ticks); } else if (this.options.labels.template) { // else fall back to the template string label = helpers.template(this.options.labels.template, { @@ -799,4 +799,357 @@ } }); Chart.scales.registerScaleType("dataset", DatasetScale); + + var LinearRadialScale = Chart.Element.extend({ + initialize: function() { + this.size = helpers.min([this.height, this.width]); + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); + }, + calculateCenterOffset: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + return (value - this.min) * scalingFactor; + }, + update: function() { + if (!this.options.lineArc) { + this.setScaleSize(); + } else { + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + } + + this.buildYLabels(); + }, + calculateRange: helpers.noop, // overridden in chart + generateTicks: function() { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } + else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildYLabels: function() { + this.yLabels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.yLabels.push(label ? label : ""); + }, this); + }, + getCircumference: function() { + return ((Math.PI * 2) / this.valuesCount); + }, + setScaleSize: function() { + /* + * Right, this is really confusing and there is a lot of maths going on here + * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 + * + * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif + * + * Solution: + * + * We assume the radius of the polygon is half the size of the canvas at first + * at each index we check if the text overlaps. + * + * Where it does, we store that angle and that index. + * + * After finding the largest index and angle we calculate how much we need to remove + * from the shape radius to move the point inwards by that x. + * + * We average the left and right distances to get the maximum shape radius that can fit in the box + * along with labels. + * + * Once we have that, we can find the centre point for the chart, by taking the x text protrusion + * on each side, removing that from the size, halving it and adding the left x protrusion width. + * + * This will mean we have a shape fitted to the canvas, as large as it can be with the labels + * and position it in the most space efficient manner + * + * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif + */ + + + // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. + // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points + var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), + pointPosition, + i, + textWidth, + halfTextWidth, + furthestRight = this.width, + furthestRightIndex, + furthestRightAngle, + furthestLeft = 0, + furthestLeftIndex, + furthestLeftAngle, + xProtrusionLeft, + xProtrusionRight, + radiusReductionRight, + radiusReductionLeft, + maxWidthRadius; + this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + for (i = 0; i < this.valuesCount; i++) { + // 5px to space the text slightly out - similar to what we do in the draw function. + pointPosition = this.getPointPosition(i, largestPossibleRadius); + textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { + value: this.labels[i] + })).width + 5; + if (i === 0 || i === this.valuesCount / 2) { + // If we're at index zero, or exactly the middle, we're at exactly the top/bottom + // of the radar chart, so text will be aligned centrally, so we'll half it and compare + // w/left and right text sizes + halfTextWidth = textWidth / 2; + if (pointPosition.x + halfTextWidth > furthestRight) { + furthestRight = pointPosition.x + halfTextWidth; + furthestRightIndex = i; + } + if (pointPosition.x - halfTextWidth < furthestLeft) { + furthestLeft = pointPosition.x - halfTextWidth; + furthestLeftIndex = i; + } + } else if (i < this.valuesCount / 2) { + // Less than half the values means we'll left align the text + if (pointPosition.x + textWidth > furthestRight) { + furthestRight = pointPosition.x + textWidth; + furthestRightIndex = i; + } + } else if (i > this.valuesCount / 2) { + // More than half the values means we'll right align the text + if (pointPosition.x - textWidth < furthestLeft) { + furthestLeft = pointPosition.x - textWidth; + furthestLeftIndex = i; + } + } + } + + xProtrusionLeft = furthestLeft; + + xProtrusionRight = Math.ceil(furthestRight - this.width); + + furthestRightAngle = this.getIndexAngle(furthestRightIndex); + + furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); + + radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); + + radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + + // Ensure we actually need to reduce the size of the chart + radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; + radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; + + this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; + + //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) + this.setCenterPoint(radiusReductionLeft, radiusReductionRight); + + }, + setCenterPoint: function(leftMovement, rightMovement) { + + var maxRight = this.width - rightMovement - this.drawingArea, + maxLeft = leftMovement + this.drawingArea; + + this.xCenter = (maxLeft + maxRight) / 2; + // Always vertically in the centre as the text height doesn't change + this.yCenter = (this.height / 2); + }, + + getIndexAngle: function(index) { + var angleMultiplier = (Math.PI * 2) / this.valuesCount; + // Start from the top instead of right, so remove a quarter of the circle + + return index * angleMultiplier - (Math.PI / 2); + }, + getPointPosition: function(index, distanceFromCenter) { + var thisAngle = this.getIndexAngle(index); + return { + x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, + y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter + }; + }, + draw: function() { + if (this.options.display) { + var ctx = this.ctx; + helpers.each(this.yLabels, function(label, index) { + // Don't draw a centre value + if (index > 0) { + var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), + yHeight = this.yCenter - yCenterOffset, + pointPosition; + + // Draw circular lines around the scale + if (this.options.gridLines.show) { + ctx.strokeStyle = this.options.gridLines.color; + ctx.lineWidth = this.options.gridLines.lineWidth; + + if (this.options.lineArc) { + ctx.beginPath(); + ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); + ctx.closePath(); + ctx.stroke(); + } else { + ctx.beginPath(); + for (var i = 0; i < this.valuesCount; i++) { + pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); + if (i === 0) { + ctx.moveTo(pointPosition.x, pointPosition.y); + } else { + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + } + } + + if (this.options.labels.show) { + ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.showLabelBackdrop) { + var labelWidth = ctx.measureText(label).width; + ctx.fillStyle = this.options.labels.backdropColor; + ctx.fillRect( + this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, + yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, + labelWidth + this.options.labels.backdropPaddingX * 2, + this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 + ); + } + + ctx.textAlign = 'center'; + ctx.textBaseline = "middle"; + ctx.fillStyle = this.options.labels.fontColor; + ctx.fillText(label, this.xCenter, yHeight); + } + } + }, this); + + if (!this.options.lineArc) { + ctx.lineWidth = this.options.angleLines.lineWidth; + ctx.strokeStyle = this.options.angleLines.color; + + for (var i = this.valuesCount - 1; i >= 0; i--) { + if (this.options.angleLines.show) { + var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); + ctx.beginPath(); + ctx.moveTo(this.xCenter, this.yCenter); + ctx.lineTo(outerPosition.x, outerPosition.y); + ctx.stroke(); + ctx.closePath(); + } + // Extra 3px out for some label spacing + var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); + ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + ctx.fillStyle = this.options.pointLabels.fontColor; + + var labelsCount = this.labels.length, + halfLabelsCount = this.labels.length / 2, + quarterLabelsCount = halfLabelsCount / 2, + upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), + exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); + if (i === 0) { + ctx.textAlign = 'center'; + } else if (i === halfLabelsCount) { + ctx.textAlign = 'center'; + } else if (i < halfLabelsCount) { + ctx.textAlign = 'left'; + } else { + ctx.textAlign = 'right'; + } + + // Set the correct text baseline based on outer positioning + if (exactQuarter) { + ctx.textBaseline = 'middle'; + } else if (upperHalf) { + ctx.textBaseline = 'bottom'; + } else { + ctx.textBaseline = 'top'; + } + + ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + } + } + } + } + }); + Chart.scales.registerScaleType("radialLinear", LinearRadialScale); }).call(this); \ No newline at end of file From b03a057a7692b8e02904c36f5c5418dcd422de1f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 26 May 2015 16:52:16 -0600 Subject: [PATCH 060/424] Nested globals --- src/Chart.Core.js | 259 ++++++++++++++++++++-------------------------- 1 file changed, 112 insertions(+), 147 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index a5588028b5c..1be01b57a94 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -51,58 +51,21 @@ //Globally expose the defaults to allow for user updating/changing Chart.defaults = { global: { - // Boolean - Whether to animate the chart - animation: true, - // Number - Number of animation steps - animationDuration: 1000, + // Animation defaults + animation: { + // Number - Number of animation steps + duration: 1000, - // String - Animation easing effect - animationEasing: "easeOutQuart", + // String - Animation easing effect + easing: "easeOutQuart", - // Boolean - If we should show the scale at all - showScale: true, + // Function - Will fire on animation progression. + onProgress: function() {}, - // 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, and not show any 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", + // Function - Will fire on animation completion. + onComplete: function() {}, + }, // Boolean - whether or not the chart should be responsive and resize when the browser does. responsive: false, @@ -110,83 +73,86 @@ // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container maintainAspectRatio: true, - //String / Boolean - Hover mode for events. - hoverMode: 'single', // 'label', 'dataset', 'false' + // Array - Array of string names to attach interaction events + events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], - //Function(event) - Custom hover handler - onHover: null, + // Hover defaults + hover: { - //Function(event, clickedElements) - Custom click handler - onClick: null, + // String || boolean + mode: 'single', // 'label', 'dataset', 'false' - //Function - Custom hover handler - hoverAnimationDuration: 400, + //Function(event, activeElements) - Custom hover handler + onHover: null, - // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove - showTooltips: true, + //Function - Custom hover handler + animationDuration: 400, + }, - // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function - customTooltips: false, + //Function(event, clickedElements) - Custom click handler + onClick: null, - // Array - Array of string names to attach interaction events - events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], + // Tooltip Defaults + tooltips: { + + // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove + enabled: true, - // String - Tooltip background colour - tooltipBackgroundColor: "rgba(0,0,0,0.8)", + // Function - Determines whether to draw built-in tooltip or call custom tooltip function + custom: null, - // String - Tooltip label font declaration for the scale label - tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + // String - Tooltip background colour + backgroundColor: "rgba(0,0,0,0.8)", - // Number - Tooltip label font size in pixels - tooltipFontSize: 14, + // String - Tooltip label font declaration for the scale label + fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - // String - Tooltip font weight style - tooltipFontStyle: "normal", + // Number - Tooltip label font size in pixels + fontSize: 14, - // String - Tooltip label font colour - tooltipFontColor: "#fff", + // String - Tooltip font weight style + fontStyle: "normal", - // String - Tooltip title font declaration for the scale label - tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + // String - Tooltip label font colour + fontColor: "#fff", - // Number - Tooltip title font size in pixels - tooltipTitleFontSize: 14, + // String - Tooltip title font declaration for the scale label + titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - // String - Tooltip title font weight style - tooltipTitleFontStyle: "bold", + // Number - Tooltip title font size in pixels + titleFontSize: 14, - // String - Tooltip title font colour - tooltipTitleFontColor: "#fff", + // String - Tooltip title font weight style + titleFontStyle: "bold", - // Number - pixel width of padding around tooltip text - tooltipYPadding: 6, + // String - Tooltip title font colour + titleFontColor: "#fff", - // Number - pixel width of padding around tooltip text - tooltipXPadding: 6, + // Number - pixel width of padding around text + yPadding: 6, - // Number - Size of the caret on the tooltip - tooltipCaretSize: 8, + // Number - pixel width of padding around text + xPadding: 6, - // Number - Pixel radius of the tooltip border - tooltipCornerRadius: 6, + // Number - Size of the caret on the + caretSize: 8, - // Number - Pixel offset from point x to tooltip edge - tooltipXOffset: 10, + // Number - Pixel radius of the border + cornerRadius: 6, - // String - Template string for single tooltips - tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", + // Number - Pixel offset from point x to edge + xOffset: 10, - // String - Template string for single tooltips - multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", + // String - Template string for singles + template: "<%if (label){%><%=label%>: <%}%><%= value %>", - // String - Colour behind the legend colour block - multiTooltipKeyBackground: '#fff', + // String - Template string for singles + multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", - // Function - Will fire on animation progression. - onAnimationProgress: function() {}, + // String - Colour behind the legend colour block + multiKeyBackground: '#fff', - // Function - Will fire on animation completion. - onAnimationComplete: function() {}, + }, // Color String - Used for undefined Colros defaultColor: 'rgba(0,0,0,0.1)', @@ -259,8 +225,7 @@ baseArray.push(valueObj); // nothing to merge } }); - } - else if (base.hasOwnProperty(key) && typeof base[key] == "object" && typeof value == "object") { + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && typeof value == "object") { // If we are overwriting an object with an object, do a merge of the properties. base[key] = helpers.configMerge(base[key], value); } else { @@ -270,7 +235,7 @@ } }); }); - + return base; }, indexOf = helpers.indexOf = function(arrayToSearch, item) { @@ -361,17 +326,17 @@ min = helpers.min = function(array) { return Math.min.apply(Math, array); }, - sign = helpers.sign = function(x) { - if (Math.sign) { - return Math.sign(x); - } else { - x = +x; // convert to a number - if (x === 0 || isNaN(x)) { - return x; - } - return x > 0 ? 1 : -1; - } - }, + sign = helpers.sign = function(x) { + if (Math.sign) { + return Math.sign(x); + } else { + x = +x; // convert to a number + if (x === 0 || isNaN(x)) { + return x; + } + return x > 0 ? 1 : -1; + } + }, cap = helpers.cap = function(valueToCap, maxValue, minValue) { if (isNumber(maxValue)) { if (valueToCap > maxValue) { @@ -405,9 +370,9 @@ toRadians = helpers.toRadians = function(degrees) { return degrees * (Math.PI / 180); }, - toDegrees = helpers.toDegrees = function(radians) { - return radians * (180 / Math.PI); - }, + toDegrees = helpers.toDegrees = function(radians) { + return radians * (180 / Math.PI); + }, // Gets the angle from vertical upright to the point about a centre. getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { var distanceFromXCenter = anglePoint.x - centrePoint.x, @@ -527,36 +492,36 @@ }; }, - // Implementation of the nice number algorithm used in determining where axis labels will go - niceNum = helpers.niceNum = function(range, round) { - var exponent = Math.floor(Math.log10(range)); - var fraction = range / Math.pow(10, exponent); - var niceFraction; - - if (round) { - if (fraction < 1.5) { - niceFraction = 1; - } else if (fraction < 3) { - niceFraction = 2; - } else if (fraction < 7) { - niceFraction = 5; - } else { - niceFraction = 10; - } - } else { - if (fraction <= 1.0) { - niceFraction = 1; - } else if (fraction <= 2) { - niceFraction = 2; - } else if (fraction <= 5) { - niceFraction = 5; - } else { - niceFraction = 10; - } - } - - return niceFraction * Math.pow(10, exponent); - }, + // Implementation of the nice number algorithm used in determining where axis labels will go + niceNum = helpers.niceNum = function(range, round) { + var exponent = Math.floor(Math.log10(range)); + var fraction = range / Math.pow(10, exponent); + var niceFraction; + + if (round) { + if (fraction < 1.5) { + niceFraction = 1; + } else if (fraction < 3) { + niceFraction = 2; + } else if (fraction < 7) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } else { + if (fraction <= 1.0) { + niceFraction = 1; + } else if (fraction <= 2) { + niceFraction = 2; + } else if (fraction <= 5) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } + + return niceFraction * Math.pow(10, exponent); + }, /* jshint ignore:start */ // Blows up jshint errors based on the new Function constructor //Templating methods From e774a893da4f7be405af2926ae74499f2ab0d813 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 26 May 2015 18:54:36 -0400 Subject: [PATCH 061/424] Use new animation options in the animation service. --- src/Chart.Core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 1be01b57a94..7fc57ac9324 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -999,10 +999,10 @@ redraw: noop, render: function(duration) { - if (this.options.animation) { + if (this.options.animation.duration !== 0) { var animation = new Chart.Animation(); - animation.numSteps = (duration || this.options.animationDuration) / 16.66; //60 fps - animation.easing = this.options.animationEasing; + animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps + animation.easing = this.options.animation.easing; // render function animation.render = function(chartInstance, animationObject) { From 54b51038ca835bbd6765a68db34aada90a5e1fc2 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 26 May 2015 19:11:05 -0400 Subject: [PATCH 062/424] Updated bar chart to use new nested config for bars. Removed unused relativeBars option. barBorderWidth was not used, but seems useful so we will keep it until later refactoring. --- src/Chart.Bar.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 6cc891b4ac3..5415287232a 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -75,17 +75,16 @@ }], }, - //Number - Pixel width of the bar border - barBorderWidth: 2, + bars: { + //Number - Pixel width of the bar border + borderWidth: 2, - //Number - Spacing between each of the X value sets - barValueSpacing: 5, + //Number - Spacing between each of the X value sets + valueSpacing: 5, - //Number - Spacing between data sets within X values - barDatasetSpacing: 1, - - //Boolean - Whether bars should be rendered on a percentage base - relativeBars: false, + //Number - Spacing between data sets within X values + datasetSpacing: 1, + } //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " @@ -375,11 +374,11 @@ this.max = this.labels.length; }, calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.barValueSpacing); + return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.bars.valueSpacing); }, calculateBarWidth: function(datasetCount) { //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.barDatasetSpacing); + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.bars.datasetSpacing); if (self.options.stacked) { return baseWidth; @@ -395,7 +394,7 @@ return xAbsolute + barWidth / 2; } - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.barDatasetSpacing) + barWidth / 2; + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.bars.datasetSpacing) + barWidth / 2; }, }); this.scales[xScale.id] = xScale; @@ -464,10 +463,6 @@ return this.getPixelForValue(sumPos + value); } - /*if (options.relativeBars) { - offset = offset / sum * 100; - }*/ - return this.getPixelForValue(0); } From 7d8b1712a7b149f5bc42f3f53afa9da1ade2b414 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 26 May 2015 19:30:34 -0400 Subject: [PATCH 063/424] Convert bar chart to use nested config. Noticed that the segmentShowStroke option wasn't used at all. --- src/Chart.Doughnut.js | 53 +++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index b25f48f47b6..fdc4f12e950 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -7,30 +7,33 @@ helpers = Chart.helpers; var defaultConfig = { - //Boolean - Whether we should show a stroke on each segment - segmentShowStroke: true, + segments: { + //Boolean - Whether we should show a stroke on each segment + showStroke: true, - //String - The colour of each segment stroke - segmentStrokeColor: "#fff", + //String - The colour of each segment stroke + strokeColor: "#fff", - //Number - The width of each segment stroke - borderWidth: 2, - - //The percentage of the chart that we cut out of the middle. - cutoutPercentage: 50, - - // The duration of animations triggered by hover events - hoverAnimationDuration: 400, + //Number - The width of each segment stroke + borderWidth: 2, + }, - //String - Animation easing effect - animationEasing: "easeOutQuart", + hover: { + // The duration of animations triggered by hover events + animationDuration: 400, + }, - //Boolean - Whether we animate the rotation of the Doughnut - animateRotate: true, + animation: { + //Boolean - Whether we animate the rotation of the Doughnut + animateRotate: true, - //Boolean - Whether we animate scaling the Doughnut from the centre - animateScale: false, + //Boolean - Whether we animate scaling the Doughnut from the centre + animateScale: false, + }, + //The percentage of the chart that we cut out of the middle. + cutoutPercentage: 50, + //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " @@ -69,9 +72,9 @@ } helpers.extend(metaSlice, { startAngle: Math.PI * 1.5, - circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animateScale) ? 0 : this.outerRadius, - innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, + circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animation.animateScale) ? 0 : this.outerRadius, + innerRadius: (this.options.animation.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, }); if (!metaSlice.backgroundColor) { slice.backgroundColor = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; @@ -157,7 +160,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hoverAnimationDuration); + this.render(this.options.hover.animationDuration); } } @@ -191,7 +194,7 @@ this.total += Math.abs(slice.value); }, this); - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.borderWidth / 2) / 2; + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segments.borderWidth / 2) / 2; // Map new data to data points helpers.each(this.data.metaData, function(slice, index) { @@ -210,8 +213,8 @@ backgroundColor: datapoint.backgroundColor, hoverBackgroundColor: datapoint.hoverBackgroundColor || datapoint.backgroundColor, - borderWidth: this.options.borderWidth, - borderColor: this.options.segmentStrokeColor, + borderWidth: this.options.segments.borderWidth, + borderColor: this.options.segments.strokeColor, }); helpers.extend(slice, { From e3519f5bd4e7b5e356d7e085d28ab9cb9daf83d5 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 26 May 2015 21:16:18 -0400 Subject: [PATCH 064/424] More nested config stuff. Not sure what all of the options in the line config do, but left them in. Ensured that tooltips work. --- src/Chart.Bar.js | 12 ++++---- src/Chart.Core.js | 42 ++++++++++++++-------------- src/Chart.Doughnut.js | 6 ++-- src/Chart.Line.js | 63 +++++++++++++++++++++++++----------------- src/Chart.PolarArea.js | 2 +- src/Chart.Scatter.js | 21 ++++++++------ 6 files changed, 81 insertions(+), 65 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 5415287232a..39482b640f2 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -84,7 +84,7 @@ //Number - Spacing between data sets within X values datasetSpacing: 1, - } + }, //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " @@ -162,7 +162,7 @@ // Find Active Elements this.active = function() { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': return this.getElementAtEvent(e); case 'label': @@ -181,7 +181,7 @@ // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; @@ -200,8 +200,8 @@ } // Built in hover styling - if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { case 'single': this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.8).darken(0.2).rgbString(); this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.8).darken(0.2).rgbString(); @@ -221,7 +221,7 @@ // Built in Tooltips - if (this.options.showTooltips) { + if (this.options.tooltips.enabled) { // The usual updates this.tooltip.initialize(); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 7fc57ac9324..0d103e47756 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -80,7 +80,7 @@ hover: { // String || boolean - mode: 'single', // 'label', 'dataset', 'false' + mode: 'label', // 'label', 'dataset', 'false' //Function(event, activeElements) - Custom hover handler onHover: null, @@ -1480,21 +1480,21 @@ var options = this._options; extend(this, { opacity: 0, - xPadding: options.tooltipXPadding, - yPadding: options.tooltipYPadding, - xOffset: options.tooltipXOffset, - backgroundColor: options.tooltipBackgroundColor, - textColor: options.tooltipFontColor, - _fontFamily: options.tooltipFontFamily, - _fontStyle: options.tooltipFontStyle, - fontSize: options.tooltipFontSize, - titleTextColor: options.tooltipTitleFontColor, - _titleFontFamily: options.tooltipTitleFontFamily, - _titleFontStyle: options.tooltipTitleFontStyle, - titleFontSize: options.tooltipTitleFontSize, - caretHeight: options.tooltipCaretSize, - cornerRadius: options.tooltipCornerRadius, - legendColorBackground: options.multiTooltipKeyBackground, + xPadding: options.tooltips.xPadding, + yPadding: options.tooltips.yPadding, + xOffset: options.tooltips.xOffset, + backgroundColor: options.tooltips.backgroundColor, + textColor: options.tooltips.fontColor, + _fontFamily: options.tooltips.fontFamily, + _fontStyle: options.tooltips.fontStyle, + fontSize: options.tooltips.fontSize, + titleTextColor: options.tooltips.titleFontColor, + _titleFontFamily: options.tooltips.titleFontFamily, + _titleFontStyle: options.tooltips.titleFontStyle, + titleFontSize: options.tooltips.titleFontSize, + caretHeight: options.tooltips.caretSize, + cornerRadius: options.tooltips.cornerRadius, + legendColorBackground: options.tooltips.multiKeyBackground, labels: [], colors: [], }); @@ -1503,10 +1503,10 @@ var ctx = this._chart.ctx; - switch (this._options.hoverMode) { + switch (this._options.hover.mode) { case 'single': helpers.extend(this, { - text: template(this._options.tooltipTemplate, this._active[0]), + text: template(this._options.tooltips.template, this._active[0]), }); var tooltipPosition = this._active[0].tooltipPosition(); helpers.extend(this, { @@ -1556,7 +1556,7 @@ yPositions.push(element._vm.y); //Include any colour information about the element - labels.push(helpers.template(this._options.multiTooltipTemplate, element)); + labels.push(helpers.template(this._options.tooltips.multiTemplate, element)); colors.push({ fill: element._vm.backgroundColor, stroke: element._vm.borderColor @@ -1583,7 +1583,7 @@ labels: labels, title: this._active.length ? this._active[0].label : '', legendColors: colors, - legendBackgroundColor: this._options.multiTooltipKeyBackground, + legendBackgroundColor: this._options.tooltips.multiKeyBackground, }); @@ -1624,7 +1624,7 @@ var ctx = this._chart.ctx; var vm = this._vm; - switch (this._options.hoverMode) { + switch (this._options.hover.mode) { case 'single': ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index fdc4f12e950..bb9faf0363d 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -55,7 +55,7 @@ }); //Set up tooltip events on the chart - if (this.options.showTooltips) { + if (this.options.tooltips.enabled) { helpers.bindEvents(this, this.options.events, this.onHover); } @@ -115,12 +115,12 @@ } // Built in hover styling - if (this.active.length && this.options.hoverMode) { + if (this.active.length && this.options.hover.mode) { this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.data.data[this.active[0]._index].backgroundColor).saturate(0.5).darken(0.35).rgbString(); } // Built in Tooltips - if (this.options.showTooltips) { + if (this.options.tooltips.enabled) { // The usual updates this.tooltip.initialize(); diff --git a/src/Chart.Line.js b/src/Chart.Line.js index ecc87e97f30..e1b44abcb56 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -78,22 +78,33 @@ //Boolean - Whether to stack the lines essentially creating a stacked area chart. stacked: false, - //Number - Tension of the bezier curve between points - tension: 0.4, - - //Number - Radius of each point dot in pixels - pointRadius: 3, - //Number - Pixel width of point dot border - pointBorderWidth: 1, - //Number - Pixel width of point on hover - pointHoverRadius: 5, - //Number - Pixel width of point dot border on hover - pointHoverBorderWidth: 2, - pointBackgroundColor: Chart.defaults.global.defaultColor, - pointBorderColor: Chart.defaults.global.defaultColor, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHitRadius: 6, + points: { + // Number - Radius of each point dot in pixels + radius: 3, + + // Number - Pixel width of point dot border + borderWidth: 1, + + // Number - Pixel width of point on hover + hoverRadius: 5, + + // Number - Pixel width of point dot border on hover + hoverBorderWidth: 2, + + // Color + backgroundColor: Chart.defaults.global.defaultColor, + + // Color + borderColor: Chart.defaults.global.defaultColor, + + //Number - amount extra to add to the radius to cater for hit detection outside the drawn point + hitRadius: 6, + }, + + lines: { + //Number - Tension of the bezier curve between points. Use 0 to turn off bezier tension + tension: 0.4, + }, //Number - Pixel width of dataset border borderWidth: 2, @@ -206,7 +217,7 @@ scaleZero: yScale.getPixelForValue(0), // Appearance - tension: dataset.tension || this.options.tension, + tension: dataset.tension || this.options.lines.tension, backgroundColor: dataset.backgroundColor || this.options.backgroundColor, borderWidth: dataset.borderWidth || this.options.borderWidth, borderColor: dataset.borderColor || this.options.borderColor, @@ -237,12 +248,12 @@ tension: this.data.datasets[datasetIndex].metaDataset.tension, // Appearnce - radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, - backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, + radius: this.data.datasets[datasetIndex].pointRadius || this.options.points.radius, + backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.points.backgroundColor, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointsborderWidth, // Tooltip - hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.pointHitRadius, + hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.points.hitRadius, }); }, this); @@ -437,7 +448,7 @@ // Find Active Elements this.active = function() { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': return this.getElementAtEvent(e); case 'label': @@ -463,7 +474,7 @@ var dataset; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; @@ -490,8 +501,8 @@ } // Built in hover styling - if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.active[0]._datasetIndex]; @@ -519,7 +530,7 @@ // Built in Tooltips - if (this.options.showTooltips) { + if (this.options.tooltips.enabled) { // The usual updates this.tooltip.initialize(); diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index 49fe2424e16..bdb83b90d2b 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -133,7 +133,7 @@ },this); //Set up tooltip events on the chart - if (this.options.showTooltips){ + if (this.options.tooltips.enabled){ helpers.bindEvents(this, this.options.events, function(evt){ var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : []; helpers.each(this.segments,function(segment){ diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 240160b7ae7..348e3defba4 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -6,7 +6,10 @@ helpers = Chart.helpers; var defaultConfig = { - hoverMode: 'single', + hover: { + mode: 'single', + }, + scales: { xAxes: [{ scaleType: "linear", // scatter should not use a dataset axis @@ -92,8 +95,10 @@ //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - tooltipTemplate: "(<%= dataX %>, <%= dataY %>)", - multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= dataX %>, <%= dataY %>)", + tooltips: { + template: "(<%= dataX %>, <%= dataY %>)", + multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= dataX %>, <%= dataY %>)", + }, }; @@ -196,7 +201,7 @@ // Find Active Elements this.active = function() { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': return this.getElementAtEvent(e); case 'label': @@ -215,7 +220,7 @@ // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; @@ -236,8 +241,8 @@ } // Built in hover styling - if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { case 'single': this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); @@ -258,7 +263,7 @@ } // Built in Tooltips - if (this.options.showTooltips) { + if (this.options.tooltips.enabled) { // The usual updates this.tooltip.initialize(); From 3a32144d899f2b047cd341e5130450cea367fdfe Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 26 May 2015 22:02:41 -0600 Subject: [PATCH 065/424] Polar Area deep data --- samples/polar-area.html | 125 ++++++------ src/Chart.Core.js | 2 +- src/Chart.Doughnut.js | 2 +- src/Chart.PolarArea.js | 412 +++++++++++++++++----------------------- 4 files changed, 233 insertions(+), 308 deletions(-) diff --git a/samples/polar-area.html b/samples/polar-area.html index 51682e65b9d..c52dad57771 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -1,76 +1,67 @@ - - Polar Area Chart - - - - -
    - -
    - + + Polar Area Chart + + + - + - window.onload = function(){ - var ctx = document.getElementById("chart-area").getContext("2d"); - window.myPolarArea = new Chart(ctx).PolarArea({ - data: polarData, - options: { - responsive:true - } - }); - }; - - $('#randomizeData').click(function(){ - $.each(polarData, function(i, piece){ - polarData[i].value = randomScalingFactor(); - polarData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; - }); - window.myPolarArea.update(); - }); - - - - - diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 7fc57ac9324..9d02389e6ab 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1372,7 +1372,7 @@ }, draw: function() { - var ctx = this.ctx; + var ctx = this._chart.ctx; var vm = this._vm; ctx.beginPath(); diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index b25f48f47b6..820217a3d5d 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -74,7 +74,7 @@ innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, }); if (!metaSlice.backgroundColor) { - slice.backgroundColor = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; + slice.backgroundColor = 'hsl(' + (360 * index / this.data.data.length) + ', 100%, 50%)'; } metaSlice.save(); this.data.metaData.push(metaSlice); diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index 49fe2424e16..ae8e45d6811 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -1,30 +1,30 @@ -(function(){ - "use strict"; +(function() { + "use strict"; - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; - var defaultConfig = { - //Boolean - Stroke a line around each segment in the chart - segmentShowStroke : true, + var defaultConfig = { - //String - The colour of the stroke on each segment. - segmentStrokeColor : "#fff", + segment: { + //String - The colour of the border on each segment. + borderColor: "#fff", - //Number - The width of the stroke value in pixels - segmentStrokeWidth : 2, + //Number - The width of the border value in pixels + borderWidth: 2, + }, - scale: { - scaleType: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate : false, + scale: { + scaleType: "radialLinear", + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate: false, + + lineArc: true, - lineArc: true, - // grid line settings gridLines: { show: true, @@ -44,238 +44,172 @@ fontColor: "#666", fontFamily: "Helvetica Neue", - //Boolean - Show a backdrop to the scale label - showLabelBackdrop : true, + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, - //String - The colour of the label backdrop - backdropColor : "rgba(255,255,255,0.75)", + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY : 2, + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX : 2, + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 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, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " - }; - - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "PolarArea", - //Providing a defaults will also register the deafults in the chart namespace - defaults : defaultConfig, - //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(){ - this.segments = []; - //Declare segment class as a chart instance specific class, so it can share props for this instance - this.SegmentArc = Chart.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 - }); - - var self = this; - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.scaleType); - this.scale = new ScaleClass({ - options: this.options.scale, - lineArc: true, - width: this.chart.width, - height: this.chart.height, - xCenter: this.chart.width/2, - yCenter: this.chart.height/2, - ctx : this.chart.ctx, - valuesCount: this.data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data, function(data) { + }, + + //Boolean - Whether to animate the rotation of the chart + animateRotate: true, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " + }; + + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "PolarArea", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { + + // Scale setup + var self = this; + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleClass({ + options: this.options.scale, + lineArc: true, + width: this.chart.width, + height: this.chart.height, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + valuesCount: this.data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data.data, function(data) { if (this.min === null) { this.min = data.value; } else if (data.value < this.min) { this.min = data.value; } - + if (this.max === null) { this.max = data.value; } else if (data.value > this.max) { this.max = data.value; } }, this); - } - }); - - this.updateScaleRange(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - - helpers.each(this.data,function(segment,index){ - this.addData(segment,index,true); - },this); - - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.events, function(evt){ - var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : []; - helpers.each(this.segments,function(segment){ - segment.restore(["fillColor"]); - }); - - helpers.each(activeSegments,function(activeSegment){ - activeSegment.fillColor = activeSegment.highlightColor; - }); - - this.showTooltip(activeSegments); - }); - } - - this.render(); - }, - getSegmentsAtEvent : function(e){ - var segmentsArray = []; - var location = helpers.getRelativePosition(e); - - helpers.each(this.segments,function(segment){ - if (segment.inRange(location.x,location.y)) segmentsArray.push(segment); - },this); - - return segmentsArray; - }, - addData : function(segment, atIndex, silent){ - var index = atIndex || this.segments.length; - - this.segments.splice(index, 0, new this.SegmentArc({ - fillColor: segment.color, - highlightColor: segment.highlight || segment.color, - label: segment.label, - value: segment.value, - outerRadius: (this.options.animateScale) ? 0 : this.scale.calculateCenterOffset(segment.value), - circumference: (this.options.animateRotate) ? 0 : this.scale.getCircumference(), - startAngle: Math.PI * 1.5 - })); - if (!silent){ - this.reflow(); - this.update(); - } - }, - removeData: function(atIndex){ - var indexToDelete = (helpers.isNumber(atIndex)) ? atIndex : this.segments.length-1; - this.segments.splice(indexToDelete, 1); - this.reflow(); - this.update(); - }, - calculateTotal: function(data){ - this.total = 0; - helpers.each(data,function(segment){ - this.total += segment.value; - },this); - this.scale.valuesCount = this.segments.length; - }, - updateScaleRange: function(){ - helpers.extend(this.scale, { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width/2, - yCenter: this.chart.height/2 - }); - - }, - update : function(){ - - // Map new data to data points - if(this.data.length == this.segments.length){ - helpers.each(this.data, function(segment, i){ - helpers.extend(this.segments[i], { - fillColor: segment.color, - highlightColor: segment.highlight || segment.color, - label: segment.label, - value: segment.value, - }); - },this); - } else{ - // Data size changed without properly inserting, just redraw the chart - this.initialize(this.data); - } - - this.calculateTotal(this.segments); - - helpers.each(this.segments,function(segment){ - segment.save(); - }); - - this.reflow(); - this.render(); - }, - reflow : function(){ - helpers.extend(this.SegmentArc.prototype,{ - x : this.chart.width/2, - y : this.chart.height/2 - }); - - this.updateScaleRange(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - - helpers.extend(this.scale,{ - xCenter: this.chart.width/2, - yCenter: this.chart.height/2 - }); - - helpers.each(this.segments, function(segment){ - //segment.update({ - // outerRadius : this.scale.calculateCenterOffset(segment.value) - //}); - helpers.extend(segment, { - outerRadius: this.scale.calculateCenterOffset(segment.value) - }); - }, this); - - }, - draw : function(ease){ - var easingDecimal = ease || 1; - //Clear & draw the canvas - this.clear(); - helpers.each(this.segments,function(segment, index){ - segment.transition({ - circumference : this.scale.getCircumference(), - outerRadius : this.scale.calculateCenterOffset(segment.value) - },easingDecimal); - - segment.endAngle = segment.startAngle + segment.circumference; - - // If we've removed the first segment we need to set the first one to - // start at the top. - if (index === 0){ - segment.startAngle = Math.PI * 1.5; - } - - //Check to see if it's the last segment, if not get the next and update the start angle - if (index < this.segments.length - 1){ - this.segments[index+1].startAngle = segment.endAngle; - } - segment.draw(); - }, this); - this.scale.draw(); - } - }); + } + }); + + //Declare segment class as a chart instance specific class, so it can share props for this instance + this.Slice = Chart.Arc.extend(); + + //Set up tooltip events on the chart + if (this.options.showTooltips) { + helpers.bindEvents(this, this.options.events, this.onHover); + } + + // Create new slice for each piece of data + this.data.metaData = []; + helpers.each(this.data.data, function(slice, index) { + var metaSlice = new this.Slice({ + _chart: this.chart, + innerRadius: 0, + startAngle: Math.PI * 1.5, + endAngle: Math.PI * 1.5, + x: this.chart.width / 2, + y: this.chart.height / 2 + }); + if (typeof slice == 'number') { + helpers.extend(metaSlice, { + value: slice + }); + } else { + helpers.extend(metaSlice, slice); + } + if (!metaSlice.backgroundColor) { + slice.backgroundColor = 'hsl(' + (360 * index / this.data.data.length) + ', 100%, 50%)'; + } + metaSlice.save(); + this.data.metaData.push(metaSlice); + }, this); + + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.update(); + + }, + updateScaleRange: function() { + helpers.extend(this.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2 + }); + }, + update: function() { + + this.updateScaleRange(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segment.borderWidth / 2) / 2; + + var circumference = 1 / this.data.data.length * 2; + + // Map new data to data points + helpers.each(this.data.metaData, function(slice, index) { + + var datapoint = this.data.data[index]; + + var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + helpers.extend(slice, { + _index: index, + x: this.chart.width / 2, + y: this.chart.height / 2, + value: datapoint.value, + label: datapoint.label, + innerRadius: 0, + outerRadius: this.scale.calculateCenterOffset(slice.value), + startAngle: startAngle, + endAngle: endAngle, + + backgroundColor: datapoint.backgroundColor, + hoverBackgroundColor: datapoint.hoverBackgroundColor || datapoint.backgroundColor, + borderWidth: this.options.borderWidth, + borderColor: this.options.segmentStrokeColor, + }); + slice.pivot(); + + }, this); + + this.render(); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + + this.clear(); + + helpers.each(this.data.metaData, function(segment, index) { + segment.transition(easingDecimal).draw(); + }, this); + + this.scale.draw(); + } + }); }).call(this); From 6af94298ec719de30c5cd8dcc0f59568dbabf032 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 27 May 2015 10:28:00 -0600 Subject: [PATCH 066/424] Radar Chart --- samples/radar.html | 116 ++- src/Chart.Core.js | 34 + src/Chart.Line.js | 44 +- src/Chart.Radar.js | 873 ++++++++++++++--------- src/Chart.Scale.js | 1684 ++++++++++++++++++++++---------------------- 5 files changed, 1475 insertions(+), 1276 deletions(-) diff --git a/samples/radar.html b/samples/radar.html index 0885f61ab8a..4a5c3f05b7e 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -1,67 +1,61 @@ - - Radar Chart - - - - -
    - -
    - - - + + + + +
    + +
    + + + - - diff --git a/src/Chart.Core.js b/src/Chart.Core.js index ff58bce32cd..48d6be231aa 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1273,6 +1273,8 @@ var vm = this._vm; var ctx = this._chart.ctx; + var first = vm._points[0]; + var last = vm._points[vm._points.length - 1]; // Draw the background first (so the border is always on top) helpers.each(vm._points, function(point, index) { @@ -1296,6 +1298,23 @@ } }, this); + if (vm.loop) { + + if (vm._tension > 0 || 1) { + + ctx.bezierCurveTo( + last._vm.controlPointNextX, + last._vm.controlPointNextY, + first._vm.controlPointPreviousX, + first._vm.controlPointPreviousY, + first._vm.x, + first._vm.y + ); + } else { + ctx.lineTo(first._vm.x, first._vm.y); + } + } + if (vm._points.length > 0) { //Round off the line by going to the base of the chart, back to the start, then fill. ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleZero); @@ -1331,6 +1350,21 @@ } } }, this); + if (vm.loop) { + if (vm._tension > 0 || 1) { + + ctx.bezierCurveTo( + last._vm.controlPointNextX, + last._vm.controlPointNextY, + first._vm.controlPointPreviousX, + first._vm.controlPointPreviousY, + first._vm.x, + first._vm.y + ); + } else { + ctx.lineTo(first._vm.x, first._vm.y); + } + } ctx.stroke(); diff --git a/src/Chart.Line.js b/src/Chart.Line.js index e1b44abcb56..25de6c2bfde 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -13,7 +13,7 @@ display: true, position: "bottom", id: "x-axis-1", // need an ID so datasets can reference the scale - + // grid line settings gridLines: { show: true, @@ -46,7 +46,7 @@ display: true, position: "left", id: "y-axis-1", - + // grid line settings gridLines: { show: true, @@ -78,22 +78,22 @@ //Boolean - Whether to stack the lines essentially creating a stacked area chart. stacked: false, - points: { + point: { // Number - Radius of each point dot in pixels radius: 3, - + // Number - Pixel width of point dot border borderWidth: 1, - + // Number - Pixel width of point on hover hoverRadius: 5, - + // Number - Pixel width of point dot border on hover hoverBorderWidth: 2, - + // Color backgroundColor: Chart.defaults.global.defaultColor, - + // Color borderColor: Chart.defaults.global.defaultColor, @@ -101,7 +101,7 @@ hitRadius: 6, }, - lines: { + line: { //Number - Tension of the bezier curve between points. Use 0 to turn off bezier tension tension: 0.4, }, @@ -207,17 +207,17 @@ helpers.extend(dataset.metaDataset, { // Utility _datasetIndex: datasetIndex, - + // Data _points: dataset.metaData, - + // Geometry scaleTop: yScale.top, scaleBottom: yScale.bottom, scaleZero: yScale.getPixelForValue(0), - + // Appearance - tension: dataset.tension || this.options.lines.tension, + tension: dataset.tension || this.options.line.tension, backgroundColor: dataset.backgroundColor || this.options.backgroundColor, borderWidth: dataset.borderWidth || this.options.borderWidth, borderColor: dataset.borderColor || this.options.borderColor, @@ -235,25 +235,25 @@ _chart: this.chart, _datasetIndex: datasetIndex, _index: index, - + // Data label: this.data.labels[index], value: this.data.datasets[datasetIndex].data[index], datasetLabel: this.data.datasets[datasetIndex].label, - + // Geometry offsetGridLines: this.options.offsetGridLines, x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), tension: this.data.datasets[datasetIndex].metaDataset.tension, - + // Appearnce - radius: this.data.datasets[datasetIndex].pointRadius || this.options.points.radius, - backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.points.backgroundColor, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointsborderWidth, - + radius: this.data.datasets[datasetIndex].pointRadius || this.options.point.radius, + backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.point.backgroundColor, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.point.borderWidth, + // Tooltip - hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.points.hitRadius, + hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.point.hitRadius, }); }, this); @@ -337,7 +337,7 @@ } else if (value < this.min) { this.min = value; } - + if (this.max === null) { this.max = value; } else if (value > this.max) { diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index 51795b695f1..4eee2439c03 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -1,233 +1,257 @@ -(function(){ - "use strict"; +(function() { + "use strict"; - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - Chart.Type.extend({ - name: "Radar", - defaults:{ + Chart.Type.extend({ + name: "Radar", + defaults: { - scale: { - scaleType: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate : false, + scale: { + scaleType: "radialLinear", + display: true, - lineArc: false, + //Boolean - Whether to animate scaling the chart from the centre + animate: false, - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, + lineArc: false, - angleLines: { - show: true, - color: "rgba(0,0,0,.1)", - lineWidth: 1 - }, + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, - // scale numbers - beginAtZero: true, + angleLines: { + show: true, + color: "rgba(0,0,0,.1)", + lineWidth: 1 + }, - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", + // scale numbers + beginAtZero: true, - //Boolean - Show a backdrop to the scale label - showLabelBackdrop : true, + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", - //String - The colour of the label backdrop - backdropColor : "rgba(255,255,255,0.75)", + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY : 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX : 2, - }, - - pointLabels: { - //String - Point label font declaration - fontFamily : "'Arial'", - - //String - Point label font weight - fontStyle : "normal", - - //Number - Point label font size in pixels - fontSize : 10, - - //String - Point label font colour - fontColor : "#666", - }, - }, - - //Boolean - Whether to show a dot for each point - pointDot : true, - - //Number - Radius of each point dot in pixels - pointRadius: 3, - - //Number - Pixel width of point dot border - pointBorderWidth: 1, - - //Number - Pixel width of point on hover - pointHoverRadius: 5, - - //Number - Pixel width of point dot border on hover - pointHoverBorderWidth: 2, - pointBackgroundColor: Chart.defaults.global.defaultColor, - pointBorderColor: Chart.defaults.global.defaultColor, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHitRadius: 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, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - - }, - - initialize: function(){ - this.PointClass = Chart.Point.extend({ - display: this.options.pointDot, - _chart: this.chart - }); - - this.datasets = []; - - this.buildScale(this.data); - - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.events, function(evt){ - var activePointsCollection = (evt.type !== 'mouseout') ? this.getPointsAtEvent(evt) : []; - - this.eachPoints(function(point){ - point.restore(['fillColor', 'strokeColor']); - }); - helpers.each(activePointsCollection, function(activePoint){ - activePoint.fillColor = activePoint.highlightFill; - activePoint.strokeColor = activePoint.highlightStroke; - }); - - this.showTooltip(activePointsCollection); - }); - } - - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(this.data.datasets,function(dataset){ - - var datasetObject = { - label: dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - pointColor : dataset.pointColor, - pointStrokeColor : dataset.pointStrokeColor, - points : [] - }; - - this.datasets.push(datasetObject); - - helpers.each(dataset.data,function(dataPoint,index){ - //Add a new point for each piece of data, passing any required data to draw. - var pointPosition; - if (!this.scale.animation){ - pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(dataPoint)); - } - datasetObject.points.push(new this.PointClass({ - value : dataPoint, - label : this.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, - fillColor : dataset.pointColor, - highlightFill : dataset.pointHighlightFill || dataset.pointColor, - highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor, - - // Appearance - radius: dataset.pointRadius || this.options.pointRadius, - backgroundColor: dataset.pointBackgroundColor || this.options.pointBackgroundColor, - borderWidth: dataset.pointBorderWidth || this.options.pointBorderWidth, - - // Tooltip - hoverRadius: dataset.pointHitRadius || this.options.pointHitRadius, - })); - },this); - - },this); - - this.render(); - }, - eachPoints : function(callback){ - helpers.each(this.datasets,function(dataset){ - helpers.each(dataset.points,callback,this); - },this); - }, - - getPointsAtEvent : function(evt){ - var mousePosition = helpers.getRelativePosition(evt), - fromCenter = helpers.getAngleFromPoint({ - x: this.scale.xCenter, - y: this.scale.yCenter - }, mousePosition); - - var anglePerIndex = (Math.PI * 2) /this.scale.valuesCount, - pointIndex = Math.round((fromCenter.angle - Math.PI * 1.5) / anglePerIndex), - activePointsCollection = []; - - // If we're at the top, make the pointIndex 0 to get the first of the array. - if (pointIndex >= this.scale.valuesCount || pointIndex < 0){ - pointIndex = 0; - } - - if (fromCenter.distance <= this.scale.drawingArea){ - helpers.each(this.datasets, function(dataset){ - activePointsCollection.push(dataset.points[pointIndex]); - }); - } - - return activePointsCollection; - }, - - buildScale : function(data){ - var self = this; - - var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); - this.scale = new ScaleConstructor({ - options: this.options.scale, - height : this.chart.height, - width: this.chart.width, - xCenter: this.chart.width/2, - yCenter: this.chart.height/2, - ctx : this.chart.ctx, - labels: data.labels, - valuesCount: data.datasets[0].data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + }, + + pointLabels: { + //String - Point label font declaration + fontFamily: "'Arial'", + + //String - Point label font weight + fontStyle: "normal", + + //Number - Point label font size in pixels + fontSize: 10, + + //String - Point label font colour + fontColor: "#666", + }, + }, + + line: { + + //Boolean - Whether to show a dot for each point + show: true, + + //Number - Pixel width of dot border + borderWidth: 1, + + backgroundColor: Chart.defaults.global.defaultColor, + + borderColor: Chart.defaults.global.defaultColor, + + //Number - amount extra to add to the radius to cater for hit detection outside the drawn + hitRadius: 20, + + //Number - Tension of the bezier curve between points. Use 0 to turn off bezier tension + tension: 0.4, + }, + + point: { + //Boolean - Whether to show a dot for each point + show: true, + + //Number - Radius of each dot in pixels + radius: 3, + + //Number - Pixel width of dot border + borderWidth: 1, + + //Number - Pixel width of on hover + hoverRadius: 5, + + //Number - Pixel width of dot border on hover + hoverBorderWidth: 2, + + backgroundColor: Chart.defaults.global.defaultColor, + + borderColor: Chart.defaults.global.defaultColor, + + //Number - amount extra to add to the radius to cater for hit detection outside the drawn + hitRadius: 20, + }, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + + }, + + initialize: function() { + + this.buildScale(this.data); + + + + // Events + helpers.bindEvents(this, this.options.events, this.events); + + var _this = this; + + //Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaDataset = new Chart.Line(); + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point()); + }, this); + + // The line chart only supports a single x axis because the x axis is always a dataset axis + }, this); + + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Set defaults for lines + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.extend(dataset.metaDataset, { + _points: dataset.metaData, + _datasetIndex: datasetIndex, + _chart: this.chart, + loop: true + }); + // Fill in dataset defaults from options + helpers.extend(dataset, helpers.merge(this.options, dataset)); + // Copy to view modele + dataset.metaDataset.save(); + }, this); + + // Set defaults for points + this.eachElement(function(point, index, dataset, datasetIndex) { + + helpers.extend(point, { + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + display: this.options.pointDot, + x: this.scale.xCenter, + y: this.scale.yCenter, + }); + + // Default bezier control points + helpers.extend(point, { + controlPointPreviousX: this.scale.xCenter, + controlPointPreviousY: this.scale.yCenter, + controlPointNextX: this.scale.xCenter, + controlPointNextY: this.scale.yCenter, + }); + // Copy to view model + point.save(); + + }, this); + + + + + + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + + + + + this.update(); + }, + + /*getPointsAtEvent: function(evt) { + var mousePosition = helpers.getRelativePosition(evt), + fromCenter = helpers.getAngleFromPoint({ + x: this.scale.xCenter, + y: this.scale.yCenter + }, mousePosition); + + var anglePerIndex = (Math.PI * 2) / this.scale.valuesCount, + pointIndex = Math.round((fromCenter.angle - Math.PI * 1.5) / anglePerIndex), + activePointsCollection = []; + + // If we're at the top, make the pointIndex 0 to get the first of the array. + if (pointIndex >= this.scale.valuesCount || pointIndex < 0) { + pointIndex = 0; + } + + if (fromCenter.distance <= this.scale.drawingArea) { + helpers.each(this.data.datasets, function(dataset) { + activePointsCollection.push(dataset.points[pointIndex]); + }); + } + + return activePointsCollection; + },*/ + nextPoint: function(collection, index) { + return collection[index - 1] || collection[collection.length - 1]; + }, + previousPoint: function(collection, index) { + return collection[index + 1] || collection[0]; + }, + buildScale: function() { + var self = this; + + var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleConstructor({ + options: this.options.scale, + height: this.chart.height, + width: this.chart.width, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + labels: this.data.labels, + valuesCount: this.data.datasets[0].data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { if (dataset.yAxisID === this.id) { helpers.each(dataset.data, function(value, index) { if (this.min === null) { @@ -235,7 +259,7 @@ } else if (value < this.min) { this.min = value; } - + if (this.max === null) { this.max = value; } else if (value > this.max) { @@ -244,139 +268,286 @@ }, this); } }, this); - } - }); - - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - }, - addData : function(valuesArray,label){ - //Map the values array for each of the datasets - this.scale.valuesCount++; - helpers.each(valuesArray,function(value,datasetIndex){ - var pointPosition = this.scale.getPointPosition(this.scale.valuesCount, this.scale.calculateCenterOffset(value)); - this.datasets[datasetIndex].points.push(new this.PointClass({ - value : value, - label : label, - datasetLabel: this.datasets[datasetIndex].label, - x: pointPosition.x, - y: pointPosition.y, - strokeColor : this.datasets[datasetIndex].pointStrokeColor, - fillColor : this.datasets[datasetIndex].pointColor - })); - },this); - - this.scale.labels.push(label); - - this.reflow(); - - this.update(); - }, - removeData : function(){ - this.scale.valuesCount--; - this.scale.labels.shift(); - helpers.each(this.datasets,function(dataset){ - dataset.points.shift(); - },this); - this.reflow(); - this.update(); - }, - update : function(){ - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(this.data.datasets,function(dataset,datasetIndex){ - - helpers.extend(this.datasets[datasetIndex], { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - pointColor : dataset.pointColor, - pointStrokeColor : dataset.pointStrokeColor, - }); - - helpers.each(dataset.data,function(dataPoint,index){ - helpers.extend(this.datasets[datasetIndex].points[index], { - value : dataPoint, - label : this.data.labels[index], - datasetLabel: dataset.label, - strokeColor : dataset.pointStrokeColor, - fillColor : dataset.pointColor, - highlightFill : dataset.pointHighlightFill || dataset.pointColor, - highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor - }); - },this); - - },this); - - this.eachPoints(function(point){ - point.save(); - }); - this.reflow(); - this.render(); - }, - reflow: function(){ - helpers.extend(this.scale, { - width : this.chart.width, - height: this.chart.height, - size : helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width/2, - yCenter: this.chart.height/2 - }); - - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - }, - draw : function(ease){ - var easeDecimal = ease || 1, - ctx = this.chart.ctx; - this.clear(); - this.scale.draw(); - - helpers.each(this.datasets,function(dataset){ - - //Transition each point first so that the line and point drawing isn't out of sync - helpers.each(dataset.points,function(point,index){ - if (point.hasValue()){ - point.transition(easeDecimal); - } - },this); - - - - //Draw the line between all the points - ctx.lineWidth = this.options.datasetStrokeWidth; - ctx.strokeStyle = dataset.strokeColor; - ctx.beginPath(); - helpers.each(dataset.points,function(point,index){ - if (index === 0){ - ctx.moveTo(point.x,point.y); - } - else{ - ctx.lineTo(point.x,point.y); - } - },this); - ctx.closePath(); - ctx.stroke(); - - ctx.fillStyle = dataset.fillColor; - ctx.fill(); - - //Now draw the points over the line - //A little inefficient double looping, but better than the line - //lagging behind the point positions - helpers.each(dataset.points,function(point){ - if (point.hasValue()){ - point.draw(); - } - }); - - },this); - - } - - }); + } + }); + + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + }, + update: function() { + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + + helpers.extend(dataset.metaDataset, { + // Utility + _datasetIndex: datasetIndex, + + // Data + _points: dataset.metaData, + + // Geometry + scaleTop: this.scale.top, + scaleBottom: this.scale.bottom, + scaleZero: this.scale.getPointPosition(0), + + // Appearance + tension: dataset.tension || this.options.line.tension, + backgroundColor: dataset.backgroundColor || this.options.backgroundColor, + borderWidth: dataset.borderWidth || this.options.borderWidth, + borderColor: dataset.borderColor || this.options.borderColor, + }); + dataset.metaDataset.pivot(); + }, this); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + + var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); + + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + + // Data + label: this.data.labels[index], + value: this.data.datasets[datasetIndex].data[index], + datasetLabel: this.data.datasets[datasetIndex].label, + + // Geometry + offsetGridLines: this.options.offsetGridLines, + x: pointPosition.x, + y: pointPosition.y, + tension: this.data.datasets[datasetIndex].metaDataset.tension, + + // Appearnce + radius: this.data.datasets[datasetIndex].pointRadius || this.options.point.radius, + backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.point.backgroundColor, + borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointsborderWidth, + + // Tooltip + hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.point.hitRadius, + }); + + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index), + point, + this.nextPoint(dataset, index), + point.tension + ); + + point.controlPointPreviousX = controlPoints.previous.x; + point.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point.controlPointNextY = this.chartArea.top; + } else { + point.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point.controlPointPreviousY = this.chartArea.top; + } else { + point.controlPointPreviousY = controlPoints.previous.y; + } + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + var datasetIndex = i; + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } + + // Draw all the scales + this.scale.draw(this.chartArea); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + + this.lastActive[0].radius = dataset.pointRadius; + this.lastActive[0].backgroundColor = dataset.pointBackgroundColor; + this.lastActive[0].borderColor = dataset.pointBorderColor; + this.lastActive[0].borderWidth = dataset.pointBorderWidth; + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + + this.lastActive[i].radius = dataset.pointRadius; + this.lastActive[i].backgroundColor = dataset.pointBackgroundColor; + this.lastActive[i].borderColor = dataset.pointBorderColor; + this.lastActive[i].borderWidth = dataset.pointBorderWidth; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + + this.active[0].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; + this.active[0].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[0].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + + this.active[i].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; + this.active[i].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); + this.active[i].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + + }); diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index b0313e4c057..d87f80e57ee 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -1,636 +1,638 @@ (function() { - "use strict"; - - var root = this, + "use strict"; + + var root = this, Chart = root.Chart, helpers = Chart.helpers; - - // The scale service is used to resize charts along with all of their axes. We make this as - // a service where scales are registered with their respective charts so that changing the - // scales does not require - Chart.scaleService = { - // The interesting function - fitScalesForChart: function(chartInstance, width, height) { - var xPadding = 10; - var yPadding = 10; - - if (chartInstance) { - var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "left"; - }); - var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "right"; - }); - var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "top"; - }); - var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "bottom"; - }); - - // Adjust the padding to take into account displaying labels - if (topScales.length === 0 || bottomScales.length === 0) { - var maxFontHeight = 0; - - var maxFontHeightFunction = function(scaleInstance) { - if (scaleInstance.options.labels.show) { - // Only consider font sizes for axes that actually show labels - maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); - } - }; - - helpers.each(leftScales, maxFontHeightFunction); - helpers.each(rightScales, maxFontHeightFunction); - - if (topScales.length === 0) { - // Add padding so that we can handle drawing the top nicely - yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides - } - - if (bottomScales.length === 0) { - // Add padding so that we can handle drawing the bottom nicely - yPadding += 1.5 * maxFontHeight; - } - } - - // Essentially we now have any number of scales on each of the 4 sides. - // Our canvas looks like the following. - // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and - // B1 is the bottom axis - // |------------------------------------------------------| - // | | T1 | | - // |----|-----|-------------------------------------|-----| - // | | | | | - // | L1 | L2 | Chart area | R1 | - // | | | | | - // | | | | | - // |----|-----|-------------------------------------|-----| - // | | B1 | | - // | | | | - // |------------------------------------------------------| - - // What we do to find the best sizing, we do the following - // 1. Determine the minimum size of the chart area. - // 2. Split the remaining width equally between each vertical axis - // 3. Split the remaining height equally between each horizontal axis - // 4. Give each scale the maximum size it can be. The scale will return it's minimum size - // 5. Adjust the sizes of each axis based on it's minimum reported size. - // 6. Refit each axis - // 7. Position each axis in the final location - // 8. Tell the chart the final location of the chart area - - // Step 1 - var chartWidth = width / 2; // min 50% - var chartHeight = height / 2; // min 50% - var aspectRatio = chartHeight / chartWidth; - var screenAspectRatio; - - if (chartInstance.options.maintainAspectRatio) { - screenAspectRatio = height / width; - - if (aspectRatio != screenAspectRatio) { - chartHeight = chartWidth * screenAspectRatio; - aspectRatio = screenAspectRatio; - } - } - - chartWidth -= (2 * xPadding); - chartHeight-= (2 * yPadding); - - // Step 2 - var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); - - // Step 3 - var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); - - // Step 4; - var minimumScaleSizes = []; - - var verticalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); - minimumScaleSizes.push({ - horizontal: false, - minSize: minSize, - scale: scaleInstance, - }); - }; - - var horizontalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); - minimumScaleSizes.push({ - horizontal: true, - minSize: minSize, - scale: scaleInstance, - }); - }; - - // vertical scales - helpers.each(leftScales, verticalScaleMinSizeFunction); - helpers.each(rightScales, verticalScaleMinSizeFunction); - - // horizontal scales - helpers.each(topScales, horizontalScaleMinSizeFunction); - helpers.each(bottomScales, horizontalScaleMinSizeFunction); - - // Step 5 - var maxChartHeight = height - (2 * yPadding); - var maxChartWidth = width - (2 * xPadding); - - helpers.each(minimumScaleSizes, function(wrapper) { - if (wrapper.horizontal) { - maxChartHeight -= wrapper.minSize.height; - } else { - maxChartWidth -= wrapper.minSize.width; - } - }); - - // At this point, maxChartHeight and maxChartWidth are the size the chart area could - // be if the axes are drawn at their minimum sizes. - if (chartInstance.options.maintainAspectRatio) { - // Figure out what the real max size will be - var maxAspectRatio = maxChartHeight / maxChartWidth; - - if (maxAspectRatio != screenAspectRatio) { - // Need to adjust - if (maxChartHeight < maxChartWidth) { - maxChartWidth = maxChartHeight / screenAspectRatio; - } - else { - maxChartHeight = maxChartWidth * screenAspectRatio; - } - } - } - - // Step 6 - var verticalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight); - } - }; - - var horizontalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - if (wrapper) { - scaleInstance.fit(maxChartWidth, wrapper.minSize.width); - } - }; - - helpers.each(leftScales, verticalScaleFitFunction); - helpers.each(rightScales, verticalScaleFitFunction); - helpers.each(topScales, horizontalScaleFitFunction); - helpers.each(bottomScales, horizontalScaleFitFunction); - - // Step 7 - var totalLeftWidth = xPadding; - var totalTopHeight = yPadding; - - // Calculate total width of all left axes - helpers.each(leftScales, function(scaleInstance) { - totalLeftWidth += scaleInstance.width; - }); - - // Calculate total height of all top axes - helpers.each(topScales, function(scaleInstance) { - totalTopHeight += scaleInstance.height; - }); - - // Position the scales - var left = xPadding; - var top = yPadding; - var right = 0; - var bottom = 0; - - var verticalScalePlacer = function(scaleInstance) { - scaleInstance.left = left; - scaleInstance.right = left + scaleInstance.width; - scaleInstance.top = totalTopHeight; - scaleInstance.bottom = totalTopHeight + maxChartHeight; - - // Move to next point - left = scaleInstance.right; - }; - - var horizontalScalePlacer = function(scaleInstance) { - scaleInstance.left = totalLeftWidth; - scaleInstance.right = totalLeftWidth + maxChartWidth; - scaleInstance.top = top; - scaleInstance.bottom = top + scaleInstance.height; - - // Move to next point - top = scaleInstance.bottom; - }; - - helpers.each(leftScales, verticalScalePlacer); - helpers.each(topScales, horizontalScalePlacer); - - // Account for chart width and height - left += maxChartWidth; - top += maxChartHeight; - - helpers.each(rightScales, verticalScalePlacer); - helpers.each(bottomScales, horizontalScalePlacer); - - // Step 8 - chartInstance.chartArea = { - left: totalLeftWidth, - top: totalTopHeight, - right: totalLeftWidth + maxChartWidth, - bottom: totalTopHeight + maxChartHeight, - }; - } - } - }; - - // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then - // use the new chart options to grab the correct scale - Chart.scales = { - constructors: {}, - // Use a registration function so that we can move to an ES6 map when we no longer need to support - // old browsers - registerScaleType: function(scaleType, scaleConstructor) { - this.constructors[scaleType] = scaleConstructor; - }, - getScaleConstructor: function(scaleType) { - return this.constructors.hasOwnProperty(scaleType) ? this.constructors[scaleType] : undefined; - } - }; - - var LinearScale = Chart.Element.extend({ - calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - generateTicks: function(width, height) { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw - - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; - - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); - } - } - else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph - - var maxTicks; - - if (this.isHorizontal()) { - maxTicks = Math.min(11, Math.ceil(width / 50)); - } else { - // The factor of 2 used to scale the font size has been experimentally determined. - maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); - } - - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } - - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; - - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - } - } - - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } - - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, - buildLabels: function() { - // We assume that this has been run after ticks have been generated. We try to figure out - // a label for each tick. - this.labels = []; - - helpers.each(this.ticks, function(tick, index, ticks) { - var label; - - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.lables.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick - }); - } - - this.labels.push(label ? label : ""); // empty string will not render so we're good - }, this); - }, - getPixelForValue: function(value) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - var pixel; - var range = this.max - this.min; - - if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.min)); - } else { - // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.min)); - } - - return pixel; - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { - this.calculateRange(); - this.generateTicks(maxWidth, maxHeight); - this.buildLabels(); - - var minSize = { - width: 0, - height: 0, - }; - - if (this.isHorizontal()) { - minSize.width = maxWidth; // fill all the width - - // In a horizontal axis, we need some room for the scale to be drawn - // - // ----------------------------------------------------- - // | | | | | - // - minSize.height = this.options.gridLines.show ? 25 : 0; - } else { - minSize.height = maxHeight; // fill all the height - - // In a vertical axis, we need some room for the scale to be drawn. - // The actual grid lines will be drawn on the chart area, however, we need to show - // ticks where the axis actually is. - // We will allocate 25px for this width - // | - // -| - // | - // | - // -| - // | - // | - // -| - minSize.width = this.options.gridLines.show ? 25 : 0; - } - - if (this.options.labels.show) { - // Don't bother fitting the labels if we are not showing them - var labelFont = helpers.fontString(this.options.labels.fontSize, - this.options.labels.fontStyle, this.options.labels.fontFamily); - - if (this.isHorizontal()) { - // A horizontal axis is more constrained by the height. - var maxLabelHeight = maxHeight - minSize.height; - var labelHeight = 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(maxHeight, minSize.height + labelHeight); - } else { - // A vertical axis is more constrained by the width. Labels are the dominant factor - // here, so get that length first - var maxLabelWidth = maxWidth - minSize.width; - var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - if (largestTextWidth < maxLabelWidth) { - // We don't need all the room - minSize.width += largestTextWidth; - } else { - // Expand to max size - minSize.width = maxWidth; - } - } - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - var hasZero; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - if (this.options.gridLines.show) { - // Draw the horizontal line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; - - helpers.each(this.ticks, function(tick, index) { - // Grid lines are vertical - var xValue = this.getPixelForValue(tick); - - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the left if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xValue, yTickStart); - this.ctx.lineTo(xValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xValue, chartArea.top); - this.ctx.lineTo(xValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - }, this); - } - - if (this.options.labels.show) { - // Draw the labels - - var labelStartY; - - if (this.options.position == "top") { - labelStartY = this.top; - } else { - // bottom side - labelStartY = this.top + 20; - } - - this.ctx.textAlign = "center"; - this.ctx.textBaseline = "top"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - helpers.each(this.labels, function(label, index) { - var xValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, xValue, labelStartY); - }, this); - } - } else { - // Vertical - if (this.options.gridLines.show) { - - // Draw the vertical line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; - var xTickStart = this.options.position == "right" ? this.left : this.right - 10; - var xTickEnd = this.options.position == "right" ? this.left + 10 : this.right; - - helpers.each(this.ticks, function(tick, index) { - // Grid lines are horizontal - var yValue = this.getPixelForValue(tick); - - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the bottom if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; // use boolean to indicate that we only want to do this once - } - - yValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xTickStart, yValue); - this.ctx.lineTo(xTickEnd, yValue); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(chartArea.left, yValue); - this.ctx.lineTo(chartArea.right, yValue); - } - - this.ctx.stroke(); - }, this); - } - - if (this.options.labels.show) { - // Draw the labels - - var labelStartX; - var maxLabelWidth = this.width - 25; - - if (this.options.position == "left") { - labelStartX = this.left; - } else { - // right side - labelStartX = this.left + 20; - } - - this.ctx.textAlign = "left"; - this.ctx.textBaseline = "middle"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - helpers.each(this.labels, function(label, index) { - var yValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, labelStartX, yValue, maxLabelWidth); - }, this); - } - } - } - } - }); - Chart.scales.registerScaleType("linear", LinearScale); - - var DatasetScale = Chart.Element.extend({ - // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset - calculateRange: helpers.noop, - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - getPixelForValue: function(value, index, includeOffset) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - if (this.isHorizontal()) { - var isRotated = (this.labelRotation > 0); - var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; - - if (this.options.gridLines.offsetGridLines && includeOffset) { - valueOffset += (valueWidth / 2); - } - - return this.left + Math.round(valueOffset); - } else { - return this.top + (index * (this.height / this.max)); - } - }, - calculateLabelRotation: function(maxHeight) { + + // The scale service is used to resize charts along with all of their axes. We make this as + // a service where scales are registered with their respective charts so that changing the + // scales does not require + Chart.scaleService = { + // The interesting function + fitScalesForChart: function(chartInstance, width, height) { + var xPadding = 10; + var yPadding = 10; + + if (chartInstance) { + var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "left"; + }); + var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "right"; + }); + var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "top"; + }); + var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "bottom"; + }); + + // Adjust the padding to take into account displaying labels + if (topScales.length === 0 || bottomScales.length === 0) { + var maxFontHeight = 0; + + var maxFontHeightFunction = function(scaleInstance) { + if (scaleInstance.options.labels.show) { + // Only consider font sizes for axes that actually show labels + maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); + } + }; + + helpers.each(leftScales, maxFontHeightFunction); + helpers.each(rightScales, maxFontHeightFunction); + + if (topScales.length === 0) { + // Add padding so that we can handle drawing the top nicely + yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides + } + + if (bottomScales.length === 0) { + // Add padding so that we can handle drawing the bottom nicely + yPadding += 1.5 * maxFontHeight; + } + } + + // Essentially we now have any number of scales on each of the 4 sides. + // Our canvas looks like the following. + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and + // B1 is the bottom axis + // |------------------------------------------------------| + // | | T1 | | + // |----|-----|-------------------------------------|-----| + // | | | | | + // | L1 | L2 | Chart area | R1 | + // | | | | | + // | | | | | + // |----|-----|-------------------------------------|-----| + // | | B1 | | + // | | | | + // |------------------------------------------------------| + + // What we do to find the best sizing, we do the following + // 1. Determine the minimum size of the chart area. + // 2. Split the remaining width equally between each vertical axis + // 3. Split the remaining height equally between each horizontal axis + // 4. Give each scale the maximum size it can be. The scale will return it's minimum size + // 5. Adjust the sizes of each axis based on it's minimum reported size. + // 6. Refit each axis + // 7. Position each axis in the final location + // 8. Tell the chart the final location of the chart area + + // Step 1 + var chartWidth = width / 2; // min 50% + var chartHeight = height / 2; // min 50% + var aspectRatio = chartHeight / chartWidth; + var screenAspectRatio; + + if (chartInstance.options.maintainAspectRatio) { + screenAspectRatio = height / width; + + if (aspectRatio != screenAspectRatio) { + chartHeight = chartWidth * screenAspectRatio; + aspectRatio = screenAspectRatio; + } + } + + chartWidth -= (2 * xPadding); + chartHeight -= (2 * yPadding); + + // Step 2 + var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); + + // Step 3 + var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); + + // Step 4; + var minimumScaleSizes = []; + + var verticalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); + minimumScaleSizes.push({ + horizontal: false, + minSize: minSize, + scale: scaleInstance, + }); + }; + + var horizontalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); + minimumScaleSizes.push({ + horizontal: true, + minSize: minSize, + scale: scaleInstance, + }); + }; + + // vertical scales + helpers.each(leftScales, verticalScaleMinSizeFunction); + helpers.each(rightScales, verticalScaleMinSizeFunction); + + // horizontal scales + helpers.each(topScales, horizontalScaleMinSizeFunction); + helpers.each(bottomScales, horizontalScaleMinSizeFunction); + + // Step 5 + var maxChartHeight = height - (2 * yPadding); + var maxChartWidth = width - (2 * xPadding); + + helpers.each(minimumScaleSizes, function(wrapper) { + if (wrapper.horizontal) { + maxChartHeight -= wrapper.minSize.height; + } else { + maxChartWidth -= wrapper.minSize.width; + } + }); + + // At this point, maxChartHeight and maxChartWidth are the size the chart area could + // be if the axes are drawn at their minimum sizes. + if (chartInstance.options.maintainAspectRatio) { + // Figure out what the real max size will be + var maxAspectRatio = maxChartHeight / maxChartWidth; + + if (maxAspectRatio != screenAspectRatio) { + // Need to adjust + if (maxChartHeight < maxChartWidth) { + maxChartWidth = maxChartHeight / screenAspectRatio; + } else { + maxChartHeight = maxChartWidth * screenAspectRatio; + } + } + } + + // Step 6 + var verticalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight); + } + }; + + var horizontalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + if (wrapper) { + scaleInstance.fit(maxChartWidth, wrapper.minSize.width); + } + }; + + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); + + // Step 7 + var totalLeftWidth = xPadding; + var totalTopHeight = yPadding; + + // Calculate total width of all left axes + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); + + // Calculate total height of all top axes + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; + }); + + // Position the scales + var left = xPadding; + var top = yPadding; + var right = 0; + var bottom = 0; + + var verticalScalePlacer = function(scaleInstance) { + scaleInstance.left = left; + scaleInstance.right = left + scaleInstance.width; + scaleInstance.top = totalTopHeight; + scaleInstance.bottom = totalTopHeight + maxChartHeight; + + // Move to next point + left = scaleInstance.right; + }; + + var horizontalScalePlacer = function(scaleInstance) { + scaleInstance.left = totalLeftWidth; + scaleInstance.right = totalLeftWidth + maxChartWidth; + scaleInstance.top = top; + scaleInstance.bottom = top + scaleInstance.height; + + // Move to next point + top = scaleInstance.bottom; + }; + + helpers.each(leftScales, verticalScalePlacer); + helpers.each(topScales, horizontalScalePlacer); + + // Account for chart width and height + left += maxChartWidth; + top += maxChartHeight; + + helpers.each(rightScales, verticalScalePlacer); + helpers.each(bottomScales, horizontalScalePlacer); + + // Step 8 + chartInstance.chartArea = { + left: totalLeftWidth, + top: totalTopHeight, + right: totalLeftWidth + maxChartWidth, + bottom: totalTopHeight + maxChartHeight, + }; + } + } + }; + + // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then + // use the new chart options to grab the correct scale + Chart.scales = { + constructors: {}, + // Use a registration function so that we can move to an ES6 map when we no longer need to support + // old browsers + registerScaleType: function(scaleType, scaleConstructor) { + this.constructors[scaleType] = scaleConstructor; + }, + getScaleConstructor: function(scaleType) { + return this.constructors.hasOwnProperty(scaleType) ? this.constructors[scaleType] : undefined; + } + }; + + var LinearScale = Chart.Element.extend({ + calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + generateTicks: function(width, height) { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks; + + if (this.isHorizontal()) { + maxTicks = Math.min(11, Math.ceil(width / 50)); + } else { + // The factor of 2 used to scale the font size has been experimentally determined. + maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); + } + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + this.labels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.lables.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.labels.push(label ? label : ""); // empty string will not render so we're good + }, this); + }, + getPixelForValue: function(value) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + var pixel; + var range = this.max - this.min; + + if (this.isHorizontal()) { + pixel = this.left + (this.width / range * (value - this.min)); + } else { + // Bottom - top since pixels increase downard on a screen + pixel = this.bottom - (this.height / range * (value - this.min)); + } + + return pixel; + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.generateTicks(maxWidth, maxHeight); + this.buildLabels(); + + var minSize = { + width: 0, + height: 0, + }; + + if (this.isHorizontal()) { + minSize.width = maxWidth; // fill all the width + + // In a horizontal axis, we need some room for the scale to be drawn + // + // ----------------------------------------------------- + // | | | | | + // + minSize.height = this.options.gridLines.show ? 25 : 0; + } else { + minSize.height = maxHeight; // fill all the height + + // In a vertical axis, we need some room for the scale to be drawn. + // The actual grid lines will be drawn on the chart area, however, we need to show + // ticks where the axis actually is. + // We will allocate 25px for this width + // | + // -| + // | + // | + // -| + // | + // | + // -| + minSize.width = this.options.gridLines.show ? 25 : 0; + } + + if (this.options.labels.show) { + // Don't bother fitting the labels if we are not showing them + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.isHorizontal()) { + // A horizontal axis is more constrained by the height. + var maxLabelHeight = maxHeight - minSize.height; + var labelHeight = 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + } else { + // A vertical axis is more constrained by the width. Labels are the dominant factor + // here, so get that length first + var maxLabelWidth = maxWidth - minSize.width; + var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (largestTextWidth < maxLabelWidth) { + // We don't need all the room + minSize.width += largestTextWidth; + } else { + // Expand to max size + minSize.width = maxWidth; + } + } + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + var hasZero; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + if (this.options.gridLines.show) { + // Draw the horizontal line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are vertical + var xValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the left if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xValue, chartArea.top); + this.ctx.lineTo(xValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartY; + + if (this.options.position == "top") { + labelStartY = this.top; + } else { + // bottom side + labelStartY = this.top + 20; + } + + this.ctx.textAlign = "center"; + this.ctx.textBaseline = "top"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var xValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, xValue, labelStartY); + }, this); + } + } else { + // Vertical + if (this.options.gridLines.show) { + + // Draw the vertical line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var xTickStart = this.options.position == "right" ? this.left : this.right - 10; + var xTickEnd = this.options.position == "right" ? this.left + 10 : this.right; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are horizontal + var yValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the bottom if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; // use boolean to indicate that we only want to do this once + } + + yValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(chartArea.left, yValue); + this.ctx.lineTo(chartArea.right, yValue); + } + + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartX; + var maxLabelWidth = this.width - 25; + + if (this.options.position == "left") { + labelStartX = this.left; + } else { + // right side + labelStartX = this.left + 20; + } + + this.ctx.textAlign = "left"; + this.ctx.textBaseline = "middle"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var yValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, labelStartX, yValue, maxLabelWidth); + }, this); + } + } + } + } + }); + Chart.scales.registerScaleType("linear", LinearScale); + + var DatasetScale = Chart.Element.extend({ + // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset + calculateRange: helpers.noop, + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + getPixelForValue: function(value, index, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.max)); + } + }, + calculateLabelRotation: function(maxHeight) { //Get the width of each grid by calculating the difference //between x offsets between 0 and 1. var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); @@ -638,8 +640,8 @@ var firstWidth = this.ctx.measureText(this.labels[0]).width; var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; - var firstRotated; - var lastRotated; + var firstRotated; + var lastRotated; this.paddingRight = lastWidth / 2 + 3; this.paddingLeft = firstWidth / 2 + 3; @@ -653,7 +655,7 @@ var firstRotatedWidth; this.labelWidth = originalLabelWidth; - + //Allow 3 pixels x2 padding either side for label readability // only the index matters for a dataset scale, but we want a consistent interface between scales var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; @@ -674,9 +676,9 @@ this.paddingRight = this.options.labels.fontSize / 2; if (sinRotation * originalLabelWidth > maxHeight) { - // go back one step - this.labelRotation--; - break; + // go back one step + this.labelRotation--; + break; } this.labelRotation++; @@ -690,117 +692,116 @@ } }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { - this.calculateRange(); - this.calculateLabelRotation(); - - var minSize = { - width: 0, - height: 0, - }; - - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - if (this.isHorizontal()) { - minSize.width = maxWidth; - this.width = maxWidth; - - var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); - } else { - minSize.height = maxHeight; - this.height = maxHeight; - - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - setContextLineSettings = true; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; - var isRotated = this.labelRotation !== 0; - - helpers.each(this.labels, function(label, index) { - var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines - var xLabelValue= this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) - - if (this.options.gridLines.show) { - if (index === 0) { - // Draw the first index specially - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xLineValue, yTickStart); - this.ctx.lineTo(xLineValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xLineValue, chartArea.top); - this.ctx.lineTo(xLineValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - } - - if (this.options.labels.show) { - this.ctx.save(); - this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); - this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); - this.ctx.font = this.font; - this.ctx.textAlign = (isRotated) ? "right" : "center"; - this.ctx.textBaseline = (isRotated) ? "middle" : "top"; - this.ctx.fillText(label, 0, 0); - this.ctx.restore(); - } - }, this); - } else { - // Vertical - if (this.options.gridLines.show) { - } - - if (this.options.labels.show) { - // Draw the labels - } - } - } - } - }); - Chart.scales.registerScaleType("dataset", DatasetScale); - - var LinearRadialScale = Chart.Element.extend({ + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.calculateLabelRotation(); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (this.isHorizontal()) { + minSize.width = maxWidth; + this.width = maxWidth; + + var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else { + minSize.height = maxHeight; + this.height = maxHeight; + + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + + helpers.each(this.labels, function(label, index) { + var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } + + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) {} + + if (this.options.labels.show) { + // Draw the labels + } + } + } + } + }); + Chart.scales.registerScaleType("dataset", DatasetScale); + + var LinearRadialScale = Chart.Element.extend({ initialize: function() { this.size = helpers.min([this.height, this.width]); this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); @@ -821,99 +822,98 @@ }, calculateRange: helpers.noop, // overridden in chart generateTicks: function() { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw - - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; - - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); - } - } - else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph - - var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); - - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } - - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; - - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - } - } - - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } - - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, buildYLabels: function() { this.yLabels = []; - - helpers.each(this.ticks, function(tick, index, ticks) { - var label; - - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.labels.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick - }); - } - - this.yLabels.push(label ? label : ""); - }, this); + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.yLabels.push(label ? label : ""); + }, this); }, getCircumference: function() { return ((Math.PI * 2) / this.valuesCount); @@ -1083,7 +1083,7 @@ if (this.options.labels.show) { ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - + if (this.showLabelBackdrop) { var labelWidth = ctx.measureText(label).width; ctx.fillStyle = this.options.labels.backdropColor; @@ -1094,7 +1094,7 @@ this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 ); } - + ctx.textAlign = 'center'; ctx.textBaseline = "middle"; ctx.fillStyle = this.options.labels.fontColor; @@ -1151,5 +1151,5 @@ } } }); - Chart.scales.registerScaleType("radialLinear", LinearRadialScale); -}).call(this); \ No newline at end of file + Chart.scales.registerScaleType("radialLinear", LinearRadialScale); +}).call(this); From 8a550852da6a903a9105a7f414e29b34f8c1318d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 31 May 2015 09:47:10 -0400 Subject: [PATCH 067/424] Check in work from floobits with minor changes to fix some errors --- src/Chart.Core.js | 276 +++++++++++++++++++--------------------------- src/Chart.Line.js | 245 +++++++++++++++++----------------------- 2 files changed, 217 insertions(+), 304 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 48d6be231aa..a41e81f0e2a 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -48,116 +48,73 @@ return this; }; + + var defaultColor = 'rgba(0,0,0,0.1)'; + //Globally expose the defaults to allow for user updating/changing Chart.defaults = { global: { - - // Animation defaults animation: { - // Number - Number of animation steps duration: 1000, - - // String - Animation easing effect easing: "easeOutQuart", - - // Function - Will fire on animation progression. onProgress: function() {}, - - // Function - Will fire on animation completion. onComplete: function() {}, }, - - // 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, - - // Array - Array of string names to attach interaction events events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], - - // Hover defaults hover: { - - // String || boolean - mode: 'label', // 'label', 'dataset', 'false' - - //Function(event, activeElements) - Custom hover handler onHover: null, - - //Function - Custom hover handler animationDuration: 400, }, - - //Function(event, clickedElements) - Custom click handler onClick: null, - - // Tooltip Defaults tooltips: { - - // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove enabled: true, - - // Function - Determines whether to draw built-in tooltip or call custom tooltip function custom: null, - - // String - Tooltip background colour backgroundColor: "rgba(0,0,0,0.8)", - - // String - Tooltip label font declaration for the scale label fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - - // Number - Tooltip label font size in pixels fontSize: 14, - - // String - Tooltip font weight style fontStyle: "normal", - - // String - Tooltip label font colour fontColor: "#fff", - - // String - Tooltip title font declaration for the scale label titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - - // Number - Tooltip title font size in pixels titleFontSize: 14, - - // String - Tooltip title font weight style titleFontStyle: "bold", - - // String - Tooltip title font colour titleFontColor: "#fff", - - // Number - pixel width of padding around text yPadding: 6, - - // Number - pixel width of padding around text xPadding: 6, - - // Number - Size of the caret on the caretSize: 8, - - // Number - Pixel radius of the border cornerRadius: 6, - - // Number - Pixel offset from point x to edge xOffset: 10, - - // String - Template string for singles template: "<%if (label){%><%=label%>: <%}%><%= value %>", - - // String - Template string for singles multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", - - // String - Colour behind the legend colour block multiKeyBackground: '#fff', }, - - // Color String - Used for undefined Colros - defaultColor: 'rgba(0,0,0,0.1)', - - } + defaultColor: defaultColor, + + // Element defaults + elements: { + line: { + tension: 0.4, + backgroundColor: defaultColor, + borderWidth: 3, + borderColor: defaultColor, + // Hover + hitRadius: 6, + hoverBorderWidth: 2, + }, + point: { + radius: 3, + backgroundColor: defaultColor, + borderWidth: 1, + borderColor: defaultColor, + // Hover + hitRadius: 6, + hoverRadius: 5, + hoverBorderWidth: 2, + }, + } + }, }; //Create a dictionary of chart types, to allow for extension of existing types @@ -238,6 +195,17 @@ return base; }, + getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { + if (!value) { + return defaultValue; + } + + if (helpers.isArray(value) && index < value.length) { + return value[index]; + } + + return value; + }, indexOf = helpers.indexOf = function(arrayToSearch, item) { if (Array.prototype.indexOf) { return arrayToSearch.indexOf(item); @@ -1142,48 +1110,36 @@ }; Chart.Element = function(configuration) { - extend(this, { - _vm: {}, - }); extend(this, configuration); this.initialize.apply(this, arguments); }; extend(Chart.Element.prototype, { initialize: function() {}, - save: function() { - this._vm = clone(this); - delete this._vm._vm; - delete this._vm._start; - return this; - }, pivot: function() { - if (this._start) { - this._start = clone(this); - helpers.extend(this._start, this._vm); - } + this._start = clone(this._view); return this; }, transition: function(ease) { + if (!this._view) { + this._view = clone(this._model); + } if (!this._start) { - if (!this._vm) { - this.save(); - } - this._start = clone(this._vm); + this.pivot(); } - each(this, function(value, key) { + each(this._model, function(value, key) { if (key[0] === '_' || !this.hasOwnProperty(key)) { // Only non-underscored properties } // Init if doesn't exist - else if (!this._vm[key]) { - this._vm[key] = value || null; + else if (!this._view[key]) { + this._view[key] = value || null; } // No unnecessary computations - else if (this[key] === this._vm[key]) { + else if (this[key] === this._view[key]) { // It's the same! Woohoo! } @@ -1191,18 +1147,18 @@ else if (typeof value === 'string') { try { var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); - this._vm[key] = color.rgbString(); + this._view[key] = color.rgbString(); } catch (err) { - this._vm[key] = value; + this._view[key] = value; } } // Number transitions else if (typeof value === 'number') { - - this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; - } else { - // Everything else - this._vm[key] = value; + this._view[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; + } + // Everything else + else { + this._view[key] = value; } }, this); @@ -1228,16 +1184,16 @@ Chart.Point = Chart.Element.extend({ inRange: function(mouseX, mouseY) { - var vm = this._vm; + var vm = this._view; var hoverRange = vm.hoverRadius + vm.radius; return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); }, inGroupRange: function(mouseX) { - var vm = this._vm; + var vm = this._view; return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + this.hoverRadius, 2)); }, tooltipPosition: function() { - var vm = this._vm; + var vm = this._view; return { x: vm.x, y: vm.y, @@ -1246,7 +1202,7 @@ }, draw: function() { - var vm = this._vm; + var vm = this._view; var ctx = this._chart.ctx; if (vm.radius > 0 || vm.borderWidth > 0) { @@ -1271,29 +1227,29 @@ Chart.Line = Chart.Element.extend({ draw: function() { - var vm = this._vm; + var vm = this._view; var ctx = this._chart.ctx; - var first = vm._points[0]; - var last = vm._points[vm._points.length - 1]; + var first = this._children[0]; + var last = this._children[this._children.length - 1]; // Draw the background first (so the border is always on top) - helpers.each(vm._points, function(point, index) { + helpers.each(this._children, function(point, index) { if (index === 0) { - ctx.moveTo(point._vm.x, point._vm.y); + ctx.moveTo(point._view.x, point._view.y); } else { if (vm._tension > 0 || 1) { - var previous = this.previousPoint(point, vm._points, index); + var previous = this.previousPoint(point, this._children, index); ctx.bezierCurveTo( - previous._vm.controlPointNextX, - previous._vm.controlPointNextY, - point._vm.controlPointPreviousX, - point._vm.controlPointPreviousY, - point._vm.x, - point._vm.y + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y ); } else { - ctx.lineTo(point._vm.x, point._vm.y); + ctx.lineTo(point._view.x, point._view.y); } } }, this); @@ -1303,22 +1259,22 @@ if (vm._tension > 0 || 1) { ctx.bezierCurveTo( - last._vm.controlPointNextX, - last._vm.controlPointNextY, - first._vm.controlPointPreviousX, - first._vm.controlPointPreviousY, - first._vm.x, - first._vm.y + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y ); } else { - ctx.lineTo(first._vm.x, first._vm.y); + ctx.lineTo(first._view.x, first._view.y); } } - if (vm._points.length > 0) { + if (this._children.length > 0) { //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleZero); - ctx.lineTo(vm._points[0].x, vm.scaleZero); + ctx.lineTo(this._children[this._children.length - 1].x, vm.scaleZero); + ctx.lineTo(this._children[0].x, vm.scaleZero); ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.closePath(); ctx.fill(); @@ -1330,23 +1286,23 @@ ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; ctx.beginPath(); - helpers.each(vm._points, function(point, index) { + helpers.each(this._children, function(point, index) { if (index === 0) { - ctx.moveTo(point._vm.x, point._vm.y); + ctx.moveTo(point._view.x, point._view.y); } else { if (vm._tension > 0 || 1) { - var previous = this.previousPoint(point, vm._points, index); + var previous = this.previousPoint(point, this._children, index); ctx.bezierCurveTo( - previous._vm.controlPointNextX, - previous._vm.controlPointNextY, - point._vm.controlPointPreviousX, - point._vm.controlPointPreviousY, - point._vm.x, - point._vm.y + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y ); } else { - ctx.lineTo(point._vm.x, point._vm.y); + ctx.lineTo(point._view.x, point._view.y); } } }, this); @@ -1354,15 +1310,15 @@ if (vm._tension > 0 || 1) { ctx.bezierCurveTo( - last._vm.controlPointNextX, - last._vm.controlPointNextY, - first._vm.controlPointPreviousX, - first._vm.controlPointPreviousY, - first._vm.x, - first._vm.y + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y ); } else { - ctx.lineTo(first._vm.x, first._vm.y); + ctx.lineTo(first._view.x, first._view.y); } } @@ -1380,7 +1336,7 @@ Chart.Arc = Chart.Element.extend({ inRange: function(chartX, chartY) { - var vm = this._vm; + var vm = this._view; var pointRelativePosition = helpers.getAngleFromPoint(vm, { x: chartX, @@ -1395,7 +1351,7 @@ //Ensure within the outside of the arc centre, but inside arc outer }, tooltipPosition: function() { - var vm = this._vm; + var vm = this._view; var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; @@ -1407,7 +1363,7 @@ draw: function() { var ctx = this._chart.ctx; - var vm = this._vm; + var vm = this._view; ctx.beginPath(); @@ -1433,7 +1389,7 @@ Chart.Rectangle = Chart.Element.extend({ draw: function() { - var vm = this._vm; + var vm = this._view; var ctx = this.ctx, halfWidth = vm.width / 2, @@ -1468,11 +1424,11 @@ } }, height: function() { - var vm = this._vm; + var vm = this._view; return vm.base - vm.y; }, inRange: function(mouseX, mouseY) { - var vm = this._vm; + var vm = this._view; if (vm.y < vm.base) { return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); } else { @@ -1480,11 +1436,11 @@ } }, inGroupRange: function(mouseX) { - var vm = this._vm; + var vm = this._view; return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); }, tooltipPosition: function() { - var vm = this._vm; + var vm = this._view; if (vm.y < vm.base) { return { x: vm.x, @@ -1586,14 +1542,14 @@ }); helpers.each(elements, function(element) { - xPositions.push(element._vm.x); - yPositions.push(element._vm.y); + xPositions.push(element._view.x); + yPositions.push(element._view.y); //Include any colour information about the element labels.push(helpers.template(this._options.tooltips.multiTemplate, element)); colors.push({ - fill: element._vm.backgroundColor, - stroke: element._vm.borderColor + fill: element._view.backgroundColor, + stroke: element._view.borderColor }); }, this); @@ -1656,7 +1612,7 @@ draw: function() { var ctx = this._chart.ctx; - var vm = this._vm; + var vm = this._view; switch (this._options.hover.mode) { case 'single': @@ -1690,7 +1646,7 @@ // Custom Tooltips if (this._custom) { - this._custom(this._vm); + this._custom(this._view); } else { switch (vm.yAlign) { case "above": @@ -1768,14 +1724,14 @@ } }, getLineHeight: function(index) { - var baseLineHeight = this._vm.y - (this._vm.height / 2) + this._vm.yPadding, + var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, afterTitleIndex = index - 1; //If the index is zero, we're getting the title if (index === 0) { - return baseLineHeight + this._vm.titleFontSize / 2; + return baseLineHeight + this._view.titleFontSize / 2; } else { - return baseLineHeight + ((this._vm.fontSize * 1.5 * afterTitleIndex) + this._vm.fontSize / 2) + this._vm.titleFontSize * 1.5; + return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; } }, diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 25de6c2bfde..ec2c766a63d 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -7,6 +7,13 @@ var defaultConfig = { + stacked: false, + + hover: { + mode: "label" + }, + + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", scales: { xAxes: [{ scaleType: "dataset", // scatter should not use a dataset axis @@ -74,45 +81,6 @@ } }], }, - - //Boolean - Whether to stack the lines essentially creating a stacked area chart. - stacked: false, - - point: { - // Number - Radius of each point dot in pixels - radius: 3, - - // Number - Pixel width of point dot border - borderWidth: 1, - - // Number - Pixel width of point on hover - hoverRadius: 5, - - // Number - Pixel width of point dot border on hover - hoverBorderWidth: 2, - - // Color - backgroundColor: Chart.defaults.global.defaultColor, - - // Color - borderColor: Chart.defaults.global.defaultColor, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - hitRadius: 6, - }, - - line: { - //Number - Tension of the bezier curve between points. Use 0 to turn off bezier tension - tension: 0.4, - }, - - //Number - Pixel width of dataset border - borderWidth: 2, - //Number - Pixel width of dataset border on hover - hoverBorderWidth: 2, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", }; @@ -121,66 +89,49 @@ defaults: defaultConfig, initialize: function() { + var _this = this; + // Events helpers.bindEvents(this, this.options.events, this.events); - var _this = this; - - //Create a new line and its points for each dataset and piece of data + // Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaDataset = new Chart.Line(); + + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point()); + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0,//xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + controlPointPreviousX: this.previousPoint(dataset.data, index).x, + controlPointPreviousY: this.nextPoint(dataset.data, index).y, + controlPointNextX: this.previousPoint(dataset.data, index).x, + controlPointNextY: this.nextPoint(dataset.data, index).y, + }, + })); }, this); - // The line chart only supports a single x axis because the x axis is always a dataset axis + // The line chart onlty supports a single x axis because the x axis is always a dataset axis dataset.xAxisID = this.options.scales.xAxes[0].id; if (!dataset.yAxisID) { dataset.yAxisID = this.options.scales.yAxes[0].id; } + }, this); // Build and fit the scale. Needs to happen after the axis IDs have been set this.buildScale(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Set defaults for lines - this.eachDataset(function(dataset, datasetIndex) { - helpers.extend(dataset.metaDataset, { - _points: dataset.metaData, - _datasetIndex: datasetIndex, - _chart: this.chart, - }); - // Fill in dataset defaults from options - helpers.extend(dataset, helpers.merge(this.options, dataset)); - // Copy to view modele - dataset.metaDataset.save(); - }, this); - - // Set defaults for points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - - helpers.extend(point, { - x: xScale.getPixelForValue(null, index, true), - y: this.chartArea.bottom, - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart - }); - - // Default bezier control points - helpers.extend(point, { - controlPointPreviousX: this.previousPoint(dataset, index).x, - controlPointPreviousY: this.nextPoint(dataset, index).y, - controlPointNextX: this.previousPoint(dataset, index).x, - controlPointNextY: this.nextPoint(dataset, index).y, - }); - // Copy to view model - point.save(); - }, this); // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ @@ -189,6 +140,7 @@ _options: this.options, }, this); + // Update that shiz this.update(); }, nextPoint: function(collection, index) { @@ -198,6 +150,7 @@ return collection[index + 1] || collection[index]; }, update: function() { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines @@ -206,22 +159,24 @@ helpers.extend(dataset.metaDataset, { // Utility + _scale: yScale, _datasetIndex: datasetIndex, - // Data - _points: dataset.metaData, - - // Geometry - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: yScale.getPixelForValue(0), - - // Appearance - tension: dataset.tension || this.options.line.tension, - backgroundColor: dataset.backgroundColor || this.options.backgroundColor, - borderWidth: dataset.borderWidth || this.options.borderWidth, - borderColor: dataset.borderColor || this.options.borderColor, + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: yScale.getPixelForValue(0), + }, }); + dataset.metaDataset.pivot(); }); @@ -233,61 +188,61 @@ helpers.extend(point, { // Utility _chart: this.chart, + _xScale: xScale, + _yScale: yScale, _datasetIndex: datasetIndex, _index: index, - // Data - label: this.data.labels[index], - value: this.data.datasets[datasetIndex].data[index], - datasetLabel: this.data.datasets[datasetIndex].label, - - // Geometry - offsetGridLines: this.options.offsetGridLines, - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales - y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - tension: this.data.datasets[datasetIndex].metaDataset.tension, - - // Appearnce - radius: this.data.datasets[datasetIndex].pointRadius || this.options.point.radius, - backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.point.backgroundColor, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.point.borderWidth, - - // Tooltip - hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.point.hitRadius, + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, }); }, this); // Update control points for the bezier curve this.eachElement(function(point, index, dataset, datasetIndex) { var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index), - point, - this.nextPoint(dataset, index), - point.tension + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension ); - point.controlPointPreviousX = controlPoints.previous.x; - point.controlPointNextX = controlPoints.next.x; + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; // Prevent the bezier going outside of the bounds of the graph // Cap puter bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chartArea.bottom) { - point.controlPointNextY = this.chartArea.bottom; + point._model.controlPointNextY = this.chartArea.bottom; } else if (controlPoints.next.y < this.chartArea.top) { - point.controlPointNextY = this.chartArea.top; + point._model.controlPointNextY = this.chartArea.top; } else { - point.controlPointNextY = controlPoints.next.y; + point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds if (controlPoints.previous.y > this.chartArea.bottom) { - point.controlPointPreviousY = this.chartArea.bottom; + point._model.controlPointPreviousY = this.chartArea.bottom; } else if (controlPoints.previous.y < this.chartArea.top) { - point.controlPointPreviousY = this.chartArea.top; + point._model.controlPointPreviousY = this.chartArea.top; } else { - point.controlPointPreviousY = controlPoints.previous.y; + point._model.controlPointPreviousY = controlPoints.previous.y; } + // Now pivot the point for animation point.pivot(); }, this); @@ -400,9 +355,6 @@ this.scales[scale.id] = scale; }, this); - }, - redraw: function() { - }, draw: function(ease) { @@ -472,25 +424,28 @@ } var dataset; + var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; - this.lastActive[0].radius = dataset.pointRadius; - this.lastActive[0].backgroundColor = dataset.pointBackgroundColor; - this.lastActive[0].borderColor = dataset.pointBorderColor; - this.lastActive[0].borderWidth = dataset.pointBorderWidth; + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; - this.lastActive[i].radius = dataset.pointRadius; - this.lastActive[i].backgroundColor = dataset.pointBackgroundColor; - this.lastActive[i].borderColor = dataset.pointBorderColor; - this.lastActive[i].borderWidth = dataset.pointBorderWidth; + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); } break; case 'dataset': @@ -505,20 +460,22 @@ switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; - this.active[0].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; - this.active[0].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; - this.active[i].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; - this.active[i].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); } break; case 'dataset': From e48c7f168ba48290ae99cfd69dc8ba27e1bd4384 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 31 May 2015 10:24:53 -0400 Subject: [PATCH 068/424] Add back line fill option. This is set on a per dataset basis, but there is an override in the config. Demo this in the line sample. --- samples/line.html | 3 ++- src/Chart.Core.js | 9 ++++++--- src/Chart.Line.js | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/samples/line.html b/samples/line.html index 826a568668c..7f96c553a25 100644 --- a/samples/line.html +++ b/samples/line.html @@ -26,7 +26,8 @@ labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + fill: false }, { label: "My Second dataset", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] diff --git a/src/Chart.Core.js b/src/Chart.Core.js index a41e81f0e2a..a3b41c9014d 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -99,6 +99,8 @@ backgroundColor: defaultColor, borderWidth: 3, borderColor: defaultColor, + fill: true, // do we fill in the area between the line and the x axis + // Hover hitRadius: 6, hoverBorderWidth: 2, @@ -1271,10 +1273,11 @@ } } - if (this._children.length > 0) { + // If we had points and want to fill this line, do so. + if (this._children.length > 0 && vm.fill) { //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(this._children[this._children.length - 1].x, vm.scaleZero); - ctx.lineTo(this._children[0].x, vm.scaleZero); + ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero); + ctx.lineTo(this._children[0]._view.x, vm.scaleZero); ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.closePath(); ctx.fill(); diff --git a/src/Chart.Line.js b/src/Chart.Line.js index ec2c766a63d..fa54cb96da6 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -170,6 +170,8 @@ backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom, From 92776ce0ac035c24ea80320dc04040bbc82c28d3 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 31 May 2015 16:55:17 -0400 Subject: [PATCH 069/424] Animations & tool tips show. The title is not correct yet. --- samples/line.html | 2 +- src/Chart.Core.js | 110 ++++++++++++++++++++++++++++------------------ src/Chart.Line.js | 13 +++--- 3 files changed, 74 insertions(+), 51 deletions(-) diff --git a/samples/line.html b/samples/line.html index 7f96c553a25..7655abe7a9d 100644 --- a/samples/line.html +++ b/samples/line.html @@ -36,7 +36,7 @@ $.each(lineChartData.datasets, function(i, dataset) { dataset.borderColor = randomColor(0.4); - dataset.backgroundColor = randomColor(1); + dataset.backgroundColor = randomColor(0.5); dataset.pointBorderColor = randomColor(0.7); dataset.pointBackgroundColor = randomColor(0.5); dataset.pointBorderWidth = 1; diff --git a/src/Chart.Core.js b/src/Chart.Core.js index a3b41c9014d..3a5adf38a26 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1131,7 +1131,7 @@ each(this._model, function(value, key) { - if (key[0] === '_' || !this.hasOwnProperty(key)) { + if (key[0] === '_' || !this._model.hasOwnProperty(key)) { // Only non-underscored properties } @@ -1141,14 +1141,14 @@ } // No unnecessary computations - else if (this[key] === this._view[key]) { + else if (this._model[key] === this._view[key]) { // It's the same! Woohoo! } // Color transitions if possible else if (typeof value === 'string') { try { - var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); + var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); this._view[key] = color.rgbString(); } catch (err) { this._view[key] = value; @@ -1156,7 +1156,7 @@ } // Number transitions else if (typeof value === 'number') { - this._view[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; + this._view[key] = ((this._model[key] - this._start[key]) * ease) + this._start[key]; } // Everything else else { @@ -1172,12 +1172,12 @@ }, tooltipPosition: function() { return { - x: this.x, - y: this.y + x: this._model.x, + y: this._model.y }; }, hasValue: function() { - return isNumber(this.value); + return isNumber(this._model.x) && isNumber(this._model.y); } }); @@ -1192,7 +1192,12 @@ }, inGroupRange: function(mouseX) { var vm = this._view; - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + this.hoverRadius, 2)); + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + } else { + return false; + } }, tooltipPosition: function() { var vm = this._view; @@ -1472,24 +1477,31 @@ initialize: function() { var options = this._options; extend(this, { - opacity: 0, - xPadding: options.tooltips.xPadding, - yPadding: options.tooltips.yPadding, - xOffset: options.tooltips.xOffset, - backgroundColor: options.tooltips.backgroundColor, - textColor: options.tooltips.fontColor, - _fontFamily: options.tooltips.fontFamily, - _fontStyle: options.tooltips.fontStyle, - fontSize: options.tooltips.fontSize, - titleTextColor: options.tooltips.titleFontColor, - _titleFontFamily: options.tooltips.titleFontFamily, - _titleFontStyle: options.tooltips.titleFontStyle, - titleFontSize: options.tooltips.titleFontSize, - caretHeight: options.tooltips.caretSize, - cornerRadius: options.tooltips.cornerRadius, - legendColorBackground: options.tooltips.multiKeyBackground, - labels: [], - colors: [], + _model: { + // Positioning + xPadding: options.tooltips.xPadding, + yPadding: options.tooltips.yPadding, + xOffset: options.tooltips.xOffset, + + // Labels + textColor: options.tooltips.fontColor, + _fontFamily: options.tooltips.fontFamily, + _fontStyle: options.tooltips.fontStyle, + fontSize: options.tooltips.fontSize, + + // Title + titleTextColor: options.tooltips.titleFontColor, + _titleFontFamily: options.tooltips.titleFontFamily, + _titleFontStyle: options.tooltips.titleFontStyle, + titleFontSize: options.tooltips.titleFontSize, + + // Appearance + caretHeight: options.tooltips.caretSize, + cornerRadius: options.tooltips.cornerRadius, + backgroundColor: options.tooltips.backgroundColor, + opacity: 0, + legendColorBackground: options.tooltips.multiKeyBackground, + }, }); }, update: function() { @@ -1498,15 +1510,22 @@ switch (this._options.hover.mode) { case 'single': - helpers.extend(this, { - text: template(this._options.tooltips.template, this._active[0]), + helpers.extend(this._model, { + text: template(this._options.tooltips.template, { + // These variables are available in the template function. Add others here + element: this._active[0], + value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], + label: this._data.labels ? this._data.labels[this._active[0]._index] : '', + }), }); + var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this, { + helpers.extend(this._model, { x: Math.round(tooltipPosition.x), y: Math.round(tooltipPosition.y), caretPadding: tooltipPosition.padding }); + break; case 'label': @@ -1542,14 +1561,19 @@ if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { elements.push(dataCollection[dataIndex]); } - }); + }, this); helpers.each(elements, function(element) { xPositions.push(element._view.x); yPositions.push(element._view.y); //Include any colour information about the element - labels.push(helpers.template(this._options.tooltips.multiTemplate, element)); + labels.push(helpers.template(this._options.tooltips.multiTemplate, { + // These variables are available in the template function. Add others here + element: element, + datasetLabel: this._data.datasets[element._datasetIndex].label, + value: this._data.datasets[element._datasetIndex].data[element._index], + })); colors.push({ fill: element._view.backgroundColor, stroke: element._view.borderColor @@ -1570,7 +1594,7 @@ }).call(this, dataIndex); // Apply for now - helpers.extend(this, { + helpers.extend(this._model, { x: medianPosition.x, y: medianPosition.y, labels: labels, @@ -1582,30 +1606,30 @@ // Calculate Appearance Tweaks - this.height = (labels.length * this.fontSize) + ((labels.length - 1) * (this.fontSize / 2)) + (this.yPadding * 2) + this.titleFontSize * 1.5; + this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; var titleWidth = ctx.measureText(this.title).width, //Label has a legend square as well so account for this. - labelWidth = longestText(ctx, this.font, labels) + this.fontSize + 3, + labelWidth = longestText(ctx, this.font, labels) + this._model.fontSize + 3, longestTextWidth = max([labelWidth, titleWidth]); - this.width = longestTextWidth + (this.xPadding * 2); + this._model.width = longestTextWidth + (this._model.xPadding * 2); - var halfHeight = this.height / 2; + var halfHeight = this._model.height / 2; //Check to ensure the height will fit on the canvas - if (this.y - halfHeight < 0) { - this.y = halfHeight; - } else if (this.y + halfHeight > this._chart.height) { - this.y = this._chart.height - halfHeight; + if (this._model.y - halfHeight < 0) { + this._model.y = halfHeight; + } else if (this._model.y + halfHeight > this._chart.height) { + this._model.y = this._chart.height - halfHeight; } //Decide whether to align left or right based on position on canvas - if (this.x > this._chart.width / 2) { - this.x -= this.xOffset + this.width; + if (this._model.x > this._chart.width / 2) { + this._model.x -= this._model.xOffset + this._model.width; } else { - this.x += this.xOffset; + this._model.x += this._model.xOffset; } break; } diff --git a/src/Chart.Line.js b/src/Chart.Line.js index fa54cb96da6..06f4c09b8d9 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -415,8 +415,8 @@ }.call(this); // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); } if (e.type == 'mouseup' || e.type == 'click') { @@ -496,17 +496,16 @@ // Active if (this.active.length) { + this.tooltip._model.opacity = 1; + helpers.extend(this.tooltip, { - opacity: 1, _active: this.active, }); this.tooltip.update(); } else { // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.tooltip._model.opacity = 0; } } @@ -529,7 +528,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hoverAnimationDuration); + this.render(this.options.hover.animationDuration); } } From edbb2356680f5c2726e9d6b7582a54b46cdb3578 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 31 May 2015 20:16:04 -0400 Subject: [PATCH 070/424] Tooltip titles now work in the line chart. Getting ever closer to being done --- samples/line.html | 4 +++- src/Chart.Core.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/line.html b/samples/line.html index 7655abe7a9d..2a1794284ba 100644 --- a/samples/line.html +++ b/samples/line.html @@ -50,7 +50,9 @@ data: lineChartData, options: { responsive: true, - hoverMode: 'label', + hover: { + mode: 'label', + }, stacked: false, scales: { xAxes: [{ diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 3a5adf38a26..e9b27caf9ab 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1598,7 +1598,7 @@ x: medianPosition.x, y: medianPosition.y, labels: labels, - title: this._active.length ? this._active[0].label : '', + title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', legendColors: colors, legendBackgroundColor: this._options.tooltips.multiKeyBackground, }); From b7dc2339f4951a12c148d4fdcdc21f9ec9350886 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 2 Jun 2015 13:42:09 -0600 Subject: [PATCH 071/424] line: skipNull functionality --- samples/line.html | 8 +++--- src/Chart.Core.js | 67 +++++++++++++++++++++++++++++++++++++++++------ src/Chart.Line.js | 20 +++++++------- 3 files changed, 74 insertions(+), 21 deletions(-) diff --git a/samples/line.html b/samples/line.html index 2a1794284ba..b954d7d15a9 100644 --- a/samples/line.html +++ b/samples/line.html @@ -26,11 +26,11 @@ labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], - fill: false + data: [null, randomScalingFactor(), randomScalingFactor(), null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + fill: false, }, { label: "My Second dataset", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + data: [null, randomScalingFactor(), randomScalingFactor(), null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], }] }; @@ -47,7 +47,7 @@ window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); window.myLine = new Chart(ctx).Line({ - data: lineChartData, + data: lineChartData, options: { responsive: true, hover: { diff --git a/src/Chart.Core.js b/src/Chart.Core.js index e9b27caf9ab..9c9587bd06c 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -100,6 +100,8 @@ borderWidth: 3, borderColor: defaultColor, fill: true, // do we fill in the area between the line and the x axis + skipNull: true, + drawNull: false, // Hover hitRadius: 6, @@ -373,11 +375,11 @@ fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta fb = t * d12 / (d01 + d12); return { - next: { + previous: { x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) }, - previous: { + next: { x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) } @@ -1212,6 +1214,11 @@ var vm = this._view; var ctx = this._chart.ctx; + + if (vm.skip) { + return; + } + if (vm.radius > 0 || vm.borderWidth > 0) { ctx.beginPath(); @@ -1241,12 +1248,32 @@ // Draw the background first (so the border is always on top) helpers.each(this._children, function(point, index) { + var scaleZero = point._yScale.getPointPixelForValue(0); + + // First point only if (index === 0) { - ctx.moveTo(point._view.x, point._view.y); - } else { + if (point._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, scaleZero); + } else { + ctx.moveTo(point._view.x, point._view.y); + } + return; + } + + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull) { + ctx.lineTo(this.previousPoint(point, this._children, index)._view.x, scaleZero); + ctx.moveTo(this.nextPoint(point, this._children, index)._view.x, scaleZero); + } + // End Skip Stright line from the base line + else if (this.previousPoint(point, this._children, index)._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, scaleZero); + ctx.lineTo(point._view.x, point._view.y); + } + // Normal Bezier Curve + else { if (vm._tension > 0 || 1) { var previous = this.previousPoint(point, this._children, index); - ctx.bezierCurveTo( previous._view.controlPointNextX, previous._view.controlPointNextY, @@ -1261,8 +1288,8 @@ } }, this); + // For radial scales, loop back around to the first point if (vm.loop) { - if (vm._tension > 0 || 1) { ctx.bezierCurveTo( @@ -1295,12 +1322,31 @@ ctx.beginPath(); helpers.each(this._children, function(point, index) { + var scaleZero = point._yScale.getPointPixelForValue(0); + // First point only if (index === 0) { + if (point._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, scaleZero); + } else { + ctx.moveTo(point._view.x, point._view.y); + } + return; + } + + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull) { + ctx.moveTo(this.previousPoint(point, this._children, index)._view.x, scaleZero); + ctx.moveTo(this.nextPoint(point, this._children, index)._view.x, scaleZero); + } + // End Skip Stright line from the base line + else if (this.previousPoint(point, this._children, index)._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, scaleZero); ctx.moveTo(point._view.x, point._view.y); - } else { + } + // Normal Bezier Curve + else { if (vm._tension > 0 || 1) { var previous = this.previousPoint(point, this._children, index); - ctx.bezierCurveTo( previous._view.controlPointNextX, previous._view.controlPointNextY, @@ -1339,6 +1385,11 @@ return true; }, index) || point; }, + nextPoint: function(point, collection, index) { + return helpers.findNextWhere(collection, function() { + return true; + }, index) || point; + }, }); Chart.Arc = Chart.Element.extend({ diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 06f4c09b8d9..4def9616892 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -111,12 +111,12 @@ _index: index, _chart: this.chart, _model: { - x: 0,//xScale.getPixelForValue(null, index, true), + x: 0, //xScale.getPixelForValue(null, index, true), y: 0, //this.chartArea.bottom, - controlPointPreviousX: this.previousPoint(dataset.data, index).x, - controlPointPreviousY: this.nextPoint(dataset.data, index).y, - controlPointNextX: this.previousPoint(dataset.data, index).x, - controlPointNextY: this.nextPoint(dataset.data, index).y, + //controlPointPreviousX: this.previousPoint(dataset.data, index).x, + //controlPointPreviousY: this.previousPoint(dataset.data, index).y, + //controlPointNextX: this.nextPoint(dataset.data, index).x, + //controlPointNextY: this.nextPoint(dataset.data, index).y, }, })); }, this); @@ -144,10 +144,10 @@ this.update(); }, nextPoint: function(collection, index) { - return collection[index - 1] || collection[index]; + return collection[index + 1] || collection[index]; }, previousPoint: function(collection, index) { - return collection[index + 1] || collection[index]; + return collection[index - 1] || collection[index]; }, update: function() { @@ -171,7 +171,8 @@ borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, borderColor: dataset.borderColor || this.options.elements.line.borderColor, fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom, @@ -206,6 +207,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -497,7 +499,7 @@ // Active if (this.active.length) { this.tooltip._model.opacity = 1; - + helpers.extend(this.tooltip, { _active: this.active, }); From df4d2d2594277dc99f46885c365b70d33be990a8 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 2 Jun 2015 15:14:06 -0600 Subject: [PATCH 072/424] Stroked tooltip colors --- samples/line.html | 51 +++++++++++++++++++---------------------------- src/Chart.Core.js | 39 +++++++++++++++++++++++++++++------- src/Chart.Line.js | 8 ++------ 3 files changed, 54 insertions(+), 44 deletions(-) diff --git a/samples/line.html b/samples/line.html index b954d7d15a9..85ff667d324 100644 --- a/samples/line.html +++ b/samples/line.html @@ -22,19 +22,24 @@ return 'rgba(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + (opacity || '.3') + ')'; }; - var lineChartData = { - labels: ["January", "February", "March", "April", "May", "June", "July"], - datasets: [{ - label: "My First dataset", - data: [null, randomScalingFactor(), randomScalingFactor(), null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], - fill: false, - }, { - label: "My Second dataset", - data: [null, randomScalingFactor(), randomScalingFactor(), null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], - }] + var config = { + data: { + labels: ["January", "February", "March", "April", "May", "June", "July"], + datasets: [{ + label: "My First dataset", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + fill: false, + }, { + label: "My Second dataset", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + }] + }, + options: { + responsive: true + } }; - $.each(lineChartData.datasets, function(i, dataset) { + $.each(config.data.datasets, function(i, dataset) { dataset.borderColor = randomColor(0.4); dataset.backgroundColor = randomColor(0.5); dataset.pointBorderColor = randomColor(0.7); @@ -42,33 +47,17 @@ dataset.pointBorderWidth = 1; }); - console.log(lineChartData); + console.log(config.data); window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myLine = new Chart(ctx).Line({ - data: lineChartData, - options: { - responsive: true, - hover: { - mode: 'label', - }, - stacked: false, - scales: { - xAxes: [{ - gridLines: { - offsetGridLines: false - } - }] - } - } - }); + window.myLine = new Chart(ctx).Line(config); }; $('#randomizeData').click(function() { - lineChartData.datasets[0].data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; + config.data.datasets[0].data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; - lineChartData.datasets[1].data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; + config.data.datasets[1].data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; window.myLine.update(); }); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 9c9587bd06c..8462b471487 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -73,11 +73,11 @@ custom: null, backgroundColor: "rgba(0,0,0,0.8)", fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - fontSize: 14, + fontSize: 10, fontStyle: "normal", fontColor: "#fff", titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - titleFontSize: 14, + titleFontSize: 12, titleFontStyle: "bold", titleFontColor: "#fff", yPadding: 6, @@ -85,8 +85,30 @@ caretSize: 8, cornerRadius: 6, xOffset: 10, - template: "<%if (label){%><%=label%>: <%}%><%= value %>", - multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", + template: [ + '<% if(label){ %>', + ' <%=label %>:', + '<% } %>', + '<%=value %>', + ].join(''), + multiTemplate: [ + '<%if (datasetLabel){ %>', + ' <%=datasetLabel %>:', + '<% } %>', + '<%=value %>' + ].join(''), + legendTemplate: [ + '
      ', + ' <% for (var i=0; i', + '
    • ', + ' ', + ' <% if(datasets[i].label){ %>', + ' <%=datasets[i].label %>', + ' <% } %>', + '
    • ', + ' <% } %>', + '
    ', + ].join(''), multiKeyBackground: '#fff', }, @@ -114,7 +136,7 @@ borderColor: defaultColor, // Hover hitRadius: 6, - hoverRadius: 5, + hoverRadius: 4, hoverBorderWidth: 2, }, } @@ -1120,6 +1142,9 @@ extend(Chart.Element.prototype, { initialize: function() {}, pivot: function() { + if (!this._view) { + this._view = clone(this._model); + } this._start = clone(this._view); return this; }, @@ -1790,8 +1815,8 @@ //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); //Instead we'll make a white filled block to put the legendColour palette over. - ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 4def9616892..8ee9859875f 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -13,7 +13,6 @@ mode: "label" }, - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", scales: { xAxes: [{ scaleType: "dataset", // scatter should not use a dataset axis @@ -113,12 +112,9 @@ _model: { x: 0, //xScale.getPixelForValue(null, index, true), y: 0, //this.chartArea.bottom, - //controlPointPreviousX: this.previousPoint(dataset.data, index).x, - //controlPointPreviousY: this.previousPoint(dataset.data, index).y, - //controlPointNextX: this.nextPoint(dataset.data, index).x, - //controlPointNextY: this.nextPoint(dataset.data, index).y, }, })); + }, this); // The line chart onlty supports a single x axis because the x axis is always a dataset axis @@ -215,6 +211,7 @@ }); }, this); + // Update control points for the bezier curve this.eachElement(function(point, index, dataset, datasetIndex) { var controlPoints = helpers.splineCurve( @@ -374,7 +371,6 @@ for (var i = this.data.datasets.length - 1; i >= 0; i--) { var dataset = this.data.datasets[i]; - var datasetIndex = i; // Transition Point Locations helpers.each(dataset.metaData, function(point, index) { From 74d3890ba9acc61a77f4cd7d2c0e310c6750dcbb Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 2 Jun 2015 15:14:51 -0600 Subject: [PATCH 073/424] no legend yet... :( --- src/Chart.Core.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8462b471487..a38ffdc44d3 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -97,18 +97,6 @@ '<% } %>', '<%=value %>' ].join(''), - legendTemplate: [ - '
      ', - ' <% for (var i=0; i', - '
    • ', - ' ', - ' <% if(datasets[i].label){ %>', - ' <%=datasets[i].label %>', - ' <% } %>', - '
    • ', - ' <% } %>', - '
    ', - ].join(''), multiKeyBackground: '#fff', }, From 6b0e609935cb67cf32c3c8c94fe278f9314d9ce4 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 2 Jun 2015 16:48:39 -0600 Subject: [PATCH 074/424] Bar Chart Stacked nestedConfig --- samples/bar.html | 10 +- src/Chart.Bar.js | 434 ++++++++++++++++++++++------------------------ src/Chart.Core.js | 12 +- 3 files changed, 221 insertions(+), 235 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index d9a5dc4d166..86169d164bc 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -34,21 +34,13 @@ label: 'Dataset 3', backgroundColor: "rgba(151,187,205,0.5)", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] - }, { - label: 'Dataset 4', - backgroundColor: "rgba(151,187,205,0.5)", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] - }, { - label: 'Dataset 3', - backgroundColor: "rgba(151,187,205,0.5)", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }] }; window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx).Bar({ - data: barChartData, + data: barChartData, options: { responsive: true, hoverMode: 'label', diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 39482b640f2..32f67e8f43f 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -7,13 +7,20 @@ var defaultConfig = { + + stacked: false, + + hover: { + mode: "label" + }, + scales: { xAxes: [{ scaleType: "dataset", // scatter should not use a dataset axis display: true, position: "bottom", id: "x-axis-1", // need an ID so datasets can reference the scale - + // grid line settings gridLines: { show: true, @@ -46,7 +53,7 @@ display: true, position: "left", id: "y-axis-1", - + // grid line settings gridLines: { show: true, @@ -75,20 +82,6 @@ }], }, - bars: { - //Number - Pixel width of the bar border - borderWidth: 2, - - //Number - Spacing between each of the X value sets - valueSpacing: 5, - - //Number - Spacing between data sets within X values - datasetSpacing: 1, - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - }; @@ -96,22 +89,23 @@ name: "Bar", defaults: defaultConfig, initialize: function() { - // Events - helpers.bindEvents(this, this.options.events, this.onHover); - //Declare the extension of the default point, to cater for the options passed in to the constructor - this.BarClass = Chart.Rectangle.extend({ - ctx: this.chart.ctx, - }); + var _this = this; + + // Events + helpers.bindEvents(this, this.options.events, this.events); //Create a new bar for each piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.metaData = []; helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new this.BarClass()); + dataset.metaData.push(new Chart.Rectangle({ + _chart: this.chart, + _datasetIndex: datasetIndex, + })); }, this); - // The bar chart only supports a single x axis because the x axis is always a dataset axis + // The bar chart only supports a single x axis because the x axis is always a dataset axis dataset.xAxisID = this.options.scales.xAxes[0].id; if (!dataset.yAxisID) { @@ -121,24 +115,6 @@ // Build and fit the scale. Needs to happen after the axis IDs have been set this.buildScale(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Set defaults for bars - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(bar, { - base: yScale.getPixelForValue(0), - width: xScale.calculateBarWidth(this.data.datasets.length), - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), - _datasetIndex: datasetIndex, - _index: index, - }); - // Copy to view model - bar.save(); - }, this); // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ @@ -150,162 +126,48 @@ // Update the chart with the latest data. this.update(); }, - onHover: function(e) { - - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); - } - - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.8).darken(0.2).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.8).darken(0.2).rgbString(); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.8).darken(0.2).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.8).darken(0.2).rgbString(); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); - } - } - - - this.tooltip.pivot(); - - // Hover animations - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, update: function() { // Update the scale sizes Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - this.eachElement(function(bar, index, dataset, datasetIndex) { - helpers.extend(bar, { - value: this.data.datasets[datasetIndex].data[index], - }); - - bar.pivot(); - }, this); - + // Update the points this.eachElement(function(bar, index, dataset, datasetIndex) { var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; helpers.extend(bar, { - base: yScale.calculateBarBase(datasetIndex, index), - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), - width: xScale.calculateBarWidth(this.data.datasets.length), - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - borderColor: this.data.datasets[datasetIndex].borderColor, - borderWidth: this.data.datasets[datasetIndex].borderWidth, - backgroundColor: this.data.datasets[datasetIndex].backgroundColor, + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, _datasetIndex: datasetIndex, _index: index, - }); + // Desired view properties + _model: { + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScale.calculateBarY(datasetIndex, index), + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), + + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + }, + }); bar.pivot(); }, this); + this.render(); }, buildScale: function(labels) { - var self = this; + var self = this; // Function to determine the range of all the var calculateYRange = function() { @@ -338,6 +200,8 @@ var values = positiveValues.concat(negativeValues); this.min = helpers.min(values); this.max = helpers.max(values); + + console.log(this.min, this.max); } else { helpers.each(self.data.datasets, function(dataset) { if (dataset.yAxisID === this.id) { @@ -347,7 +211,7 @@ } else if (value < this.min) { this.min = value; } - + if (this.max === null) { this.max = value; } else if (value > this.max) { @@ -374,11 +238,11 @@ this.max = this.labels.length; }, calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.bars.valueSpacing); + return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.elements.bar.valueSpacing); }, calculateBarWidth: function(datasetCount) { //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.bars.datasetSpacing); + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.elements.bar.datasetSpacing); if (self.options.stacked) { return baseWidth; @@ -394,7 +258,7 @@ return xAbsolute + barWidth / 2; } - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.bars.datasetSpacing) + barWidth / 2; + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.elements.bar.datasetSpacing) + barWidth / 2; }, }); this.scales[xScale.id] = xScale; @@ -410,22 +274,25 @@ var base = 0; if (self.options.stacked) { - var bar = self.data.datasets[datasetIndex].metaData[index]; - if (bar.value < 0) { + var value = self.data.datasets[datasetIndex].data[index]; + + if (value < 0) { for (var i = 0; i < datasetIndex; i++) { if (self.data.datasets[i].yAxisID === this.id) { - base += self.data.datasets[i].metaData[index].value < base ? self.data.datasets[i].metaData[index].value : 0; + base += self.data.datasets[i].data[index] < 0 ? self.data.datasets[i].data[index] : 0; } } } else { - for (var i = 0; i < datasetIndex; i++) { - if (self.data.datasets[i].yAxisID === this.id) { - base += self.data.datasets[i].metaData[index].value > base ? self.data.datasets[i].metaData[index].value : 0; + for (var j = 0; j < datasetIndex; j++) { + if (self.data.datasets[j].yAxisID === this.id) { + base += self.data.datasets[j].data[index] > 0 ? self.data.datasets[j].data[index] : 0; } } } + console.log(base); + return this.getPixelForValue(base); } @@ -442,7 +309,9 @@ return base; }, - calculateBarY: function(datasets, datasetIndex, barIndex, value) { + calculateBarY: function(datasetIndex, index) { + + var value = self.data.datasets[datasetIndex].data[index]; if (self.options.stacked) { @@ -450,10 +319,10 @@ sumNeg = 0; for (var i = 0; i < datasetIndex; i++) { - if (datasets[i].metaData[barIndex].value < 0) { - sumNeg += datasets[i].metaData[barIndex].value || 0; + if (self.data.datasets[i].data[index] < 0) { + sumNeg += self.data.datasets[i].data[index] || 0; } else { - sumPos += datasets[i].metaData[barIndex].value || 0; + sumPos += self.data.datasets[i].data[index] || 0; } } @@ -463,52 +332,27 @@ return this.getPixelForValue(sumPos + value); } - return this.getPixelForValue(0); + return this.getPixelForValue(value); } var offset = 0; - for (i = datasetIndex; i < datasets.length; i++) { - if (i === datasetIndex && value) { + for (j = datasetIndex; j < datasets.length; j++) { + if (j === datasetIndex && value) { offset += value; } else { - offset = offset + (datasets[i].metaData[barIndex].value); + offset = offset + value; } } return this.getPixelForValue(value); }, - - calculateBaseHeight: function() { - return (this.getPixelForValue(1) - this.getPixelForValue(0)); - }, id: yAxisOptions.id, }); this.scales[scale.id] = scale; }, this); }, - // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function - redraw: function() { - this.eachElement(function(element, index, datasetIndex) { - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - var base = yScale.getPixelForValue(yScale.min); - - if (yScale.min <= 0 && yScale.max >= 0) { - // have a 0 point - base = yScale.getPixelForValue(0); - } else if (yScale.min < 0 && yScale.max < 0) { - // all megative - base = yScale.getPixelForValue(yScale.max); - } - - helpers.extend(element, { - y: base, - base: base - }); - }); - this.render(); - }, draw: function(ease) { var easingDecimal = ease || 1; @@ -526,7 +370,149 @@ // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); - } + }, + events: function(e) { + + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + this.tooltip.pivot(); + + // Hover animations + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, }); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index a38ffdc44d3..ca8ec0105b3 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -65,6 +65,7 @@ events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], hover: { onHover: null, + mode: 'single', animationDuration: 400, }, onClick: null, @@ -127,6 +128,13 @@ hoverRadius: 4, hoverBorderWidth: 2, }, + bar: { + backgroundColor: defaultColor, + borderWidth: 2, + borderColor: defaultColor, + valueSpacing: 5, + datasetSpacing: 1, + }, } }, }; @@ -1462,9 +1470,9 @@ draw: function() { var vm = this._view; + var ctx = this._chart.ctx; - var ctx = this.ctx, - halfWidth = vm.width / 2, + var halfWidth = vm.width / 2, leftX = vm.x - halfWidth, rightX = vm.x + halfWidth, top = vm.base - (vm.base - vm.y), From 9b2d2efc7ada2fd66d1779509eb7a6a1f5763b92 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 2 Jun 2015 18:54:18 -0400 Subject: [PATCH 075/424] Animation on refresh --- src/Chart.Core.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index a38ffdc44d3..8b7886f8719 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1131,14 +1131,14 @@ initialize: function() {}, pivot: function() { if (!this._view) { - this._view = clone(this._model); + this._view = {}; } this._start = clone(this._view); return this; }, transition: function(ease) { if (!this._view) { - this._view = clone(this._model); + this._view = {}; } if (!this._start) { this.pivot(); @@ -1152,7 +1152,11 @@ // Init if doesn't exist else if (!this._view[key]) { - this._view[key] = value || null; + if (typeof value === 'number') { + this._view[key] = value * ease; + } else { + this._view[key] = value || null; + } } // No unnecessary computations @@ -1171,7 +1175,8 @@ } // Number transitions else if (typeof value === 'number') { - this._view[key] = ((this._model[key] - this._start[key]) * ease) + this._start[key]; + var startVal = this._start[key] !== undefined ? this._start[key] : 0; + this._view[key] = ((this._model[key] - startVal) * ease) + startVal; } // Everything else else { From 4ded634d75cc428ef7d7ca78f774c64d76d76e1e Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 2 Jun 2015 17:13:47 -0600 Subject: [PATCH 076/424] no logging --- src/Chart.Bar.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 32f67e8f43f..b33ef2758e3 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -201,7 +201,6 @@ this.min = helpers.min(values); this.max = helpers.max(values); - console.log(this.min, this.max); } else { helpers.each(self.data.datasets, function(dataset) { if (dataset.yAxisID === this.id) { @@ -291,8 +290,6 @@ } } - console.log(base); - return this.getPixelForValue(base); } From 02d7442e4f20ba04870441453b2758be1692fe2f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 2 Jun 2015 17:29:17 -0600 Subject: [PATCH 077/424] !bar borderWidth --- src/Chart.Bar.js | 1 + src/Chart.Core.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index b33ef2758e3..c3b614f0a68 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -102,6 +102,7 @@ dataset.metaData.push(new Chart.Rectangle({ _chart: this.chart, _datasetIndex: datasetIndex, + _index: index, })); }, this); diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8bcd18ab3ff..6cfa98ce3a9 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -130,7 +130,7 @@ }, bar: { backgroundColor: defaultColor, - borderWidth: 2, + borderWidth: 0, borderColor: defaultColor, valueSpacing: 5, datasetSpacing: 1, @@ -1474,8 +1474,8 @@ Chart.Rectangle = Chart.Element.extend({ draw: function() { - var vm = this._view; var ctx = this._chart.ctx; + var vm = this._view; var halfWidth = vm.width / 2, leftX = vm.x - halfWidth, From f44dd06826dda929d2f1b5505bb53bf1c9828b16 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 2 Jun 2015 20:06:50 -0400 Subject: [PATCH 078/424] Better animations when chart is first initialized. --- src/Chart.Core.js | 4 +-- src/Chart.Line.js | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8bcd18ab3ff..90a0425bf40 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1139,14 +1139,14 @@ initialize: function() {}, pivot: function() { if (!this._view) { - this._view = {}; + this._view = clone(this._model); } this._start = clone(this._view); return this; }, transition: function(ease) { if (!this._view) { - this._view = {}; + this._view = clone(this._model); } if (!this._start) { this.pivot(); diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 8ee9859875f..a7deb1c329c 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -136,6 +136,12 @@ _options: this.options, }, this); + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + // Update that shiz this.update(); }, @@ -145,6 +151,86 @@ previousPoint: function(collection, index) { return collection[index - 1] || collection[index]; }, + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max <0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScalePoint, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + }, update: function() { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); From b22e1e3e9c67fbe3522cde4cae9555e998c8b010 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 2 Jun 2015 20:44:24 -0400 Subject: [PATCH 079/424] Update scatter chart. Still need to get tooltips working --- src/Chart.Scatter.js | 531 +++++++++++++++++++++++++------------------ 1 file changed, 307 insertions(+), 224 deletions(-) diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 348e3defba4..071ff4dbdad 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -77,27 +77,12 @@ }], }, - //Number - Tension of the bezier curve between points - tension: 0.4, - - //Number - Radius of each point dot in pixels - pointRadius: 4, - - //Number - Pixel width of point dot border - pointBorderWidth: 1, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHoverRadius: 20, - - //Number - Pixel width of dataset border - borderWidth: 2, - //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", tooltips: { - template: "(<%= dataX %>, <%= dataY %>)", - multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= dataX %>, <%= dataY %>)", + template: "(<%= value.x %>, <%= value.y %>)", + multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", }, }; @@ -108,30 +93,29 @@ defaults: defaultConfig, initialize: function() { //Custom Point Defaults - this.PointClass = Chart.Point.extend({ - _chart: this.chart, - offsetGridLines: this.options.offsetGridLines, - borderWidth: this.options.pointBorderWidth, - radius: this.options.pointRadius, - hoverRadius: this.options.pointHoverRadius, - }); - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Build Scale - this.buildScale(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - //Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaDataset = new Chart.Line(); + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new this.PointClass()); + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + }, this); - // Make sure each dataset is bound to an x and a y axis + // The line chart onlty supports a single x axis because the x axis is always a dataset axis if (!dataset.xAxisID) { dataset.xAxisID = this.options.scales.xAxes[0].id; } @@ -139,42 +123,11 @@ if (!dataset.yAxisID) { dataset.yAxisID = this.options.scales.yAxes[0].id; } - }, this); - // Set defaults for lines - this.eachDataset(function(dataset, datasetIndex) { - dataset = helpers.merge(this.options, dataset); - helpers.extend(dataset.metaDataset, { - _points: dataset.metaData, - _datasetIndex: datasetIndex, - _chart: this.chart, - }); - // Copy to view model - dataset.metaDataset.save(); }, this); - // Set defaults for points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - - helpers.extend(point, { - x: xScale.getPixelForValue(index), - y: this.chartArea.bottom, - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart - }); - - // Default bezier control points - helpers.extend(point, { - controlPointPreviousX: this.previousPoint(dataset, index).x, - controlPointPreviousY: this.nextPoint(dataset, index).y, - controlPointNextX: this.previousPoint(dataset, index).x, - controlPointNextY: this.nextPoint(dataset, index).y, - }); - // Copy to view model - point.save(); - }, this); + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ @@ -183,149 +136,131 @@ _options: this.options, }, this); + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz this.update(); }, nextPoint: function(collection, index) { - return collection[index - 1] || collection[index]; + return collection[index + 1] || collection[index]; }, previousPoint: function(collection, index) { - return collection[index + 1] || collection[index]; + return collection[index - 1] || collection[index]; }, - events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - this.lastActive = this.lastActive || []; + var yScalePoint; - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); } - }.call(this); - - // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); - } - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor; - this.lastActive[0].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBackgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].pointBorderColor; - this.lastActive[i].borderWidth = this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderWidth = this.data.datasets[this.active[0]._datasetIndex].borderWidth + 10; - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderWidth = this.data.datasets[this.active[i]._datasetIndex].borderWidth + 2; - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } + // Desired view properties + _model: { + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), // value not used in dataset scale, but we want a consistent API between scales + y: yScalePoint, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); - // Built in Tooltips - if (this.options.tooltips.enabled) { + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); - // The usual updates - this.tooltip.initialize(); + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; - // Active - if (this.active.length) { - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, - }); + // Prevent the bezier going outside of the bounds of the graph - this.tooltip.update(); + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; } else { - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + point._model.controlPointNextY = controlPoints.next.y; } - } - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; } - } - - // Remember Last Active - this.lastActive = this.active; - return this; + // Now pivot the point for animation + point.pivot(); + }, this); }, update: function() { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines this.eachDataset(function(dataset, datasetIndex) { + var yScale = this.scales[dataset.yAxisID]; + helpers.extend(dataset.metaDataset, { - backgroundColor: dataset.backgroundColor || this.options.backgroundColor, - borderWidth: dataset.borderWidth || this.options.borderWidth, - borderColor: dataset.borderColor || this.options.borderColor, - tension: dataset.tension || this.options.tension, - scaleTop: this.chartArea.top, - scaleBottom: this.chartArea.bottom, - _points: dataset.metaData, + // Utility + _scale: yScale, _datasetIndex: datasetIndex, + // Data + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: yScale.getPixelForValue(0), + }, }); + dataset.metaDataset.pivot(); }); @@ -335,58 +270,65 @@ var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; helpers.extend(point, { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), - y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), - dataX: this.data.datasets[datasetIndex].data[index].x, - dataY: this.data.datasets[datasetIndex].data[index].y, - label: '', // so that the multitooltip looks ok - value: this.data.datasets[datasetIndex].data[index].y, // for legacy reasons - datasetLabel: this.data.datasets[datasetIndex].label, - // Appearance - hoverBackgroundColor: this.data.datasets[datasetIndex].pointHoverBackgroundColor || this.options.pointHoverBackgroundColor, - hoverBorderColor: this.data.datasets[datasetIndex].pointHoverBorderColor || this.options.pointHoverBorderColor, - hoverRadius: this.data.datasets[datasetIndex].pointHoverRadius || this.options.pointHoverRadius, - radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, - borderColor: this.data.datasets[datasetIndex].pointBorderColor || this.options.pointBorderColor, - backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, - tension: this.data.datasets[datasetIndex].metaDataset.tension, + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, _datasetIndex: datasetIndex, _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), + y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, }); }, this); + // Update control points for the bezier curve this.eachElement(function(point, index, dataset, datasetIndex) { var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index), - point, - this.nextPoint(dataset, index), - point.tension + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension ); - point.controlPointPreviousX = controlPoints.previous.x; - point.controlPointNextX = controlPoints.next.x; + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; // Prevent the bezier going outside of the bounds of the graph // Cap puter bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chartArea.bottom) { - point.controlPointNextY = this.chartArea.bottom; + point._model.controlPointNextY = this.chartArea.bottom; } else if (controlPoints.next.y < this.chartArea.top) { - point.controlPointNextY = this.chartArea.top; + point._model.controlPointNextY = this.chartArea.top; } else { - point.controlPointNextY = controlPoints.next.y; + point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds if (controlPoints.previous.y > this.chartArea.bottom) { - point.controlPointPreviousY = this.chartArea.bottom; + point._model.controlPointPreviousY = this.chartArea.bottom; } else if (controlPoints.previous.y < this.chartArea.top) { - point.controlPointPreviousY = this.chartArea.top; + point._model.controlPointPreviousY = this.chartArea.top; } else { - point.controlPointPreviousY = controlPoints.previous.y; + point._model.controlPointPreviousY = controlPoints.previous.y; } + // Now pivot the point for animation point.pivot(); }, this); @@ -465,25 +407,28 @@ options: yAxisOptions, calculateRange: calculateYRange, id: yAxisOptions.id, + getPointPixelForValue: function(value, index, datasetIndex) { + return this.getPixelForValue(value); + } }); this.scales[scale.id] = scale; }, this); - }, - redraw: function() { - }, draw: function(ease) { - var easingDecimal = ease || 1; this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - this.eachDataset(function(dataset, datasetIndex) { + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + // Transition Point Locations helpers.each(dataset.metaData, function(point, index) { point.transition(easingDecimal); @@ -496,11 +441,149 @@ helpers.each(dataset.metaData, function(point) { point.draw(); }); - }, this); + } // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); - } + }, + events: function(e) { + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, }); From 42e2c237d4e17db68929e47c9146ba023dca69ad Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 2 Jun 2015 20:48:26 -0400 Subject: [PATCH 080/424] Bind events in scatter chart --- src/Chart.Scatter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 071ff4dbdad..34e120a5f5d 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -92,6 +92,10 @@ name: "Scatter", defaults: defaultConfig, initialize: function() { + + // Events + helpers.bindEvents(this, this.options.events, this.events); + //Custom Point Defaults helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.metaDataset = new Chart.Line({ From 8d1a857e75ac6b27d39dfb957b530f6e84af9037 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 2 Jun 2015 20:50:36 -0400 Subject: [PATCH 081/424] Scatter tooltips --- src/Chart.Scatter.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 34e120a5f5d..23f30e9fa02 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -547,17 +547,16 @@ // Active if (this.active.length) { + this.tooltip._model.opacity = 1; + helpers.extend(this.tooltip, { - opacity: 1, _active: this.active, }); this.tooltip.update(); } else { // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.tooltip._model.opacity = 0; } } From 37cfbdb8028b24715589620e9e1ed191486f410a Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 07:57:50 -0400 Subject: [PATCH 082/424] Fix an issue with bar charts that are not stacked --- src/Chart.Bar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index c3b614f0a68..77e3de3548a 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -335,7 +335,7 @@ var offset = 0; - for (j = datasetIndex; j < datasets.length; j++) { + for (var j = datasetIndex; j < self.data.datasets.length; j++) { if (j === datasetIndex && value) { offset += value; } else { From 06d55e3501c582579b1e9afab92e39360ffab070 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 08:02:21 -0400 Subject: [PATCH 083/424] Get closer to having radar charts work. Some issues with the line & point drawing code. --- src/Chart.Radar.js | 458 +++++++++++++++++++++------------------------ 1 file changed, 213 insertions(+), 245 deletions(-) diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index 4eee2439c03..dffaa2a4738 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -73,47 +73,10 @@ }, }, - line: { - - //Boolean - Whether to show a dot for each point - show: true, - - //Number - Pixel width of dot border - borderWidth: 1, - - backgroundColor: Chart.defaults.global.defaultColor, - - borderColor: Chart.defaults.global.defaultColor, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn - hitRadius: 20, - - //Number - Tension of the bezier curve between points. Use 0 to turn off bezier tension - tension: 0.4, - }, - - point: { - //Boolean - Whether to show a dot for each point - show: true, - - //Number - Radius of each dot in pixels - radius: 3, - - //Number - Pixel width of dot border - borderWidth: 1, - - //Number - Pixel width of on hover - hoverRadius: 5, - - //Number - Pixel width of dot border on hover - hoverBorderWidth: 2, - - backgroundColor: Chart.defaults.global.defaultColor, - - borderColor: Chart.defaults.global.defaultColor, - - //Number - amount extra to add to the radius to cater for hit detection outside the drawn - hitRadius: 20, + elements: { + line: { + tension: 0, // no bezier in radar + } }, //String - A legend template @@ -122,73 +85,37 @@ }, initialize: function() { - - this.buildScale(this.data); - - - // Events helpers.bindEvents(this, this.options.events, this.events); - var _this = this; - - //Create a new line and its points for each dataset and piece of data + // Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaDataset = new Chart.Line(); - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point()); - }, this); - - // The line chart only supports a single x axis because the x axis is always a dataset axis - }, this); - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Set defaults for lines - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.extend(dataset.metaDataset, { - _points: dataset.metaData, - _datasetIndex: datasetIndex, + dataset.metaDataset = new Chart.Line({ _chart: this.chart, - loop: true - }); - // Fill in dataset defaults from options - helpers.extend(dataset, helpers.merge(this.options, dataset)); - // Copy to view modele - dataset.metaDataset.save(); - }, this); - - // Set defaults for points - this.eachElement(function(point, index, dataset, datasetIndex) { - - helpers.extend(point, { _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - display: this.options.pointDot, - x: this.scale.xCenter, - y: this.scale.yCenter, - }); - - // Default bezier control points - helpers.extend(point, { - controlPointPreviousX: this.scale.xCenter, - controlPointPreviousY: this.scale.yCenter, - controlPointNextX: this.scale.xCenter, - controlPointNextY: this.scale.yCenter, + _points: dataset.metaData, + loop: true, }); - // Copy to view model - point.save(); - - }, this); - + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + }, this); + }, this); + // Build the scale. + this.buildScale(); // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ @@ -197,114 +124,120 @@ _options: this.options, }, this); + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + // Reset so that we animation from the baseline + this.resetElements(); - - + // Update that shiz this.update(); }, - - /*getPointsAtEvent: function(evt) { - var mousePosition = helpers.getRelativePosition(evt), - fromCenter = helpers.getAngleFromPoint({ - x: this.scale.xCenter, - y: this.scale.yCenter - }, mousePosition); - - var anglePerIndex = (Math.PI * 2) / this.scale.valuesCount, - pointIndex = Math.round((fromCenter.angle - Math.PI * 1.5) / anglePerIndex), - activePointsCollection = []; - - // If we're at the top, make the pointIndex 0 to get the first of the array. - if (pointIndex >= this.scale.valuesCount || pointIndex < 0) { - pointIndex = 0; - } - - if (fromCenter.distance <= this.scale.drawingArea) { - helpers.each(this.data.datasets, function(dataset) { - activePointsCollection.push(dataset.points[pointIndex]); - }); - } - - return activePointsCollection; - },*/ nextPoint: function(collection, index) { - return collection[index - 1] || collection[collection.length - 1]; + return collection[index + 1] || collection[collection.length - 1]; }, previousPoint: function(collection, index) { - return collection[index + 1] || collection[0]; + return collection[index - 1] || collection[0]; }, - buildScale: function() { - var self = this; + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, - var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); - this.scale = new ScaleConstructor({ - options: this.options.scale, - height: this.chart.height, - width: this.chart.width, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - labels: this.data.labels, - valuesCount: this.data.datasets[0].data.length, - calculateRange: function() { - this.min = null; - this.max = null; + // Desired view properties + _model: { + x: this.scale.xCenter, + y: this.scale.yCenter, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; } - }); - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); }, update: function() { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines this.eachDataset(function(dataset, datasetIndex) { - helpers.extend(dataset.metaDataset, { // Utility _datasetIndex: datasetIndex, - + // Data - _points: dataset.metaData, - - // Geometry - scaleTop: this.scale.top, - scaleBottom: this.scale.bottom, - scaleZero: this.scale.getPointPosition(0), - - // Appearance - tension: dataset.tension || this.options.line.tension, - backgroundColor: dataset.backgroundColor || this.options.backgroundColor, - borderWidth: dataset.borderWidth || this.options.borderWidth, - borderColor: dataset.borderColor || this.options.borderColor, + _children: dataset.metaData, + + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + + // Scale + scaleTop: this.scale.top, + scaleBottom: this.scale.bottom, + scaleZero: this.scale.getPointPosition(0), + }, }); + dataset.metaDataset.pivot(); - }, this); + }); // Update the points this.eachElement(function(point, index, dataset, datasetIndex) { - var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); helpers.extend(point, { @@ -313,76 +246,119 @@ _datasetIndex: datasetIndex, _index: index, - // Data - label: this.data.labels[index], - value: this.data.datasets[datasetIndex].data[index], - datasetLabel: this.data.datasets[datasetIndex].label, - - // Geometry - offsetGridLines: this.options.offsetGridLines, - x: pointPosition.x, - y: pointPosition.y, - tension: this.data.datasets[datasetIndex].metaDataset.tension, - - // Appearnce - radius: this.data.datasets[datasetIndex].pointRadius || this.options.point.radius, - backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.point.backgroundColor, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointsborderWidth, - - // Tooltip - hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.point.hitRadius, + // Desired view properties + _model: { + x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: pointPosition.y, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, }); - }, this); + // Update control points for the bezier curve this.eachElement(function(point, index, dataset, datasetIndex) { var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index), - point, - this.nextPoint(dataset, index), - point.tension + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension ); - point.controlPointPreviousX = controlPoints.previous.x; - point.controlPointNextX = controlPoints.next.x; + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; // Prevent the bezier going outside of the bounds of the graph // Cap puter bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chartArea.bottom) { - point.controlPointNextY = this.chartArea.bottom; + point._model.controlPointNextY = this.chartArea.bottom; } else if (controlPoints.next.y < this.chartArea.top) { - point.controlPointNextY = this.chartArea.top; + point._model.controlPointNextY = this.chartArea.top; } else { - point.controlPointNextY = controlPoints.next.y; + point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds if (controlPoints.previous.y > this.chartArea.bottom) { - point.controlPointPreviousY = this.chartArea.bottom; + point._model.controlPointPreviousY = this.chartArea.bottom; } else if (controlPoints.previous.y < this.chartArea.top) { - point.controlPointPreviousY = this.chartArea.top; + point._model.controlPointPreviousY = this.chartArea.top; } else { - point.controlPointPreviousY = controlPoints.previous.y; + point._model.controlPointPreviousY = controlPoints.previous.y; } + // Now pivot the point for animation point.pivot(); }, this); this.render(); }, - draw: function(ease) { + buildScale: function() { + var self = this; + var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleConstructor({ + options: this.options.scale, + height: this.chart.height, + width: this.chart.width, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + labels: this.data.labels, + valuesCount: this.data.datasets[0].data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }); + + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + }, + draw: function(ease) { var easingDecimal = ease || 1; this.clear(); + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); // reverse for-loop for proper stacking for (var i = this.data.datasets.length - 1; i >= 0; i--) { var dataset = this.data.datasets[i]; - var datasetIndex = i; // Transition Point Locations helpers.each(dataset.metaData, function(point, index) { @@ -398,12 +374,8 @@ }); } - // Draw all the scales - this.scale.draw(this.chartArea); - // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); - }, events: function(e) { @@ -429,8 +401,8 @@ }.call(this); // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); } if (e.type == 'mouseup' || e.type == 'click') { @@ -440,25 +412,28 @@ } var dataset; + var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; - this.lastActive[0].radius = dataset.pointRadius; - this.lastActive[0].backgroundColor = dataset.pointBackgroundColor; - this.lastActive[0].borderColor = dataset.pointBorderColor; - this.lastActive[0].borderWidth = dataset.pointBorderWidth; + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; - this.lastActive[i].radius = dataset.pointRadius; - this.lastActive[i].backgroundColor = dataset.pointBackgroundColor; - this.lastActive[i].borderColor = dataset.pointBorderColor; - this.lastActive[i].borderWidth = dataset.pointBorderWidth; + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); } break; case 'dataset': @@ -473,20 +448,22 @@ switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; - this.active[0].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; - this.active[0].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; - this.active[i].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; - this.active[i].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); } break; case 'dataset': @@ -496,7 +473,6 @@ } } - // Built in Tooltips if (this.options.tooltips.enabled) { @@ -505,21 +481,19 @@ // Active if (this.active.length) { + this.tooltip._model.opacity = 1; + helpers.extend(this.tooltip, { - opacity: 1, _active: this.active, }); this.tooltip.update(); } else { // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.tooltip._model.opacity = 0; } } - // Hover animations this.tooltip.pivot(); @@ -538,7 +512,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hoverAnimationDuration); + this.render(this.options.hover.animationDuration); } } @@ -546,11 +520,5 @@ this.lastActive = this.active; return this; }, - }); - - - - - }).call(this); From 7e791e02f2bf4527090c81d21e83a5faf449c4a0 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 12:05:04 -0600 Subject: [PATCH 084/424] Radar Chart skipNull & bezier fixes --- samples/radar.html | 4 +- src/Chart.Core.js | 105 ++++++++++++++++++++++++--------------------- src/Chart.Radar.js | 44 ++++++------------- 3 files changed, 70 insertions(+), 83 deletions(-) diff --git a/samples/radar.html b/samples/radar.html index 4a5c3f05b7e..199791904d1 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -27,14 +27,14 @@ label: "My First dataset", backgroundColor: "rgba(220,220,220,0.2)", pointBackgroundColor: "rgba(220,220,220,1)", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + data: [null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }, { label: "My Second dataset", backgroundColor: "rgba(151,187,205,0.2)", pointBackgroundColor: "rgba(151,187,205,1)", hoverPointBackgroundColor: "#fff", pointHighlightStroke: "rgba(151,187,205,1)", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + data: [null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }] }, options: { diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 221086b7600..3e5304d299d 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1274,32 +1274,32 @@ // Draw the background first (so the border is always on top) helpers.each(this._children, function(point, index) { - var scaleZero = point._yScale.getPointPixelForValue(0); + var previous = this.previousPoint(point, this._children, index); + var next = this.nextPoint(point, this._children, index); // First point only if (index === 0) { - if (point._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, scaleZero); - } else { - ctx.moveTo(point._view.x, point._view.y); - } + ctx.moveTo(point._view.x, point._view.y); return; } // Start Skip and drag along scale baseline - if (point._view.skip && vm.skipNull) { - ctx.lineTo(this.previousPoint(point, this._children, index)._view.x, scaleZero); - ctx.moveTo(this.nextPoint(point, this._children, index)._view.x, scaleZero); + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.lineTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); } // End Skip Stright line from the base line - else if (this.previousPoint(point, this._children, index)._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, scaleZero); + else if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); ctx.lineTo(point._view.x, point._view.y); } + + if (previous._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, point._view.y); + } // Normal Bezier Curve else { - if (vm._tension > 0 || 1) { - var previous = this.previousPoint(point, this._children, index); + if (vm.tension > 0) { ctx.bezierCurveTo( previous._view.controlPointNextX, previous._view.controlPointNextY, @@ -1315,8 +1315,8 @@ }, this); // For radial scales, loop back around to the first point - if (vm.loop) { - if (vm._tension > 0 || 1) { + if (this._loop) { + if (vm.tension > 0 && !first._view.skip) { ctx.bezierCurveTo( last._view.controlPointNextX, @@ -1348,46 +1348,49 @@ ctx.beginPath(); helpers.each(this._children, function(point, index) { - var scaleZero = point._yScale.getPointPixelForValue(0); + var previous = this.previousPoint(point, this._children, index); + var next = this.nextPoint(point, this._children, index); + // First point only if (index === 0) { - if (point._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, scaleZero); - } else { - ctx.moveTo(point._view.x, point._view.y); - } + ctx.moveTo(point._view.x, point._view.y); return; } // Start Skip and drag along scale baseline - if (point._view.skip && vm.skipNull) { - ctx.moveTo(this.previousPoint(point, this._children, index)._view.x, scaleZero); - ctx.moveTo(this.nextPoint(point, this._children, index)._view.x, scaleZero); + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); + return; } // End Skip Stright line from the base line - else if (this.previousPoint(point, this._children, index)._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, scaleZero); + if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); + ctx.moveTo(point._view.x, point._view.y); + return; + } + + if (previous._view.skip && vm.skipNull) { ctx.moveTo(point._view.x, point._view.y); + return; } // Normal Bezier Curve - else { - if (vm._tension > 0 || 1) { - var previous = this.previousPoint(point, this._children, index); - ctx.bezierCurveTo( - previous._view.controlPointNextX, - previous._view.controlPointNextY, - point._view.controlPointPreviousX, - point._view.controlPointPreviousY, - point._view.x, - point._view.y - ); - } else { - ctx.lineTo(point._view.x, point._view.y); - } + if (vm.tension > 0) { + ctx.bezierCurveTo( + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y + ); + } else { + ctx.lineTo(point._view.x, point._view.y); } }, this); - if (vm.loop) { - if (vm._tension > 0 || 1) { + + if (this._loop && !first._view.skip) { + if (vm.tension > 0) { ctx.bezierCurveTo( last._view.controlPointNextX, @@ -1406,15 +1409,17 @@ ctx.stroke(); }, - previousPoint: function(point, collection, index) { - return helpers.findPreviousWhere(collection, function() { - return true; - }, index) || point; - }, nextPoint: function(point, collection, index) { - return helpers.findNextWhere(collection, function() { - return true; - }, index) || point; + if (this.loop) { + return collection[index + 1] || collection[0]; + } + return collection[index + 1] || collection[collection.length - 1]; + }, + previousPoint: function(point, collection, index) { + if (this.loop) { + return collection[index - 1] || collection[collection.length - 1]; + } + return collection[index - 1] || collection[0]; }, }); diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index dffaa2a4738..b8f0436b5f0 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -95,7 +95,7 @@ _chart: this.chart, _datasetIndex: datasetIndex, _points: dataset.metaData, - loop: true, + _loop: true }); dataset.metaData = []; @@ -134,12 +134,13 @@ this.update(); }, nextPoint: function(collection, index) { - return collection[index + 1] || collection[collection.length - 1]; + return collection[index + 1] || collection[0]; }, previousPoint: function(collection, index) { - return collection[index - 1] || collection[0]; + return collection[index - 1] || collection[collection.length - 1]; }, resetElements: function() { + // Update the points this.eachElement(function(point, index, dataset, datasetIndex) { helpers.extend(point, { @@ -147,6 +148,7 @@ _chart: this.chart, _datasetIndex: datasetIndex, _index: index, + _scale: this.scale, // Desired view properties _model: { @@ -176,28 +178,10 @@ point._model.tension ); - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } + point._model.controlPointPreviousX = this.scale.xCenter; + point._model.controlPointPreviousY = this.scale.yCenter; + point._model.controlPointNextX = this.scale.xCenter; + point._model.controlPointNextY = this.scale.yCenter; // Now pivot the point for animation point.pivot(); @@ -211,10 +195,10 @@ helpers.extend(dataset.metaDataset, { // Utility _datasetIndex: datasetIndex, - + // Data _children: dataset.metaData, - + // Model _model: { // Appearance @@ -225,7 +209,7 @@ fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - + // Scale scaleTop: this.scale.top, scaleBottom: this.scale.bottom, @@ -351,9 +335,7 @@ this.clear(); // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); + this.scale.draw(this.chartArea); // reverse for-loop for proper stacking for (var i = this.data.datasets.length - 1; i >= 0; i--) { From 9be48a73ea2cde6e087401901e1befd44f17b73a Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 14:14:23 -0600 Subject: [PATCH 085/424] Pie Chart --- samples/bar.html | 4 - samples/doughnut.html | 92 ++++++++++------ samples/pie.html | 121 +++++++++++---------- src/Chart.Core.js | 5 + src/Chart.Doughnut.js | 240 +++++++++++++++++++----------------------- 5 files changed, 236 insertions(+), 226 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index 86169d164bc..117c375313e 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -43,10 +43,6 @@ data: barChartData, options: { responsive: true, - hoverMode: 'label', - scaleBeginAtZero: false, - hoverAnimationDuration: 400, - stacked: true, } }); }; diff --git a/samples/doughnut.html b/samples/doughnut.html index 4a5860e3093..9b856dbbb64 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -24,50 +24,80 @@ - - - -
    - -
    - - + + - var randomScalingFactor = function(){ return Math.round(Math.random()*100)}; - var randomColorFactor = function(){ return Math.round(Math.random()*255)}; + +
    + +
    + + + - - - - diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 3e5304d299d..9c91b862d85 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -135,6 +135,11 @@ valueSpacing: 5, datasetSpacing: 1, }, + slice: { + backgroundColor: defaultColor, + borderColor: "#fff", + borderWidth: 2, + }, } }, }; diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 48ac9e78773..553a831a24a 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -7,21 +7,6 @@ helpers = Chart.helpers; var defaultConfig = { - segments: { - //Boolean - Whether we should show a stroke on each segment - showStroke: true, - - //String - The colour of each segment stroke - strokeColor: "#fff", - - //Number - The width of each segment stroke - borderWidth: 2, - }, - - hover: { - // The duration of animations triggered by hover events - animationDuration: 400, - }, animation: { //Boolean - Whether we animate the rotation of the Doughnut @@ -32,10 +17,8 @@ }, //The percentage of the chart that we cut out of the middle. - cutoutPercentage: 50, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " + + cutoutPercentage: 1, }; @@ -47,40 +30,21 @@ //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() { - // Slice Type and defaults - this.Slice = Chart.Arc.extend({ - _chart: this.chart, - x: this.chart.width / 2, - y: this.chart.height / 2 - }); //Set up tooltip events on the chart - if (this.options.tooltips.enabled) { - helpers.bindEvents(this, this.options.events, this.onHover); - } - - // Create new slice for each piece of data - this.data.metaData = []; - helpers.each(this.data.data, function(slice, index) { - var metaSlice = new this.Slice(); - if (typeof slice == 'number') { - helpers.extend(metaSlice, { - value: slice - }); - } else { - helpers.extend(metaSlice, slice); - } - helpers.extend(metaSlice, { - startAngle: Math.PI * 1.5, - circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animation.animateScale) ? 0 : this.outerRadius, - innerRadius: (this.options.animation.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, - }); - if (!metaSlice.backgroundColor) { - slice.backgroundColor = 'hsl(' + (360 * index / this.data.data.length) + ', 100%, 50%)'; - } - metaSlice.save(); - this.data.metaData.push(metaSlice); + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); }, this); // Create tooltip instance exclusively for this chart with some defaults. @@ -90,9 +54,104 @@ _options: this.options, }, this); + // Update the chart with the latest data. this.update(); + + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + helpers.each(this.data.metaData, function(slice, index) { + if (slice.inRange(location.x, location.y)) elements.push(slice); + }, this); + return elements; + }, + calculateCircumference: function(dataset, value) { + if (dataset.total > 0) { + return (Math.PI * 2) * (value / dataset.total); + } else { + return 0; + } + }, + update: function() { + + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; + this.innerRadius = (this.outerRadius / 100) * this.options.cutoutPercentage; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; + + + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + + helpers.extend(slice, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + circumference: this.calculateCircumference(dataset, dataset.data[index]), + outerRadius: dataset.outerRadius, + innerRadius: dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + if (index === 0) { + slice._model.startAngle = Math.PI * 1.5; + } else { + slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; + } + + slice._model.endAngle = slice._model.startAngle + slice._model.circumference; + + + //Check to see if it's the last slice, if not get the next and update its start angle + if (index < dataset.data.length - 1) { + dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; + } + + slice.pivot(); + }, this); + + }, this); + + this.render(); + }, + draw: function(easeDecimal) { + easeDecimal = easeDecimal || 1; + this.clear(); + + this.eachElement(function(slice) { + slice.transition(easeDecimal).draw(); + }, this); + + this.tooltip.transition(easeDecimal).draw(); }, - onHover: function(e) { + events: function(e) { // If exiting chart if (e.type == 'mouseout') { @@ -169,83 +228,6 @@ return this; }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - helpers.each(this.data.metaData, function(slice, index) { - if (slice.inRange(location.x, location.y)) elements.push(slice); - }, this); - return elements; - }, - calculateCircumference: function(value) { - if (this.total > 0) { - return (Math.PI * 2) * (value / this.total); - } else { - return 0; - } - }, - update: function() { - - // Calc Total - this.total = 0; - helpers.each(this.data.data, function(slice) { - this.total += Math.abs(slice.value); - }, this); - - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segments.borderWidth / 2) / 2; - - // Map new data to data points - helpers.each(this.data.metaData, function(slice, index) { - - var datapoint = this.data.data[index]; - - helpers.extend(slice, { - _index: index, - x: this.chart.width / 2, - y: this.chart.height / 2, - value: datapoint.value, - label: datapoint.label, - circumference: this.calculateCircumference(datapoint.value), - outerRadius: this.outerRadius, - innerRadius: (this.outerRadius / 100) * this.options.cutoutPercentage, - - backgroundColor: datapoint.backgroundColor, - hoverBackgroundColor: datapoint.hoverBackgroundColor || datapoint.backgroundColor, - borderWidth: this.options.segments.borderWidth, - borderColor: this.options.segments.strokeColor, - }); - - helpers.extend(slice, { - endAngle: slice.startAngle + slice.circumference, - }); - - if (index === 0) { - slice.startAngle = Math.PI * 1.5; - } - - //Check to see if it's the last slice, if not get the next and update its start angle - if (index < this.data.data.length - 1) { - this.data.metaData[index + 1].startAngle = slice.endAngle; - } - - slice.pivot(); - - }, this); - - this.render(); - }, - draw: function(easeDecimal) { - easeDecimal = easeDecimal || 1; - this.clear(); - - helpers.each(this.data.metaData, function(slice, index) { - slice.transition(easeDecimal).draw(); - }, this); - - this.tooltip.transition(easeDecimal).draw(); - } }); Chart.types.Doughnut.extend({ From ecb1cde3fc11b304184cd08d2e683c911d40b179 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 14:17:10 -0600 Subject: [PATCH 086/424] Fix --- src/Chart.Doughnut.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 553a831a24a..a6db6cb82c3 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -18,7 +18,7 @@ //The percentage of the chart that we cut out of the middle. - cutoutPercentage: 1, + cutoutPercentage: 50, }; @@ -78,7 +78,7 @@ update: function() { this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; - this.innerRadius = (this.outerRadius / 100) * this.options.cutoutPercentage; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; From b3b58963298d0dfe0b8c6ac19fb12c47b4fd1df1 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 14:45:40 -0600 Subject: [PATCH 087/424] Polar Area --- samples/polar-area.html | 52 ++++++----- src/Chart.PolarArea.js | 201 ++++++++++++++++++++++++++-------------- 2 files changed, 161 insertions(+), 92 deletions(-) diff --git a/samples/polar-area.html b/samples/polar-area.html index c52dad57771..d77291a001e 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -22,27 +22,29 @@ var config = { data: { - data: [{ - value: randomScalingFactor(), - backgroundColor: "#F7464A", - label: "Red" - }, { - value: randomScalingFactor(), - backgroundColor: "#46BFBD", - label: "Green" - }, { - value: randomScalingFactor(), - backgroundColor: "#FDB45C", - label: "Yellow" - }, { - value: randomScalingFactor(), - backgroundColor: "#949FB1", - label: "Grey" - }, { - value: randomScalingFactor(), - backgroundColor: "#4D5360", - label: "Dark Grey" - }] + datasets: [{ + data: [ + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + ], + backgroundColor: [ + "#F7464A", + "#46BFBD", + "#FDB45C", + "#949FB1", + "#4D5360", + ], + labels: [ + "Red", + "Green", + "Yellow", + "Grey", + "Dark Grey" + ] + }], }, options: { responsive: true @@ -55,9 +57,11 @@ }; $('#randomizeData').click(function() { - $.each(polarData, function(i, piece) { - polarData[i].value = randomScalingFactor(); - polarData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + $.each(config.data.datasets, function(i, piece) { + $.each(piece.data, function(j, value) { + config.data.datasets[i].data[j] = randomScalingFactor(); + //config.data.datasets.backgroundColor[i] = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + }); }); window.myPolarArea.update(); }); diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index ae8e45d6811..e11f222ea2d 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -8,14 +8,6 @@ var defaultConfig = { - segment: { - //String - The colour of the border on each segment. - borderColor: "#fff", - - //Number - The width of the border value in pixels - borderWidth: 2, - }, - scale: { scaleType: "radialLinear", display: true, @@ -60,9 +52,6 @@ //Boolean - Whether to animate the rotation of the chart animateRotate: true, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " }; @@ -91,56 +80,40 @@ this.min = null; this.max = null; - helpers.each(self.data.data, function(data) { + helpers.each(self.data.datasets[0].data, function(value) { if (this.min === null) { - this.min = data.value; - } else if (data.value < this.min) { - this.min = data.value; + this.min = value; + } else if (value < this.min) { + this.min = value; } if (this.max === null) { - this.max = data.value; - } else if (data.value > this.max) { - this.max = data.value; + this.max = value; + } else if (value > this.max) { + this.max = value; } }, this); } }); - //Declare segment class as a chart instance specific class, so it can share props for this instance - this.Slice = Chart.Arc.extend(); + helpers.bindEvents(this, this.options.events, this.events); //Set up tooltip events on the chart - if (this.options.showTooltips) { - helpers.bindEvents(this, this.options.events, this.onHover); - } - - // Create new slice for each piece of data - this.data.metaData = []; - helpers.each(this.data.data, function(slice, index) { - var metaSlice = new this.Slice({ - _chart: this.chart, - innerRadius: 0, - startAngle: Math.PI * 1.5, - endAngle: Math.PI * 1.5, - x: this.chart.width / 2, - y: this.chart.height / 2 - }); - if (typeof slice == 'number') { - helpers.extend(metaSlice, { - value: slice - }); - } else { - helpers.extend(metaSlice, slice); - } - if (!metaSlice.backgroundColor) { - slice.backgroundColor = 'hsl(' + (360 * index / this.data.data.length) + ', 100%, 50%)'; - } - metaSlice.save(); - this.data.metaData.push(metaSlice); + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); }, this); - // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ _chart: this.chart, @@ -148,6 +121,7 @@ _options: this.options, }, this); + // Update the chart with the latest data. this.update(); }, @@ -165,36 +139,40 @@ this.scale.generateTicks(); this.scale.buildYLabels(); - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segment.borderWidth / 2) / 2; + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - var circumference = 1 / this.data.data.length * 2; + var circumference = 1 / this.data.datasets[0].data.length * 2; // Map new data to data points - helpers.each(this.data.metaData, function(slice, index) { + helpers.each(this.data.datasets[0].metaData, function(slice, index) { - var datapoint = this.data.data[index]; + var value = this.data.datasets[0].data[index]; var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; var endAngle = startAngle + (circumference * Math.PI); helpers.extend(slice, { _index: index, - x: this.chart.width / 2, - y: this.chart.height / 2, - value: datapoint.value, - label: datapoint.label, - innerRadius: 0, - outerRadius: this.scale.calculateCenterOffset(slice.value), - startAngle: startAngle, - endAngle: endAngle, - - backgroundColor: datapoint.backgroundColor, - hoverBackgroundColor: datapoint.hoverBackgroundColor || datapoint.backgroundColor, - borderWidth: this.options.borderWidth, - borderColor: this.options.segmentStrokeColor, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: this.scale.calculateCenterOffset(value), + startAngle: startAngle, + endAngle: endAngle, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, }); slice.pivot(); + console.log(slice); + }, this); this.render(); @@ -204,12 +182,99 @@ this.clear(); - helpers.each(this.data.metaData, function(segment, index) { - segment.transition(easingDecimal).draw(); + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + slice.transition(easingDecimal).draw(); }, this); this.scale.draw(); - } + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = this.getSliceAtEvent(e); + + // On Hover hook + if (this.options.onHover) { + this.options.onHover.call(this, this.active); + } + + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + this.lastActive[0].backgroundColor = this.data.data[this.lastActive[0]._index].backgroundColor; + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.data.data[this.active[0]._index].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + } + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + helpers.extend(this.tooltip, { + opacity: 1, + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + helpers.extend(this.tooltip, { + opacity: 0, + }); + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + helpers.each(this.data.metaData, function(slice, index) { + if (slice.inRange(location.x, location.y)) elements.push(slice); + }, this); + return elements; + }, }); }).call(this); From 235247eb126ead4cad2a4b79070f26a87993576f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 15:18:42 -0600 Subject: [PATCH 088/424] example fixes --- samples/doughnut.html | 7 ++-- samples/pie.html | 98 ++++++++++++++++++++++++++++--------------- 2 files changed, 69 insertions(+), 36 deletions(-) diff --git a/samples/doughnut.html b/samples/doughnut.html index 9b856dbbb64..dc874e754d9 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -97,9 +97,10 @@ }; $('#randomizeData').click(function() { - $.each(config.data, function(i, datapoint) { - datapoint.value = randomScalingFactor(); - datapoint.backgroundColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + $.each(config.data.datasets, function(i, piece) { + $.each(piece.data, function(j, value) { + config.data.datasets[i].data[j] = randomScalingFactor(); + }); }); window.myDoughnut.update(); }); diff --git a/samples/pie.html b/samples/pie.html index 24076af5133..34b126ec062 100644 --- a/samples/pie.html +++ b/samples/pie.html @@ -20,46 +20,78 @@ return Math.round(Math.random() * 255); }; - var pieData = [{ - value: randomScalingFactor(), - color: "#F7464A", - highlight: "#FF5A5E", - label: "Red" - }, { - value: randomScalingFactor(), - color: "#46BFBD", - highlight: "#5AD3D1", - label: "Green" - }, { - value: randomScalingFactor(), - color: "#FDB45C", - highlight: "#FFC870", - label: "Yellow" - }, { - value: randomScalingFactor(), - color: "#949FB1", - highlight: "#A8B3C5", - label: "Grey" - }, { - value: randomScalingFactor(), - color: "#4D5360", - highlight: "#616774", - label: "Dark Grey" + var config = { + data: { + datasets: [{ + data: [ + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + ], + backgroundColor: [ + "#F7464A", + "#46BFBD", + "#FDB45C", + "#949FB1", + "#4D5360", + ], + }, { + data: [ + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + ], + backgroundColor: [ + "#F7464A", + "#46BFBD", + "#FDB45C", + "#949FB1", + "#4D5360", + ], + }, { + data: [ + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + randomScalingFactor(), + ], + backgroundColor: [ + "#F7464A", + "#46BFBD", + "#FDB45C", + "#949FB1", + "#4D5360", + ], + }], + labels: [ + "Red", + "Green", + "Yellow", + "Grey", + "Dark Grey" + ] + }, + options: { + responsive: true } - - ]; + }; window.onload = function() { var ctx = document.getElementById("chart-area").getContext("2d"); - window.myPie = new Chart(ctx).Pie({ - data: pieData - }); + window.myPie = new Chart(ctx).Pie(config); }; $('#randomizeData').click(function() { - $.each(pieData, function(i, piece) { - pieData[i].value = randomScalingFactor(); - pieData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + $.each(config.data.datasets, function(i, piece) { + $.each(piece.data, function(j, value) { + config.data.datasets[i].data[j] = randomScalingFactor(); + //config.data.datasets.backgroundColor[i] = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + }); }); window.myPie.update(); }); From 675a9f827e6fbb94a855602fee2144fbf5b3d28f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 15:25:18 -0600 Subject: [PATCH 089/424] Version bump 2.0.0-alpha --- bower.json | 24 ++++++++++------------ package.json | 58 ++++++++++++++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/bower.json b/bower.json index cc8681852a0..efdffbd1988 100644 --- a/bower.json +++ b/bower.json @@ -1,15 +1,13 @@ { - "name": "Chart.js", - "version": "1.0.2", - "description": "Simple HTML5 Charts using the canvas element", - "homepage": "https://github.com/nnnick/Chart.js", - "author": "nnnick", - "main": [ - "Chart.js" - ], - "devDependencies": { - "angular": "~1.3.15", - "jquery": "~2.1.4", - "flatstrap": "~3.3.1" - } + "name": "Chart.js", + "version": "2.0.0-alpha", + "description": "Simple HTML5 Charts using the canvas element", + "homepage": "https://github.com/nnnick/Chart.js", + "author": "nnnick", + "main": [ + "Chart.js" + ], + "devDependencies": { + "jquery": "~2.1.4" + } } diff --git a/package.json b/package.json index 3f63e7b8599..cf30a62270e 100644 --- a/package.json +++ b/package.json @@ -1,31 +1,31 @@ { - "name": "chart.js", - "homepage": "http://www.chartjs.org", - "description": "Simple HTML5 charts using the canvas element.", - "version": "1.0.2", - "main": "Chart.js", - "repository": { - "type": "git", - "url": "https://github.com/nnnick/Chart.js.git" - }, - "dependences": {}, - "devDependencies": { - "color": "git://github.com/chartjs/color", - "gulp": "3.5.x", - "gulp-concat": "~2.1.x", - "gulp-connect": "~2.0.5", - "gulp-html-validator": "^0.0.2", - "gulp-jshint": "~1.5.1", - "gulp-replace": "^0.4.0", - "gulp-size": "~0.4.0", - "gulp-uglify": "~0.2.x", - "gulp-util": "~2.2.x", - "inquirer": "^0.5.1", - "jquery": "^2.1.4", - "onecolor": "^2.5.0", - "semver": "^3.0.1" - }, - "spm": { - "main": "Chart.js" - } + "name": "chart.js", + "homepage": "http://www.chartjs.org", + "description": "Simple HTML5 charts using the canvas element.", + "version": "2.0.0-alpha", + "main": "Chart.js", + "repository": { + "type": "git", + "url": "https://github.com/nnnick/Chart.js.git" + }, + "dependences": {}, + "devDependencies": { + "color": "git://github.com/chartjs/color", + "gulp": "3.5.x", + "gulp-concat": "~2.1.x", + "gulp-connect": "~2.0.5", + "gulp-html-validator": "^0.0.2", + "gulp-jshint": "~1.5.1", + "gulp-replace": "^0.4.0", + "gulp-size": "~0.4.0", + "gulp-uglify": "~0.2.x", + "gulp-util": "~2.2.x", + "inquirer": "^0.5.1", + "jquery": "^2.1.4", + "onecolor": "^2.5.0", + "semver": "^3.0.1" + }, + "spm": { + "main": "Chart.js" + } } From 8b0b6194b2c042fae70206418865859b0074d947 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 15:25:28 -0600 Subject: [PATCH 090/424] No playground --- samples/playground.html | 72 ------------------- samples/playground.js | 156 ---------------------------------------- 2 files changed, 228 deletions(-) delete mode 100644 samples/playground.html delete mode 100644 samples/playground.js diff --git a/samples/playground.html b/samples/playground.html deleted file mode 100644 index 0d332a0f712..00000000000 --- a/samples/playground.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Line Chart - - - - - - -
    -
    - -
    -
    -
    - - -
    -
    - -
    -
    - -
    -
    -
    {{dataset.data}}
    -
    - borderWidth: - -
    -
    - hoverBorderWidth: - -
    -
    - pointBorderWidth: - -
    -
    - pointHoverBorderWidth: - -
    -
    -
    -
    - - - - - - - diff --git a/samples/playground.js b/samples/playground.js deleted file mode 100644 index b75824483ba..00000000000 --- a/samples/playground.js +++ /dev/null @@ -1,156 +0,0 @@ -(function() { - - var module = angular.module('app', []); - - module.controller('mainController', function($scope, $timeout) { - angular.extend($scope, { - - chart: {}, - chartTypes: chartTypes(), - - init: init, - randomizeData: randomizeData, - }); - - - init(); - - - - function init() { - if ($scope._chart) { - $scope._chart.destroy(); - } - $scope.ctx = $('canvas')[0].getContext("2d"); - buildData(); - buildChart(); - - $scope.$watch('options', function(val) { - try { - angular.extend($scope.chart.options, JSON.parse(val)); - } catch (e) { - console.log(e); - } - }, true); - - $scope.$watch('chart.options', function() { - if ($scope._chart) { - $scope._chart.update(); - } - }, true); - } - - function chartTypes() { - return [{ - name: 'Line/Scatter', - value: 'Line/Scatter', - selected: true - }, { - name: 'Bar', - value: 'Bar', - }, { - name: 'Pie/Doughnut', - value: 'Pie/Doughnut', - }, { - name: 'Polar', - value: 'Polar', - }, { - name: 'Radar', - value: 'Radar', - }]; - } - - - - function buildData() { - $scope.chart.data = groupData(); - $scope.chart.options = { - stacked: true, - hoverMode: 'label' - }; - $scope.options = stringify($scope.chart.options); - } - - function buildChart() { - $scope._chart = new Chart($scope.ctx)[$scope.chartType || 'Line']($scope.chart); - } - - function stringify(o) { - var cache = []; - var result = JSON.stringify(o, function(key, value) { - if (typeof value === 'object' && value !== null) { - if (cache.indexOf(value) !== -1) { - // Circular reference found, discard key - return; - } - // Store value in our collection - cache.push(value); - } - return value; - }, 1); - cache = null; // Enable garbage collection - return result; - } - - - function groupData() { - return { - labels: ["January", "February", "March", "April", "May", "June", "July"], - datasets: [{ - label: "Dataset 1", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], - backgroundColor: randomColor(0.8), - }, { - label: "Dataset 2", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], - backgroundColor: randomColor(0.8), - }, { - label: "Dataset 3", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], - backgroundColor: randomColor(0.8), - }] - }; - } - - function flatData() { - return { - labels: ["January", "February", "March", "April", "May", "June", "July"], - datasets: [{ - label: "My First dataset", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] - }, { - label: "My Second dataset", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] - }] - }; - } - - function randomizeData() { - - angular.forEach($scope.chart.data.datasets, function(dataset) { - - dataset.data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; - dataset.backgroundColor = randomColor(.8); - dataset.borderColor = randomColor(0.7); - dataset.pointBackgroundColor = randomColor(1); - dataset.pointBorderColor = randomColor(1); - - - $scope._chart.update(); - }); - } - - - - - function randomScalingFactor() { - return Math.round(Math.random() * 100 * (Math.random() > 0.5 ? -1 : 1)); - } - - function randomColor(opacity) { - return 'rgba(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + (typeof opacity != "undefined" ? opacity : '.3') + ')'; - } - - }); - -})(); From 8e5d8b88615f77685c3f44e6fbaf76f5120ea82d Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 16:31:25 -0600 Subject: [PATCH 091/424] Doughnut and polar hovering/clicking --- src/Chart.Core.js | 13 ++++- src/Chart.Doughnut.js | 117 ++++++++++++++++++++++++++++++++++------- src/Chart.PolarArea.js | 106 ++++++++++++++++++++++++++++++++----- 3 files changed, 204 insertions(+), 32 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 9c91b862d85..356e0dbc3e0 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -88,13 +88,13 @@ xOffset: 10, template: [ '<% if(label){ %>', - ' <%=label %>:', + '<%=label %>:', '<% } %>', '<%=value %>', ].join(''), multiTemplate: [ '<%if (datasetLabel){ %>', - ' <%=datasetLabel %>:', + '<%=datasetLabel %>:', '<% } %>', '<%=value %>' ].join(''), @@ -1429,6 +1429,15 @@ }); Chart.Arc = Chart.Element.extend({ + inGroupRange: function(mouseX) { + var vm = this._view; + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + } else { + return false; + } + }, inRange: function(chartX, chartY) { var vm = this._view; diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index a6db6cb82c3..9ccee22afaf 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -58,16 +58,7 @@ this.update(); }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - helpers.each(this.data.metaData, function(slice, index) { - if (slice.inRange(location.x, location.y)) elements.push(slice); - }, this); - return elements; - }, calculateCircumference: function(dataset, value) { if (dataset.total > 0) { return (Math.PI * 2) * (value / dataset.total); @@ -161,23 +152,91 @@ this.lastActive = this.lastActive || []; // Find Active Elements - this.active = this.getSliceAtEvent(e); + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); } + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - this.lastActive[0].backgroundColor = this.data.data[this.lastActive[0]._index].backgroundColor; + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } } // Built in hover styling if (this.active.length && this.options.hover.mode) { - this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.data.data[this.active[0]._index].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } } + // Built in Tooltips if (this.options.tooltips.enabled) { @@ -186,17 +245,16 @@ // Active if (this.active.length) { + this.tooltip._model.opacity = 1; + helpers.extend(this.tooltip, { - opacity: 1, _active: this.active, }); this.tooltip.update(); } else { // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.tooltip._model.opacity = 0; } } @@ -226,8 +284,31 @@ // Remember Last Active this.lastActive = this.active; return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ }); Chart.types.Doughnut.extend({ diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index e11f222ea2d..ae4b7236361 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -187,6 +187,8 @@ }, this); this.scale.draw(); + + this.tooltip.transition(easingDecimal).draw(); }, events: function(e) { @@ -198,23 +200,91 @@ this.lastActive = this.lastActive || []; // Find Active Elements - this.active = this.getSliceAtEvent(e); + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } } + var dataset; + var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - this.lastActive[0].backgroundColor = this.data.data[this.lastActive[0]._index].backgroundColor; + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } } // Built in hover styling if (this.active.length && this.options.hover.mode) { - this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.data.data[this.active[0]._index].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } } + // Built in Tooltips if (this.options.tooltips.enabled) { @@ -223,17 +293,16 @@ // Active if (this.active.length) { + this.tooltip._model.opacity = 1; + helpers.extend(this.tooltip, { - opacity: 1, _active: this.active, }); this.tooltip.update(); } else { // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.tooltip._model.opacity = 0; } } @@ -263,18 +332,31 @@ // Remember Last Active this.lastActive = this.active; return this; - }, getSliceAtEvent: function(e) { var elements = []; var location = helpers.getRelativePosition(e); - helpers.each(this.data.metaData, function(slice, index) { - if (slice.inRange(location.x, location.y)) elements.push(slice); + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } }, this); return elements; }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ }); }).call(this); From 2a62e0e04de5cda4caf6fd0dd825ae1e536eb95b Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 18:35:42 -0400 Subject: [PATCH 092/424] Reset elements for bar charts. Bar multi axis demo also shows different colours for each bar. --- samples/bar-multi-axis.html | 12 +++++++-- src/Chart.Bar.js | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/samples/bar-multi-axis.html b/samples/bar-multi-axis.html index 6ae6eca4590..b8c3a384d3b 100644 --- a/samples/bar-multi-axis.html +++ b/samples/bar-multi-axis.html @@ -19,6 +19,9 @@ var randomColorFactor = function() { return Math.round(Math.random() * 255); }; + var randomColor = function() { + return 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + }; var barChartData = { labels: ["January", "February", "March", "April", "May", "June", "July"], @@ -34,7 +37,7 @@ data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }, { label: 'Dataset 3', - backgroundColor: "rgba(151,187,205,0.5)", + backgroundColor: [randomColor(), randomColor(), randomColor(), randomColor(), randomColor(), randomColor(), randomColor()], yAxisID: "y-axis-1", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }] @@ -120,7 +123,12 @@ $('#randomizeData').click(function() { $.each(barChartData.datasets, function(i, dataset) { - dataset.backgroundColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; + if (Chart.helpers.isArray(dataset.backgroundColor)) { + dataset.backgroundColor= [randomColor(), randomColor(), randomColor(), randomColor(), randomColor(), randomColor(), randomColor()]; + } else { + dataset.backgroundColor= randomColor(); + } + dataset.data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; }); diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 77e3de3548a..e15260dc423 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -124,9 +124,60 @@ _options: this.options, }, this); + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // So that we animate from the baseline + this.resetElements(); + // Update the chart with the latest data. this.update(); }, + resetElements: function() { + // Update the points + this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max <0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(bar, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScalePoint, + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), + + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + }, + }); + bar.pivot(); + }, this); + }, update: function() { // Update the scale sizes Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); From a6c712323f86ed9d12256f824287202c9d641dd4 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 19:16:42 -0400 Subject: [PATCH 093/424] Reset elements for donut charts --- src/Chart.Doughnut.js | 44 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 9ccee22afaf..41bc7d0cd9e 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -54,6 +54,8 @@ _options: this.options, }, this); + this.resetElements(); + // Update the chart with the latest data. this.update(); @@ -66,6 +68,46 @@ return 0; } }, + resetElements: function() { + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; + + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + // So that calculateCircumference works + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + helpers.extend(slice, { + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, + innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + slice.pivot(); + }, this); + + }, this); + }, update: function() { this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; @@ -112,7 +154,7 @@ }); if (index === 0) { - slice._model.startAngle = Math.PI * 1.5; + slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function } else { slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; } From c2d6e4c31f027fc2bbba0a594ab41d156523bd71 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 19:24:29 -0400 Subject: [PATCH 094/424] Reset elements for polar area chart --- src/Chart.PolarArea.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index ae4b7236361..f0ceff750cc 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -121,6 +121,14 @@ _options: this.options, }, this); + // Fit the scale before we animate + this.updateScaleRange(); + this.scale.calculateRange(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // so that we animate nicely + this.resetElements(); + // Update the chart with the latest data. this.update(); @@ -132,6 +140,39 @@ yCenter: this.chart.height / 2 }); }, + resetElements: function() { + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: 0, + startAngle: Math.PI * 1.5, + endAngle: Math.PI * 1.5, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + + slice.pivot(); + }, this); + }, update: function() { this.updateScaleRange(); From b9ab70f21b2c3ea28b5a8a768e54c393604cdb5b Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 19:54:34 -0400 Subject: [PATCH 095/424] Cleaned up global config + documentation of global config options --- docs/00-Getting-Started.md | 292 +++++++++++++++++++++++-------------- src/Chart.Core.js | 4 - 2 files changed, 182 insertions(+), 114 deletions(-) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index a6884a4beab..3c2b6435fb6 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -74,135 +74,207 @@ This concept was introduced in Chart.js 1.0 to keep configuration DRY, and allow ```javascript Chart.defaults.global = { - // Boolean - Whether to animate the chart - animation: true, + // Animation settings + animation: { + // Length that animation should take in ms assuming 60fps. + // Set to 0 to disable animation + duration: 1000, - // Number - Number of animation steps - animationSteps: 60, + // Easing type. Possible values are: + // [easeInOutQuart, linear, easeOutBounce, easeInBack, easeInOutQuad, + // easeOutQuart, easeOutQuad, easeInOutBounce, easeOutSine, easeInOutCubic, + // easeInExpo, easeInOutBack, easeInCirc, easeInOutElastic, easeOutBack, + // easeInQuad, easeInOutExpo, easeInQuart, easeOutQuint, easeInOutCirc, + // easeInSine, easeOutExpo, easeOutCirc, easeOutCubic, easeInQuint, + // easeInElastic, easeInOutSine, easeInOutQuint, easeInBounce, + // easeOutElastic, easeInCubic] + easing: "easeOutQuart", + + // Function - function to call each time an animation step occurs + onProgress: function() {}, - // String - Animation easing effect - // Possible effects are: - // [easeInOutQuart, linear, easeOutBounce, easeInBack, easeInOutQuad, - // easeOutQuart, easeOutQuad, easeInOutBounce, easeOutSine, easeInOutCubic, - // easeInExpo, easeInOutBack, easeInCirc, easeInOutElastic, easeOutBack, - // easeInQuad, easeInOutExpo, easeInQuart, easeOutQuint, easeInOutCirc, - // easeInSine, easeOutExpo, easeOutCirc, easeOutCubic, easeInQuint, - // easeInElastic, easeInOutSine, easeInOutQuint, easeInBounce, - // easeOutElastic, easeInCubic] - animationEasing: "easeOutQuart", + // Function - function to call when animations finish + onComplete: function() {}, + }, - // Boolean - If we should show the scale at all - showScale: true, + // Boolean - if true, resize the charts when the page resizes + responsive: false, - // Boolean - If we want to override with a hard coded scale - scaleOverride: false, + // Boolean - if true, try to maintain the screen aspect ratio + maintainAspectRatio: true, + + // Array - events to bind tooltips to + events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], + + // Hover settings + hover: { + // Function - called when the user hovers over the items. + // Parameters: array of active elements + onHover: null, - // ** 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 - hover mode. Options are 'single', 'label', and 'dataset' + // 'single' gets the nearest element + // 'label' gets all of the elements at the given dataset index (do not use for scatter charts) + // 'dataset' gets all the elements in the given dataset + mode: 'single', + + // Number - duration (in ms) of the tooltip animation. 0 to disable + animationDuration: 400, + }, + + // Function - click handler to bind to chart area + onClick: null, + + // Tooltip configuration + tooltips: { + // Boolean - if true show tooltips + enabled: true, + + // Function - custom tooltip function to use + custom: null, + + // String - color of tooltip background + backgroundColor: "rgba(0,0,0,0.8)", + + // String - fonts to use + fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + + // Number - font size + fontSize: 10, + + // String - font style + fontStyle: "normal", - // String - Colour of the scale line - scaleLineColor: "rgba(0,0,0,.1)", + // String - font color + fontColor: "#fff", + + // String - title fonts + titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + + // Number - title font size + titleFontSize: 12, + + // String - title font style + titleFontStyle: "bold", - // Number - Pixel width of the scale line - scaleLineWidth: 1, + // String - title font color + titleFontColor: "#fff", - // Boolean - Whether to show labels on the scale - scaleShowLabels: true, + // Number - + yPadding: 6, + + // Number - + xPadding: 6, + + // Number - + caretSize: 8, + + // Number - radius of rounded corners + cornerRadius: 6, + + // Number - + xOffset: 10, + + // String - template string to use for tooltips in single mode + template: [ + '<% if(label){ %>', + '<%=label %>:', + '<% } %>', + '<%=value %>', + ].join(''), + + // String - template string to use for tooltips in label mode + multiTemplate: [ + '<%if (datasetLabel){ %>', + '<%=datasetLabel %>:', + '<% } %>', + '<%=value %>' + ].join(''), - // Interpolated JS string - can access value - scaleLabel: "<%=value%>", + // String - + multiKeyBackground: '#fff', + }, - // Boolean - Whether the scale should stick to integers, not floats even if drawing space is there - scaleIntegersOnly: true, + // String - default grey color. 'rgba(0,0,0,0.1)' + defaultColor: defaultColor, - // Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value - scaleBeginAtZero: false, + // Element defaults + elements: { + // Default settings for all line elements + line: { + // Number - Bezier curve tension. Set to 0 for no bezier curves + tension: 0.4, - // String - Scale label font declaration for the scale label - scaleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + // String - the fill color + backgroundColor: defaultColor, + + // Number - width of the line + borderWidth: 3, - // Number - Scale label font size in pixels - scaleFontSize: 12, + // String = color of the line + borderColor: defaultColor, + + // Boolean - if true fill in the area between the line and the x axis with the background color + fill: true, - // String - Scale label font weight style - scaleFontStyle: "normal", + // Boolean - + skipNull: true, - // String - Scale label font colour - scaleFontColor: "#666", + // Boolean - + drawNull: false, + }, + // Settings for all point elements + point: { + // Number - radius of point circle + radius: 3, - // Boolean - whether or not the chart should be responsive and resize when the browser does. - responsive: false, + // String - fill color of point + backgroundColor: defaultColor, - // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container - maintainAspectRatio: true, + // Number - width of stroke of point circle + borderWidth: 1, - // Boolean - Determines whether to draw tooltips on the canvas or not - showTooltips: true, + // String - stroke color for point + borderColor: defaultColor, - // Function - Determines whether to execute the customTooltips function instead of drawing the built in tooltips (See [Advanced - External Tooltips](#advanced-usage-custom-tooltips)) - customTooltips: false, - - // 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 multiple tooltips - multiTooltipTemplate: "<%= value %>", - - // Function - Will fire on animation progression. - onAnimationProgress: function(){}, - - // Function - Will fire on animation completion. - onAnimationComplete: function(){} + // Number - extra radius added to radius for hit detection + hitRadius: 6, + + // Number - radius of point circle when hovered + hoverRadius: 4, + + // Number - radius of circle stroke when hovered + hoverBorderWidth: 2, + }, + // Settings for all bar elements + bar: { + // String - fill color of bar + backgroundColor: defaultColor, + + // Number - width of stroke of line surrounding bar fill + borderWidth: 0, + + // String - Border color + borderColor: defaultColor, + + // Number - + valueSpacing: 5, + + // Number - + datasetSpacing: 1, + }, + // Settings for all slice elements + slice: { + // String - fill color + backgroundColor: defaultColor, + + // String - border color + borderColor: "#fff", + + // Number - border stroke width + borderWidth: 2, + }, + } } ``` diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 356e0dbc3e0..34600aaae24 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -113,10 +113,6 @@ fill: true, // do we fill in the area between the line and the x axis skipNull: true, drawNull: false, - - // Hover - hitRadius: 6, - hoverBorderWidth: 2, }, point: { radius: 3, From f12d1bcb5605887944a19f3f81da3bfa69538a92 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 20:25:43 -0400 Subject: [PATCH 096/424] Cleaned up line docs a bit and remove unnecessary options --- docs/01-Line-Chart.md | 188 +++++++++++++++++++++++++++++++++--------- src/Chart.Line.js | 6 -- 2 files changed, 149 insertions(+), 45 deletions(-) diff --git a/docs/01-Line-Chart.md b/docs/01-Line-Chart.md index 8d164ffb2bc..abee3c9f9e6 100644 --- a/docs/01-Line-Chart.md +++ b/docs/01-Line-Chart.md @@ -23,13 +23,29 @@ var data = { datasets: [ { label: "My First dataset", + + // String or array - if an array is specified, allows changing the value for the point at the given index fillColor: "rgba(220,220,220,0.2)", + + // String or array - if an array is specified, allows changing the value for the point at the given index strokeColor: "rgba(220,220,220,1)", + + // String or array - if an array is specified, allows changing the value for the point at the given index pointColor: "rgba(220,220,220,1)", + + // String or array - if an array is specified, allows changing the value for the point at the given index pointStrokeColor: "#fff", + + // String or array - if an array is specified, allows changing the value for the point at the given index pointHighlightFill: "#fff", + + // String or array - if an array is specified, allows changing the value for the point at the given index pointHighlightStroke: "rgba(220,220,220,1)", - data: [65, 59, 80, 81, 56, 55, 40] + + data: [65, 59, 80, 81, 56, 55, 40], + + // String - If specified, binds the dataset to a certain y-axis. If not specified, the first y-axis is used. + yAxisID: "y-axis-1", }, { label: "My Second dataset", @@ -56,65 +72,159 @@ These are the customisation options specific to Line charts. These options are m ```javascript { + // Boolean - if true, line stack on top of each other along the y axis + stacked: false, + + hover: { + // String - We use a label hover mode since the x axis displays data by the index in the dataset + mode: "label" + }, + + scales: { + // The line chart officially supports only 1 x-axis but uses an array to keep the API consistent. Use a scatter chart if you need multiple x axes. + xAxes: [{ + // String - type of axis to use. Should not be changed from 'dataset'. To use a 'linear' axis on the x, use the scatter chart type + scaleType: "dataset", // scatter should not use a dataset axis + + // Boolean - if true, show the scale + display: true, + + // String - position of the scale. possible options are "top" and "bottom" for dataset scales + position: "bottom", + + // String - id of the axis so that data can bind to it + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + // Boolean - if true, show the grid lines + show: true, + + // String - color of the grid lines + color: "rgba(0, 0, 0, 0.05)", + + // Number - width of the grid lines + lineWidth: 1, + + // Boolean - if true draw lines on the chart area + drawOnChartArea: true, + + // Boolean - if true draw ticks in the axis area + drawTicks: true, + + // Number - width of the grid line for the first index (index 0) + zeroLineWidth: 1, + + // String - color of the grid line for the first index + zeroLineColor: "rgba(0,0,0,0.25)", + + // Boolean - if true, offset labels from grid lines + offsetGridLines: false, + }, + + // label settings + labels: { + // Boolean - if true show labels + show: true, + + // String - template string for labels + template: "<%=value%>", + + // Number - label font size + fontSize: 12, + + // String - label font style + fontStyle: "normal", + + // String - label font color + fontColor: "#666", + + // String - label font family + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + // String - type of axis. 'linear' is the default but extensions may provide other types such as logarithmic + scaleType: "linear", + + // Boolean - if true, show the scale + display: true, + + // String - position of axis. Vertical axes can have either "left" or "right" + position: "left", + + // ID of the axis for data binding + id: "y-axis-1", - ///Boolean - Whether grid lines are shown across the chart - scaleShowGridLines : true, + // grid line settings + gridLines: { + // Boolean - if true, show the grid lines + show: true, - //String - Colour of the grid lines - scaleGridLineColor : "rgba(0,0,0,.05)", + // String - color of the grid lines + color: "rgba(0, 0, 0, 0.05)", - //Number - Width of the grid lines - scaleGridLineWidth : 1, + // Number - width of the grid lines + lineWidth: 1, - //Boolean - Whether to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, + // Boolean - if true draw lines on the chart area + drawOnChartArea: true, - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, + // Boolean - if true draw ticks in the axis area + drawTicks: true, - //Boolean - Whether the line is curved between points - bezierCurve : true, + // Number - width of the grid line representing a numerical value of 0 + zeroLineWidth: 1, - //Number - Tension of the bezier curve between points - bezierCurveTension : 0.4, + // String - color of the grid line representing a numerical value of 0 + zeroLineColor: "rgba(0,0,0,0.25)", + }, - //Boolean - Whether to show a dot for each point - pointDot : true, + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, - //Number - Radius of each point dot in pixels - pointDotRadius : 4, + // label settings + labels: { + // Boolean - if true show labels + show: true, - //Number - Pixel width of point dot stroke - pointDotStrokeWidth : 1, + // String - template string for labels + template: "<%=value%>", - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHitDetectionRadius : 20, + // Function - if specified this is passed the tick value, index, and the array of all tick values. Returns a string that is used as the label for that value + userCallback: null, - //Boolean - Whether to show a stroke for datasets - datasetStroke : true, + // Number - label font size + fontSize: 12, - //Number - Pixel width of dataset stroke - datasetStrokeWidth : 2, + // String - label font style + fontStyle: "normal", - //Boolean - Whether to fill the dataset with a colour - datasetFill : true, - {% raw %} - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - {% endraw %} + // String - label font color + fontColor: "#666", - //Boolean - Whether to horizontally center the label and point dot inside the grid - offsetGridLines : false + // String - label font family + fontFamily: "Helvetica Neue", + }, + }], + } }; ``` -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. +You can override these for your `Chart` instance by passing a member `options` into the `Line` method. -For example, we could have a line chart without bezier curves between points by doing the following: +For example, we could have a line chart display without an x axis by doing the following. The config merge is smart enough to handle arrays so that you do not need to specify all axis settings to change one thing. ```javascript -new Chart(ctx).Line(data, { - bezierCurve: false +new Chart(ctx).Line({ + data: data, + options: { + xAxes: [{ + show: 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. diff --git a/src/Chart.Line.js b/src/Chart.Line.js index a7deb1c329c..c456bddd84d 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -32,11 +32,6 @@ offsetGridLines: false, }, - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - // label settings labels: { show: true, @@ -66,7 +61,6 @@ // scale numbers beginAtZero: false, - integersOnly: false, override: null, // label settings From 7dcee4b40e4ef90dde718dc0f57f4eef98994640 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 20:33:50 -0400 Subject: [PATCH 097/424] Additional fixes to line chart docs --- docs/01-Line-Chart.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/01-Line-Chart.md b/docs/01-Line-Chart.md index abee3c9f9e6..7ab8166a3ae 100644 --- a/docs/01-Line-Chart.md +++ b/docs/01-Line-Chart.md @@ -13,7 +13,10 @@ Often, it is used to show trend data, and the comparison of two data sets. ###Example usage ```javascript -var myLineChart = new Chart(ctx).Line(data, options); +var myLineChart = new Chart(ctx).Line({ + data: data, + options: options +}); ``` ###Data structure @@ -180,9 +183,14 @@ These are the customisation options specific to Line charts. These options are m zeroLineColor: "rgba(0,0,0,0.25)", }, - // scale numbers + // Boolean - if true ensures that the scale always has a 0 point beginAtZero: false, - integersOnly: false, + + // Object - if specified, allows the user to override the step generation algorithm. + // Contains the following values + // start: // number to start at + // stepWidth: // size of step + // steps: // number of steps override: null, // label settings From 9c106aa8ffdcf73f7db582672858e96363aec692 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 20:46:35 -0400 Subject: [PATCH 098/424] Some more line options --- docs/01-Line-Chart.md | 55 +++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/docs/01-Line-Chart.md b/docs/01-Line-Chart.md index 7ab8166a3ae..0800eb5b4d7 100644 --- a/docs/01-Line-Chart.md +++ b/docs/01-Line-Chart.md @@ -27,24 +27,39 @@ var data = { { label: "My First dataset", - // String or array - if an array is specified, allows changing the value for the point at the given index - fillColor: "rgba(220,220,220,0.2)", + // Boolean - if true fill the area under the line + fill: false, - // String or array - if an array is specified, allows changing the value for the point at the given index - strokeColor: "rgba(220,220,220,1)", + // String - the color to fill the area under the line with if fill is true + backgroundColor: "rgba(220,220,220,0.2)", - // String or array - if an array is specified, allows changing the value for the point at the given index - pointColor: "rgba(220,220,220,1)", + // The properties below allow an array to be specified to change the value of the item at the given index - // String or array - if an array is specified, allows changing the value for the point at the given index - pointStrokeColor: "#fff", + // String or array - Line color + borderColor: "rgba(220,220,220,1)", - // String or array - if an array is specified, allows changing the value for the point at the given index - pointHighlightFill: "#fff", + // String or array - Point stroke color + pointBorderColor: "rgba(220,220,220,1)", - // String or array - if an array is specified, allows changing the value for the point at the given index - pointHighlightStroke: "rgba(220,220,220,1)", + // String or array - Point fill color + pointBackgroundColor: "#fff", + // Number or array - Stroke width of point border + pointBorderWidth: 1, + + // Number or array - Radius of point when hovered + pointHoverRadius: 5 + + // String or array - point background color when hovered + pointHoverBackgroundColor: "rgba(220,220,220,1)" + + // Point border color when hovered + pointHoverBorderColor: "rgba(220,220,220,1)" + + // Number or array - border width of point when hovered + pointBorderWidth: 2, + + // The actual data data: [65, 59, 80, 81, 56, 55, 40], // String - If specified, binds the dataset to a certain y-axis. If not specified, the first y-axis is used. @@ -52,12 +67,16 @@ var data = { }, { 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)", + fill: false, + backgroundColor: "rgba(220,220,220,0.2)", + borderColor: "rgba(220,220,220,1)", + pointBorderColor: "rgba(220,220,220,1)", + pointBackgroundColor: "#fff", + pointBorderWidth: 1, + pointHoverRadius: 5, + pointHoverBackgroundColor: "rgba(220,220,220,1)", + pointHoverBorderColor: "rgba(220,220,220,1)", + pointBorderWidth: 2, data: [28, 48, 40, 19, 86, 27, 90] } ] From 70f7dd4c7d00ccc4fbb224412a79d2cdd481c84d Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 18:47:11 -0600 Subject: [PATCH 099/424] Default global responsive --- src/Chart.Core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 34600aaae24..02689a5d61b 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -60,7 +60,7 @@ onProgress: function() {}, onComplete: function() {}, }, - responsive: false, + responsive: true, maintainAspectRatio: true, events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], hover: { From 996e4711717921e3090208549dea28d154646769 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 20:49:22 -0400 Subject: [PATCH 100/424] Missed some commas --- docs/01-Line-Chart.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/01-Line-Chart.md b/docs/01-Line-Chart.md index 0800eb5b4d7..986ec3f426f 100644 --- a/docs/01-Line-Chart.md +++ b/docs/01-Line-Chart.md @@ -48,13 +48,13 @@ var data = { pointBorderWidth: 1, // Number or array - Radius of point when hovered - pointHoverRadius: 5 + pointHoverRadius: 5, // String or array - point background color when hovered - pointHoverBackgroundColor: "rgba(220,220,220,1)" + pointHoverBackgroundColor: "rgba(220,220,220,1)", // Point border color when hovered - pointHoverBorderColor: "rgba(220,220,220,1)" + pointHoverBorderColor: "rgba(220,220,220,1)", // Number or array - border width of point when hovered pointBorderWidth: 2, From 9e9f436454838223f0f540925f064a36b89c0072 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 3 Jun 2015 20:55:17 -0400 Subject: [PATCH 101/424] Bar config cleanup + some initial docs --- docs/02-Bar-Chart.md | 208 +++++++++++++++++++++++++++++++++++-------- src/Chart.Bar.js | 7 -- 2 files changed, 171 insertions(+), 44 deletions(-) diff --git a/docs/02-Bar-Chart.md b/docs/02-Bar-Chart.md index cc23f38b733..12545886147 100644 --- a/docs/02-Bar-Chart.md +++ b/docs/02-Bar-Chart.md @@ -14,7 +14,10 @@ It is sometimes used to show trend data, and the comparison of multiple data set ### Example usage ```javascript -var myBarChart = new Chart(ctx).Bar(data, options); +var myBarChart = new Chart(ctx).Bar({ + data: data, + options: options +}); ``` ### Data structure @@ -25,18 +28,36 @@ var data = { 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] + + // 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)", + + // String or array - bar stroke color + borderColor: "rgba(220,220,220,1)", + + // Number or array - bar border width + borderWidth: 1, + + // String or array - fill color when hovered + hoverBackgroundColor: "rgba(220,220,220,0.2)", + + // String or array - border color when hovered + hoverBorderColor: "rgba(220,220,220,1)", + + // The actual data + data: [65, 59, 80, 81, 56, 55, 40], + + // String - If specified, binds the dataset to a certain y-axis. If not specified, the first y-axis is used. + yAxisID: "y-axis-1", }, { 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)", + backgroundColor: "rgba(220,220,220,0.2)", + borderColor: "rgba(220,220,220,1)", + borderWidth: 1, + hoverBackgroundColor: "rgba(220,220,220,0.2)", + hoverBorderColor: "rgba(220,220,220,1)", data: [28, 48, 40, 19, 86, 27, 90] } ] @@ -53,40 +74,150 @@ These are the customisation options specific to Bar charts. These options are me ```javascript { - //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value - scaleBeginAtZero : true, + // Boolean - if true, bars stack on top of each other + stacked: false, + + hover: { + // String - We use a label hover mode since the x axis displays data by the index in the dataset + mode: "label" + }, + + scales: { + // The bar chart officially supports only 1 x-axis but uses an array to keep the API consistent. Use a scatter chart if you need multiple x axes. + xAxes: [{ + // String - type of axis to use. Should not be changed from 'dataset'. + scaleType: "dataset", // scatter should not use a dataset axis + + // Boolean - if true, show the scale + display: true, + + // String - position of the scale. possible options are "top" and "bottom" for dataset scales + position: "bottom", + + // String - id of the axis so that data can bind to it + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + // Boolean - if true, show the grid lines + show: true, + + // String - color of the grid lines + color: "rgba(0, 0, 0, 0.05)", + + // Number - width of the grid lines + lineWidth: 1, + + // Boolean - if true draw lines on the chart area + drawOnChartArea: true, + + // Boolean - if true draw ticks in the axis area + drawTicks: true, + + // Number - width of the grid line for the first index (index 0) + zeroLineWidth: 1, - //Boolean - Whether grid lines are shown across the chart - scaleShowGridLines : true, + // String - color of the grid line for the first index + zeroLineColor: "rgba(0,0,0,0.25)", - //String - Colour of the grid lines - scaleGridLineColor : "rgba(0,0,0,.05)", + // Boolean - if true, offset labels from grid lines + offsetGridLines: false, + }, - //Number - Width of the grid lines - scaleGridLineWidth : 1, + // label settings + labels: { + // Boolean - if true show labels + show: true, - //Boolean - Whether to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, + // String - template string for labels + template: "<%=value%>", - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, + // Number - label font size + fontSize: 12, - //Boolean - If there is a stroke on each bar - barShowStroke : true, + // String - label font style + fontStyle: "normal", - //Number - Pixel width of the bar stroke - barStrokeWidth : 2, + // String - label font color + fontColor: "#666", - //Number - Spacing between each of the X value sets - barValueSpacing : 5, + // String - label font family + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + // String - type of axis. 'linear' is the default but extensions may provide other types such as logarithmic + scaleType: "linear", - //Number - Spacing between data sets within X values - barDatasetSpacing : 1, - {% raw %} - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - {% endraw %} -} + // Boolean - if true, show the scale + display: true, + + // String - position of axis. Vertical axes can have either "left" or "right" + position: "left", + + // ID of the axis for data binding + id: "y-axis-1", + + // grid line settings + gridLines: { + // Boolean - if true, show the grid lines + show: true, + + // String - color of the grid lines + color: "rgba(0, 0, 0, 0.05)", + + // Number - width of the grid lines + lineWidth: 1, + + // Boolean - if true draw lines on the chart area + drawOnChartArea: true, + + // Boolean - if true draw ticks in the axis area + drawTicks: true, + + // Number - width of the grid line representing a numerical value of 0 + zeroLineWidth: 1, + + // String - color of the grid line representing a numerical value of 0 + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // Boolean - if true ensures that the scale always has a 0 point + beginAtZero: false, + + // Object - if specified, allows the user to override the step generation algorithm. + // Contains the following values + // start: // number to start at + // stepWidth: // size of step + // steps: // number of steps + override: null, + + // label settings + labels: { + // Boolean - if true show labels + show: true, + + // String - template string for labels + template: "<%=value%>", + + // Function - if specified this is passed the tick value, index, and the array of all tick values. Returns a string that is used as the label for that value + userCallback: null, + + // Number - label font size + fontSize: 12, + + // String - label font style + fontStyle: "normal", + + // String - label font color + fontColor: "#666", + + // String - label font family + fontFamily: "Helvetica Neue", + }, + }], + }, +}; ``` 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. @@ -94,8 +225,11 @@ You can override these for your `Chart` instance by passing a second argument in 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 +new Chart(ctx).Bar({ + data: data, + options: { + 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. diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index e15260dc423..e1234cabd66 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -5,7 +5,6 @@ Chart = root.Chart, helpers = Chart.helpers; - var defaultConfig = { stacked: false, @@ -33,11 +32,6 @@ offsetGridLines: true, }, - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - // label settings labels: { show: true, @@ -67,7 +61,6 @@ // scale numbers beginAtZero: false, - integersOnly: false, override: null, // label settings From d46a1740801a68664da0885c1a60ccb1dcc77853 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 3 Jun 2015 19:45:14 -0600 Subject: [PATCH 102/424] Gulp Build --- Chart.js | 6385 +++++++++++++++++++++++++++++++++----------------- Chart.min.js | 11 +- 2 files changed, 4176 insertions(+), 2220 deletions(-) diff --git a/Chart.js b/Chart.js index f16219b5018..2d1fde13a51 100644 --- a/Chart.js +++ b/Chart.js @@ -1,7 +1,7 @@ /*! * Chart.js * http://chartjs.org/ - * Version: 1.0.2 + * Version: 2.0.0-alpha * * Copyright 2015 Nick Downie * Released under the MIT license @@ -48,150 +48,96 @@ return this; }; + + var defaultColor = 'rgba(0,0,0,0.1)'; + //Globally expose the defaults to allow for user updating/changing Chart.defaults = { global: { - // Boolean - Whether to animate the chart - animation: true, - - // Number - Number of animation steps - animationDuration: 1000, - - // 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, and not show any 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 - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container + animation: { + duration: 1000, + easing: "easeOutQuart", + onProgress: function() {}, + onComplete: function() {}, + }, + responsive: true, maintainAspectRatio: true, - - //String / Boolean - Hover mode for events. - hoverMode: 'single', // 'label', 'dataset', 'false' - - //Function(event) - Custom hover handler - onHover: null, - - //Function(event, clickedElements) - Custom click handler - onClick: null, - - //Function - Custom hover handler - hoverAnimationDuration: 400, - - // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove - showTooltips: true, - - // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function - customTooltips: false, - - // Array - Array of string names to attach interaction events events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], + hover: { + onHover: null, + mode: 'single', + animationDuration: 400, + }, + onClick: null, + tooltips: { + enabled: true, + custom: null, + backgroundColor: "rgba(0,0,0,0.8)", + fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + fontSize: 10, + fontStyle: "normal", + fontColor: "#fff", + titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + titleFontSize: 12, + titleFontStyle: "bold", + titleFontColor: "#fff", + yPadding: 6, + xPadding: 6, + caretSize: 8, + cornerRadius: 6, + xOffset: 10, + template: [ + '<% if(label){ %>', + '<%=label %>:', + '<% } %>', + '<%=value %>', + ].join(''), + multiTemplate: [ + '<%if (datasetLabel){ %>', + '<%=datasetLabel %>:', + '<% } %>', + '<%=value %>' + ].join(''), + multiKeyBackground: '#fff', - // String - Tooltip background colour - tooltipBackgroundColor: "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, - - // String - Template string for single tooltips - tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", - - // String - Template string for single tooltips - multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>", - - // String - Colour behind the legend colour block - multiTooltipKeyBackground: '#fff', - - // Function - Will fire on animation progression. - onAnimationProgress: function() {}, - - // Function - Will fire on animation completion. - onAnimationComplete: function() {}, - - // Color String - Used for undefined Colros - defaultColor: 'rgba(0,0,0,0.1)', - - } + }, + defaultColor: defaultColor, + + // Element defaults + elements: { + line: { + tension: 0.4, + backgroundColor: defaultColor, + borderWidth: 3, + borderColor: defaultColor, + fill: true, // do we fill in the area between the line and the x axis + skipNull: true, + drawNull: false, + }, + point: { + radius: 3, + backgroundColor: defaultColor, + borderWidth: 1, + borderColor: defaultColor, + // Hover + hitRadius: 6, + hoverRadius: 4, + hoverBorderWidth: 2, + }, + bar: { + backgroundColor: defaultColor, + borderWidth: 0, + borderColor: defaultColor, + valueSpacing: 5, + datasetSpacing: 1, + }, + slice: { + backgroundColor: defaultColor, + borderColor: "#fff", + borderWidth: 2, + }, + } + }, }; //Create a dictionary of chart types, to allow for extension of existing types @@ -242,6 +188,47 @@ args.unshift({}); return extend.apply(null, args); }, + // Need a special merge function to chart configs since they are now grouped + configMerge = helpers.configMerge = function(base) { + helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { + helpers.each(extension, function(value, key) { + if (extension.hasOwnProperty(key)) { + if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { + // In this case we have an array of objects replacing another array. Rather than doing a strict replace, + // merge. This allows easy scale option merging + var baseArray = base[key]; + + helpers.each(value, function(valueObj, index) { + if (index < baseArray.length) { + baseArray[index] = helpers.configMerge(baseArray[index], valueObj); + } else { + baseArray.push(valueObj); // nothing to merge + } + }); + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && typeof value == "object") { + // If we are overwriting an object with an object, do a merge of the properties. + base[key] = helpers.configMerge(base[key], value); + } else { + // can just overwrite the value in this case + base[key] = value; + } + } + }); + }); + + return base; + }, + getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { + if (!value) { + return defaultValue; + } + + if (helpers.isArray(value) && index < value.length) { + return value[index]; + } + + return value; + }, indexOf = helpers.indexOf = function(arrayToSearch, item) { if (Array.prototype.indexOf) { return arrayToSearch.indexOf(item); @@ -330,6 +317,17 @@ min = helpers.min = function(array) { return Math.min.apply(Math, array); }, + sign = helpers.sign = function(x) { + if (Math.sign) { + return Math.sign(x); + } else { + x = +x; // convert to a number + if (x === 0 || isNaN(x)) { + return x; + } + return x > 0 ? 1 : -1; + } + }, cap = helpers.cap = function(valueToCap, maxValue, minValue) { if (isNumber(maxValue)) { if (valueToCap > maxValue) { @@ -360,9 +358,12 @@ return 0; } }, - toRadians = helpers.radians = function(degrees) { + toRadians = helpers.toRadians = function(degrees) { return degrees * (Math.PI / 180); }, + toDegrees = helpers.toDegrees = function(radians) { + return radians * (180 / Math.PI); + }, // Gets the angle from vertical upright to the point about a centre. getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { var distanceFromXCenter = anglePoint.x - centrePoint.x, @@ -393,11 +394,11 @@ fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta fb = t * d12 / (d01 + d12); return { - next: { + previous: { x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) }, - previous: { + next: { x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) } @@ -482,6 +483,36 @@ }; }, + // Implementation of the nice number algorithm used in determining where axis labels will go + niceNum = helpers.niceNum = function(range, round) { + var exponent = Math.floor(Math.log10(range)); + var fraction = range / Math.pow(10, exponent); + var niceFraction; + + if (round) { + if (fraction < 1.5) { + niceFraction = 1; + } else if (fraction < 3) { + niceFraction = 2; + } else if (fraction < 7) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } else { + if (fraction <= 1.0) { + niceFraction = 1; + } else if (fraction <= 2) { + niceFraction = 2; + } else if (fraction <= 5) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } + + return niceFraction * Math.pow(10, exponent); + }, /* jshint ignore:start */ // Blows up jshint errors based on the new Function constructor //Templating methods @@ -959,10 +990,10 @@ redraw: noop, render: function(duration) { - if (this.options.animation) { + if (this.options.animation.duration !== 0) { var animation = new Chart.Animation(); - animation.numSteps = (duration || this.options.animationDuration) / 16.66; //60 fps - animation.easing = this.options.animationEasing; + animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps + animation.easing = this.options.animation.easing; // render function animation.render = function(chartInstance, animationObject) { @@ -1086,13 +1117,13 @@ var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; - Chart.defaults[chartName] = extend(baseDefaults, extensions.defaults); + Chart.defaults[chartName] = helpers.configMerge(baseDefaults, extensions.defaults); Chart.types[chartName] = ChartType; //Register this new chart type in the Chart prototype Chart.prototype[chartName] = function(config) { - helpers.extend(config.options, merge(Chart.defaults.global, Chart.defaults[chartName], config.options || {})); + config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[chartName], config.options || {}); return new ChartType(config, this); }; } else { @@ -1102,67 +1133,63 @@ }; Chart.Element = function(configuration) { - extend(this, { - _vm: {}, - }); extend(this, configuration); this.initialize.apply(this, arguments); }; extend(Chart.Element.prototype, { initialize: function() {}, - save: function() { - this._vm = clone(this); - delete this._vm._vm; - delete this._vm._start; - return this; - }, pivot: function() { - if (this._start) { - this._start = clone(this); - helpers.extend(this._start, this._vm); + if (!this._view) { + this._view = clone(this._model); } + this._start = clone(this._view); return this; }, transition: function(ease) { + if (!this._view) { + this._view = clone(this._model); + } if (!this._start) { - if (!this._vm) { - this.save(); - } - this._start = clone(this._vm); + this.pivot(); } - each(this, function(value, key) { + each(this._model, function(value, key) { - if (key[0] === '_' || !this.hasOwnProperty(key)) { + if (key[0] === '_' || !this._model.hasOwnProperty(key)) { // Only non-underscored properties } // Init if doesn't exist - else if (!this._vm[key]) { - this._vm[key] = value || null; + else if (!this._view[key]) { + if (typeof value === 'number') { + this._view[key] = value * ease; + } else { + this._view[key] = value || null; + } } // No unnecessary computations - else if (this[key] === this._vm[key]) { + else if (this._model[key] === this._view[key]) { // It's the same! Woohoo! } // Color transitions if possible else if (typeof value === 'string') { try { - var color = helpers.color(this._start[key]).mix(helpers.color(this[key]), ease); - this._vm[key] = color.rgbString(); + var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); + this._view[key] = color.rgbString(); } catch (err) { - this._vm[key] = value; + this._view[key] = value; } } // Number transitions else if (typeof value === 'number') { - - this._vm[key] = ((this[key] - this._start[key]) * ease) + this._start[key]; - } else { - // Everything else - this._vm[key] = value; + var startVal = this._start[key] !== undefined ? this._start[key] : 0; + this._view[key] = ((this._model[key] - startVal) * ease) + startVal; + } + // Everything else + else { + this._view[key] = value; } }, this); @@ -1174,12 +1201,12 @@ }, tooltipPosition: function() { return { - x: this.x, - y: this.y + x: this._model.x, + y: this._model.y }; }, hasValue: function() { - return isNumber(this.value); + return isNumber(this._model.x) && isNumber(this._model.y); } }); @@ -1188,16 +1215,21 @@ Chart.Point = Chart.Element.extend({ inRange: function(mouseX, mouseY) { - var vm = this._vm; + var vm = this._view; var hoverRange = vm.hoverRadius + vm.radius; return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); }, inGroupRange: function(mouseX) { - var vm = this._vm; - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + this.hoverRadius, 2)); + var vm = this._view; + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + } else { + return false; + } }, tooltipPosition: function() { - var vm = this._vm; + var vm = this._view; return { x: vm.x, y: vm.y, @@ -1206,9 +1238,14 @@ }, draw: function() { - var vm = this._vm; + var vm = this._view; var ctx = this._chart.ctx; + + if (vm.skip) { + return; + } + if (vm.radius > 0 || vm.borderWidth > 0) { ctx.beginPath(); @@ -1231,35 +1268,75 @@ Chart.Line = Chart.Element.extend({ draw: function() { - var vm = this._vm; + var vm = this._view; var ctx = this._chart.ctx; + var first = this._children[0]; + var last = this._children[this._children.length - 1]; // Draw the background first (so the border is always on top) - helpers.each(vm._points, function(point, index) { + helpers.each(this._children, function(point, index) { + var previous = this.previousPoint(point, this._children, index); + var next = this.nextPoint(point, this._children, index); + + // First point only if (index === 0) { - ctx.moveTo(point._vm.x, point._vm.y); - } else { - if (vm._tension > 0 || 1) { - var previous = this.previousPoint(point, vm._points, index); + ctx.moveTo(point._view.x, point._view.y); + return; + } + + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.lineTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); + } + // End Skip Stright line from the base line + else if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); + ctx.lineTo(point._view.x, point._view.y); + } + if (previous._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, point._view.y); + } + // Normal Bezier Curve + else { + if (vm.tension > 0) { ctx.bezierCurveTo( - previous._vm.controlPointNextX, - previous._vm.controlPointNextY, - point._vm.controlPointPreviousX, - point._vm.controlPointPreviousY, - point._vm.x, - point._vm.y + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y ); } else { - ctx.lineTo(point._vm.x, point._vm.y); + ctx.lineTo(point._view.x, point._view.y); } } }, this); - if (vm._points.length > 0) { + // For radial scales, loop back around to the first point + if (this._loop) { + if (vm.tension > 0 && !first._view.skip) { + + ctx.bezierCurveTo( + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y + ); + } else { + ctx.lineTo(first._view.x, first._view.y); + } + } + + // If we had points and want to fill this line, do so. + if (this._children.length > 0 && vm.fill) { //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(vm._points[vm._points.length - 1].x, vm.scaleZero); - ctx.lineTo(vm._points[0].x, vm.scaleZero); + ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero); + ctx.lineTo(this._children[0]._view.x, vm.scaleZero); ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.closePath(); ctx.fill(); @@ -1271,42 +1348,95 @@ ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; ctx.beginPath(); - helpers.each(vm._points, function(point, index) { + helpers.each(this._children, function(point, index) { + var previous = this.previousPoint(point, this._children, index); + var next = this.nextPoint(point, this._children, index); + + // First point only if (index === 0) { - ctx.moveTo(point._vm.x, point._vm.y); - } else { - if (vm._tension > 0 || 1) { - var previous = this.previousPoint(point, vm._points, index); + ctx.moveTo(point._view.x, point._view.y); + return; + } - ctx.bezierCurveTo( - previous._vm.controlPointNextX, - previous._vm.controlPointNextY, - point._vm.controlPointPreviousX, - point._vm.controlPointPreviousY, - point._vm.x, - point._vm.y - ); - } else { - ctx.lineTo(point._vm.x, point._vm.y); - } + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); + return; + } + // End Skip Stright line from the base line + if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); + ctx.moveTo(point._view.x, point._view.y); + return; + } + + if (previous._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, point._view.y); + return; + } + // Normal Bezier Curve + if (vm.tension > 0) { + ctx.bezierCurveTo( + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y + ); + } else { + ctx.lineTo(point._view.x, point._view.y); } }, this); + if (this._loop && !first._view.skip) { + if (vm.tension > 0) { + + ctx.bezierCurveTo( + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y + ); + } else { + ctx.lineTo(first._view.x, first._view.y); + } + } + ctx.stroke(); }, + nextPoint: function(point, collection, index) { + if (this.loop) { + return collection[index + 1] || collection[0]; + } + return collection[index + 1] || collection[collection.length - 1]; + }, previousPoint: function(point, collection, index) { - return helpers.findPreviousWhere(collection, function() { - return true; - }, index) || point; + if (this.loop) { + return collection[index - 1] || collection[collection.length - 1]; + } + return collection[index - 1] || collection[0]; }, }); Chart.Arc = Chart.Element.extend({ + inGroupRange: function(mouseX) { + var vm = this._view; + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + } else { + return false; + } + }, inRange: function(chartX, chartY) { - var vm = this._vm; + var vm = this._view; var pointRelativePosition = helpers.getAngleFromPoint(vm, { x: chartX, @@ -1321,7 +1451,7 @@ //Ensure within the outside of the arc centre, but inside arc outer }, tooltipPosition: function() { - var vm = this._vm; + var vm = this._view; var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; @@ -1333,7 +1463,7 @@ draw: function() { var ctx = this._chart.ctx; - var vm = this._vm; + var vm = this._view; ctx.beginPath(); @@ -1359,10 +1489,10 @@ Chart.Rectangle = Chart.Element.extend({ draw: function() { - var vm = this._vm; + var ctx = this._chart.ctx; + var vm = this._view; - var ctx = this.ctx, - halfWidth = vm.width / 2, + var halfWidth = vm.width / 2, leftX = vm.x - halfWidth, rightX = vm.x + halfWidth, top = vm.base - (vm.base - vm.y), @@ -1394,11 +1524,11 @@ } }, height: function() { - var vm = this._vm; + var vm = this._view; return vm.base - vm.y; }, inRange: function(mouseX, mouseY) { - var vm = this._vm; + var vm = this._view; if (vm.y < vm.base) { return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); } else { @@ -1406,11 +1536,11 @@ } }, inGroupRange: function(mouseX) { - var vm = this._vm; + var vm = this._view; return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); }, tooltipPosition: function() { - var vm = this._vm; + var vm = this._view; if (vm.y < vm.base) { return { x: vm.x, @@ -1439,41 +1569,55 @@ initialize: function() { var options = this._options; extend(this, { - opacity: 0, - xPadding: options.tooltipXPadding, - yPadding: options.tooltipYPadding, - xOffset: options.tooltipXOffset, - backgroundColor: options.tooltipBackgroundColor, - textColor: options.tooltipFontColor, - _fontFamily: options.tooltipFontFamily, - _fontStyle: options.tooltipFontStyle, - fontSize: options.tooltipFontSize, - titleTextColor: options.tooltipTitleFontColor, - _titleFontFamily: options.tooltipTitleFontFamily, - _titleFontStyle: options.tooltipTitleFontStyle, - titleFontSize: options.tooltipTitleFontSize, - caretHeight: options.tooltipCaretSize, - cornerRadius: options.tooltipCornerRadius, - legendColorBackground: options.multiTooltipKeyBackground, - labels: [], - colors: [], + _model: { + // Positioning + xPadding: options.tooltips.xPadding, + yPadding: options.tooltips.yPadding, + xOffset: options.tooltips.xOffset, + + // Labels + textColor: options.tooltips.fontColor, + _fontFamily: options.tooltips.fontFamily, + _fontStyle: options.tooltips.fontStyle, + fontSize: options.tooltips.fontSize, + + // Title + titleTextColor: options.tooltips.titleFontColor, + _titleFontFamily: options.tooltips.titleFontFamily, + _titleFontStyle: options.tooltips.titleFontStyle, + titleFontSize: options.tooltips.titleFontSize, + + // Appearance + caretHeight: options.tooltips.caretSize, + cornerRadius: options.tooltips.cornerRadius, + backgroundColor: options.tooltips.backgroundColor, + opacity: 0, + legendColorBackground: options.tooltips.multiKeyBackground, + }, }); }, update: function() { var ctx = this._chart.ctx; - switch (this._options.hoverMode) { + switch (this._options.hover.mode) { case 'single': - helpers.extend(this, { - text: template(this._options.tooltipTemplate, this._active[0]), + helpers.extend(this._model, { + text: template(this._options.tooltips.template, { + // These variables are available in the template function. Add others here + element: this._active[0], + value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], + label: this._data.labels ? this._data.labels[this._active[0]._index] : '', + }), }); + var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this, { + helpers.extend(this._model, { x: Math.round(tooltipPosition.x), y: Math.round(tooltipPosition.y), caretPadding: tooltipPosition.padding }); + break; case 'label': @@ -1509,17 +1653,22 @@ if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { elements.push(dataCollection[dataIndex]); } - }); + }, this); helpers.each(elements, function(element) { - xPositions.push(element._vm.x); - yPositions.push(element._vm.y); + xPositions.push(element._view.x); + yPositions.push(element._view.y); //Include any colour information about the element - labels.push(helpers.template(this._options.multiTooltipTemplate, element)); + labels.push(helpers.template(this._options.tooltips.multiTemplate, { + // These variables are available in the template function. Add others here + element: element, + datasetLabel: this._data.datasets[element._datasetIndex].label, + value: this._data.datasets[element._datasetIndex].data[element._index], + })); colors.push({ - fill: element._vm.backgroundColor, - stroke: element._vm.borderColor + fill: element._view.backgroundColor, + stroke: element._view.borderColor }); }, this); @@ -1537,42 +1686,42 @@ }).call(this, dataIndex); // Apply for now - helpers.extend(this, { + helpers.extend(this._model, { x: medianPosition.x, y: medianPosition.y, labels: labels, - title: this._active.length ? this._active[0].label : '', + title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', legendColors: colors, - legendBackgroundColor: this._options.multiTooltipKeyBackground, + legendBackgroundColor: this._options.tooltips.multiKeyBackground, }); // Calculate Appearance Tweaks - this.height = (labels.length * this.fontSize) + ((labels.length - 1) * (this.fontSize / 2)) + (this.yPadding * 2) + this.titleFontSize * 1.5; + this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; var titleWidth = ctx.measureText(this.title).width, //Label has a legend square as well so account for this. - labelWidth = longestText(ctx, this.font, labels) + this.fontSize + 3, + labelWidth = longestText(ctx, this.font, labels) + this._model.fontSize + 3, longestTextWidth = max([labelWidth, titleWidth]); - this.width = longestTextWidth + (this.xPadding * 2); + this._model.width = longestTextWidth + (this._model.xPadding * 2); - var halfHeight = this.height / 2; + var halfHeight = this._model.height / 2; //Check to ensure the height will fit on the canvas - if (this.y - halfHeight < 0) { - this.y = halfHeight; - } else if (this.y + halfHeight > this._chart.height) { - this.y = this._chart.height - halfHeight; + if (this._model.y - halfHeight < 0) { + this._model.y = halfHeight; + } else if (this._model.y + halfHeight > this._chart.height) { + this._model.y = this._chart.height - halfHeight; } //Decide whether to align left or right based on position on canvas - if (this.x > this._chart.width / 2) { - this.x -= this.xOffset + this.width; + if (this._model.x > this._chart.width / 2) { + this._model.x -= this._model.xOffset + this._model.width; } else { - this.x += this.xOffset; + this._model.x += this._model.xOffset; } break; } @@ -1582,9 +1731,9 @@ draw: function() { var ctx = this._chart.ctx; - var vm = this._vm; + var vm = this._view; - switch (this._options.hoverMode) { + switch (this._options.hover.mode) { case 'single': ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); @@ -1616,7 +1765,7 @@ // Custom Tooltips if (this._custom) { - this._custom(this._vm); + this._custom(this._view); } else { switch (vm.yAlign) { case "above": @@ -1682,8 +1831,8 @@ //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); //Instead we'll make a white filled block to put the legendColour palette over. - ctx.fillStyle = helpers.color(vm.legendBackgroundColor).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); @@ -1694,680 +1843,2095 @@ } }, getLineHeight: function(index) { - var baseLineHeight = this._vm.y - (this._vm.height / 2) + this._vm.yPadding, + var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, afterTitleIndex = index - 1; //If the index is zero, we're getting the title if (index === 0) { - return baseLineHeight + this._vm.titleFontSize / 2; + return baseLineHeight + this._view.titleFontSize / 2; } else { - return baseLineHeight + ((this._vm.fontSize * 1.5 * afterTitleIndex) + this._vm.fontSize / 2) + this._vm.titleFontSize * 1.5; + return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; } }, }); - Chart.Scale = Chart.Element.extend({ - initialize: function() { - this.fit(); - }, - buildYLabels: function() { - this.yLabels = []; + Chart.animationService = { + frameDuration: 17, + animations: [], + dropFrames: 0, + addAnimation: function(chartInstance, animationObject, duration) { - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); + if (!duration) { + chartInstance.animating = true; + } - for (var i = 0; i <= this.steps; i++) { - this.yLabels.push(template(this.templateString, { - value: (this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces) - })); + for (var index = 0; index < this.animations.length; ++index) { + if (this.animations[index].chartInstance === chartInstance) { + // replacing an in progress animation + this.animations[index].animationObject = animationObject; + return; + } } - this.yLabelWidth = (this.display && this.showLabels) ? longestText(this.ctx, this.font, this.yLabels) + 10 : 0; - }, - addXLabel: function(label) { - this.xLabels.push(label); - this.valuesCount++; - this.fit(); - }, - removeXLabel: function() { - this.xLabels.shift(); - this.valuesCount--; - this.fit(); - }, - // Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use - fit: function() { - // First we need the width of the yLabels, assuming the xLabels aren't rotated - // To do that we need the base line at the top and base of the chart, assuming there is no x label rotation - this.startPoint = (this.display) ? this.fontSize : 0; - this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels + this.animations.push({ + chartInstance: chartInstance, + animationObject: animationObject + }); - // Apply padding settings to the start and end point. - this.startPoint += this.padding; - this.endPoint -= this.padding; + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (this.animations.length == 1) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + }, + // Cancel the animation for a given chart instance + cancelAnimation: function(chartInstance) { + var index = helpers.findNextWhere(this.animations, function(animationWrapper) { + return animationWrapper.chartInstance === chartInstance; + }); - // Cache the starting endpoint, excluding the space for x labels - var cachedEndPoint = this.endPoint; + if (index) { + this.animations.splice(index, 1); + chartInstance.animating = false; + } + }, + // calls startDigest with the proper context + digestWrapper: function() { + Chart.animationService.startDigest.call(Chart.animationService); + }, + startDigest: function() { - // Cache the starting height, so can determine if we need to recalculate the scale yAxis - var cachedHeight = this.endPoint - this.startPoint, - cachedYLabelWidth; + var startTime = Date.now(); + var framesToDrop = 0; - // Build the current yLabels so we have an idea of what size they'll be to start - /* - * This sets what is returned from calculateScaleRange as static properties of this class: - * - this.steps; - this.stepValue; - this.min; - this.max; - * - */ - this.calculateYRange(cachedHeight); + if (this.dropFrames > 1) { + framesToDrop = Math.floor(this.dropFrames); + this.dropFrames -= framesToDrop; + } - // With these properties set we can now build the array of yLabels - // and also the width of the largest yLabel - this.buildYLabels(); + for (var i = 0; i < this.animations.length; i++) { - this.calculateXLabelRotation(); + if (this.animations[i].animationObject.currentStep === null) { + this.animations[i].animationObject.currentStep = 0; + } - while ((cachedHeight > this.endPoint - this.startPoint)) { - cachedHeight = this.endPoint - this.startPoint; - cachedYLabelWidth = this.yLabelWidth; + this.animations[i].animationObject.currentStep += 1 + framesToDrop; + if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { + this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; + } - this.calculateYRange(cachedHeight); - this.buildYLabels(); + this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); - // Only go through the xLabel loop again if the yLabel width has changed - if (cachedYLabelWidth < this.yLabelWidth) { - this.endPoint = cachedEndPoint; - this.calculateXLabelRotation(); + if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { + // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; + this.animations.splice(i, 1); + // Keep the index in place to offset the splice + i--; } } - }, - calculateXLabelRotation: function() { - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - - this.ctx.font = this.font; - - var firstWidth = this.ctx.measureText(this.xLabels[0]).width, - lastWidth = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width, - firstRotated, - lastRotated; - - - this.xScalePaddingRight = lastWidth / 2 + 3; - this.xScalePaddingLeft = (firstWidth / 2 > this.yLabelWidth) ? firstWidth / 2 : this.yLabelWidth; - - this.xLabelRotation = 0; - if (this.display) { - var originalLabelWidth = longestText(this.ctx, this.font, this.xLabels), - cosRotation, - firstRotatedWidth; - this.xLabelWidth = originalLabelWidth; - //Allow 3 pixels x2 padding either side for label readability - var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; + var endTime = Date.now(); + var delay = endTime - startTime - this.frameDuration; + var frameDelay = delay / this.frameDuration; - //Max label rotate should be 90 - also act as a loop counter - while ((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)) { - cosRotation = Math.cos(toRadians(this.xLabelRotation)); + if (frameDelay > 1) { + this.dropFrames += frameDelay; + } - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; + // Do we have more stuff to animate? + if (this.animations.length > 0) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + } + }; - // We're right aligning the text now. - if (firstRotated + this.fontSize / 2 > this.yLabelWidth) { - this.xScalePaddingLeft = firstRotated + this.fontSize / 2; + // Attach global event to resize each chart instance when the browser resizes + helpers.addEvent(window, "resize", (function() { + // Basic debounce of resize function so it doesn't hurt performance when resizing browser. + var timeout; + return function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + each(Chart.instances, function(instance) { + // If the responsive flag is set in the chart instance config + // Cascade the resize event down to the chart. + if (instance.options.responsive) { + instance.resize(); + instance.update(); + instance.render(); } - this.xScalePaddingRight = this.fontSize / 2; + }); + }, 50); + }; + })()); - this.xLabelRotation++; - this.xLabelWidth = cosRotation * originalLabelWidth; + if (amd) { + define(function() { + return Chart; + }); + } else if (typeof module === 'object' && module.exports) { + module.exports = Chart; + } - } - if (this.xLabelRotation > 0) { - this.endPoint -= Math.sin(toRadians(this.xLabelRotation)) * originalLabelWidth + 3; - } - } else { - this.xLabelWidth = 0; - this.xScalePaddingRight = this.padding; - this.xScalePaddingLeft = this.padding; - } + root.Chart = Chart; - }, - // Needs to be overidden in each Chart type - // Otherwise we need to pass all the data into the scale class - calculateYRange: noop, - drawingArea: function() { - return this.startPoint - this.endPoint; - }, - calculateY: function(value) { - var scalingFactor = this.drawingArea() / (this.min - this.max); - return this.endPoint - (scalingFactor * (value - this.min)); - }, - calculateX: function(index) { - var isRotated = (this.xLabelRotation > 0), - // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding, - innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight), - valueWidth = innerWidth / Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1), - valueOffset = (valueWidth * index) + this.xScalePaddingLeft; + Chart.noConflict = function() { + root.Chart = previous; + return Chart; + }; - if (this.offsetGridLines) { - valueOffset += (valueWidth / 2); - } +}).call(this); - return Math.round(valueOffset); - }, - update: function(newProps) { - helpers.extend(this, newProps); - this.fit(); - }, - draw: function() { - var ctx = this.ctx, - yLabelGap = (this.endPoint - this.startPoint) / this.steps, - xStart = Math.round(this.xScalePaddingLeft); - if (this.display) { - ctx.fillStyle = this.textColor; - ctx.font = this.font; - each(this.yLabels, function(labelString, index) { - var yLabelCenter = this.endPoint - (yLabelGap * index), - linePositionY = Math.round(yLabelCenter), - drawHorizontalLine = this.showHorizontalLines; - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - if (this.showLabels) { - ctx.fillText(labelString, xStart - 10, yLabelCenter); - } +(function() { + "use strict"; - // This is X axis, so draw it - if (index === 0 && !drawHorizontalLine) { - drawHorizontalLine = true; - } + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - if (drawHorizontalLine) { - ctx.beginPath(); - } + var defaultConfig = { - if (index > 0) { - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } + stacked: false, - linePositionY += helpers.aliasPixel(ctx.lineWidth); + hover: { + mode: "label" + }, - if (drawHorizontalLine) { - ctx.moveTo(xStart, linePositionY); - ctx.lineTo(this.width, linePositionY); - ctx.stroke(); - ctx.closePath(); - } + scales: { + xAxes: [{ + scaleType: "dataset", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: true, + }, - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - ctx.beginPath(); - ctx.moveTo(xStart - 5, linePositionY); - ctx.lineTo(xStart, linePositionY); - ctx.stroke(); - ctx.closePath(); + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, - }, this); + // scale numbers + beginAtZero: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, - each(this.xLabels, function(label, index) { - var xPos = this.calculateX(index) + aliasPixel(this.lineWidth), - // Check to see if line/bar here and decide where to place the line - linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth), - isRotated = (this.xLabelRotation > 0), - drawVerticalLine = this.showVerticalLines; + }; - // This is Y axis, so draw it - if (index === 0 && !drawVerticalLine) { - drawVerticalLine = true; - } - if (drawVerticalLine) { - ctx.beginPath(); - } + Chart.Type.extend({ + name: "Bar", + defaults: defaultConfig, + initialize: function() { - if (index > 0) { - // This is a grid line in the centre, so drop that - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - } else { - // This is the first line on the scale - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; - } + var _this = this; - if (drawVerticalLine) { - ctx.moveTo(linePos, this.endPoint); - ctx.lineTo(linePos, this.startPoint - 3); - ctx.stroke(); - ctx.closePath(); - } + // Events + helpers.bindEvents(this, this.options.events, this.events); + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Rectangle({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + })); + }, this); - ctx.lineWidth = this.lineWidth; - ctx.strokeStyle = this.lineColor; + // The bar chart only supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } + }, this); - // Small lines at the bottom of the base grid line - ctx.beginPath(); - ctx.moveTo(linePos, this.endPoint); - ctx.lineTo(linePos, this.endPoint + 5); - ctx.stroke(); - ctx.closePath(); + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); - ctx.save(); - ctx.translate(xPos, (isRotated) ? this.endPoint + 12 : this.endPoint + 8); - ctx.rotate(toRadians(this.xLabelRotation) * -1); - ctx.font = this.font; - ctx.textAlign = (isRotated) ? "right" : "center"; - ctx.textBaseline = (isRotated) ? "middle" : "top"; - ctx.fillText(label, 0, 0); - ctx.restore(); - }, this); + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); - } - } + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - }); + // So that we animate from the baseline + this.resetElements(); - Chart.RadialScale = Chart.Element.extend({ - initialize: function() { - this.size = min([this.height, this.width]); - this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + // Update the chart with the latest data. + this.update(); }, - calculateCenterOffset: function(value) { - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); + resetElements: function() { + // Update the points + this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - return (value - this.min) * scalingFactor; - }, - update: function() { - if (!this.lineArc) { - this.setScaleSize(); - } else { - this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); - } - this.buildYLabels(); - }, - buildYLabels: function() { - this.yLabels = []; + var yScalePoint; - var stepDecimalPlaces = getDecimalPlaces(this.stepValue); + if (yScale.min < 0 && yScale.max <0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } - for (var i = 0; i <= this.steps; i++) { - this.yLabels.push(template(this.templateString, { - value: (this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces) - })); - } - }, - getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); + helpers.extend(bar, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScalePoint, + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), + + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + }, + }); + bar.pivot(); + }, this); }, - setScaleSize: function() { - /* - * Right, this is really confusing and there is a lot of maths going on here - * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 - * - * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif - * - * Solution: - * - * We assume the radius of the polygon is half the size of the canvas at first - * at each index we check if the text overlaps. - * - * Where it does, we store that angle and that index. - * - * After finding the largest index and angle we calculate how much we need to remove - * from the shape radius to move the point inwards by that x. - * - * We average the left and right distances to get the maximum shape radius that can fit in the box - * along with labels. - * - * Once we have that, we can find the centre point for the chart, by taking the x text protrusion - * on each side, removing that from the size, halving it and adding the left x protrusion width. - * - * This will mean we have a shape fitted to the canvas, as large as it can be with the labels - * and position it in the most space efficient manner - * - * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - */ + update: function() { + // Update the scale sizes + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + // Update the points + this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points - var largestPossibleRadius = min([(this.height / 2 - this.pointLabelFontSize - 5), this.width / 2]), - pointPosition, - i, - textWidth, - halfTextWidth, - furthestRight = this.width, - furthestRightIndex, - furthestRightAngle, - furthestLeft = 0, - furthestLeftIndex, - furthestLeftAngle, - xProtrusionLeft, - xProtrusionRight, - radiusReductionRight, - radiusReductionLeft, - maxWidthRadius; - this.ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); - for (i = 0; i < this.valuesCount; i++) { - // 5px to space the text slightly out - similar to what we do in the draw function. - pointPosition = this.getPointPosition(i, largestPossibleRadius); - textWidth = this.ctx.measureText(template(this.templateString, { - value: this.labels[i] - })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { - // If we're at index zero, or exactly the middle, we're at exactly the top/bottom - // of the radar chart, so text will be aligned centrally, so we'll half it and compare - // w/left and right text sizes - halfTextWidth = textWidth / 2; - if (pointPosition.x + halfTextWidth > furthestRight) { - furthestRight = pointPosition.x + halfTextWidth; - furthestRightIndex = i; - } - if (pointPosition.x - halfTextWidth < furthestLeft) { - furthestLeft = pointPosition.x - halfTextWidth; - furthestLeftIndex = i; - } - } else if (i < this.valuesCount / 2) { - // Less than half the values means we'll left align the text - if (pointPosition.x + textWidth > furthestRight) { - furthestRight = pointPosition.x + textWidth; - furthestRightIndex = i; - } - } else if (i > this.valuesCount / 2) { - // More than half the values means we'll right align the text - if (pointPosition.x - textWidth < furthestLeft) { - furthestLeft = pointPosition.x - textWidth; - furthestLeftIndex = i; - } - } - } + helpers.extend(bar, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, - xProtrusionLeft = furthestLeft; + // Desired view properties + _model: { + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScale.calculateBarY(datasetIndex, index), + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), + + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + }, + }); + bar.pivot(); + }, this); - xProtrusionRight = Math.ceil(furthestRight - this.width); - furthestRightAngle = this.getIndexAngle(furthestRightIndex); + this.render(); + }, + buildScale: function(labels) { + var self = this; - furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); + // Function to determine the range of all the + var calculateYRange = function() { + this.min = null; + this.max = null; - radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); + var positiveValues = []; + var negativeValues = []; - radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + if (self.options.stacked) { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + + if (self.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); + } + }, this); - // Ensure we actually need to reduce the size of the chart - radiusReductionRight = (isNumber(radiusReductionRight)) ? radiusReductionRight : 0; - radiusReductionLeft = (isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); - this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; + } else { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } - //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) - this.setCenterPoint(radiusReductionLeft, radiusReductionRight); + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }; - }, - setCenterPoint: function(leftMovement, rightMovement) { + // Map of scale ID to scale object so we can lookup later + this.scales = {}; - var maxRight = this.width - rightMovement - this.drawingArea, - maxLeft = leftMovement + this.drawingArea; + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); + var xScale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scales.xAxes[0], + id: this.options.scales.xAxes[0].id, + calculateRange: function() { + this.labels = self.data.labels; + this.min = 0; + this.max = this.labels.length; + }, + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.elements.bar.valueSpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.elements.bar.datasetSpacing); - this.xCenter = (maxLeft + maxRight) / 2; - // Always vertically in the centre as the text height doesn't change - this.yCenter = (this.height / 2); - }, + if (self.options.stacked) { + return baseWidth; + } + return (baseWidth / datasetCount); + }, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); - getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; - // Start from the top instead of right, so remove a quarter of the circle + if (self.options.stacked) { + return xAbsolute + barWidth / 2; + } - return index * angleMultiplier - (Math.PI / 2); - }, - getPointPosition: function(index, distanceFromCenter) { - var thisAngle = this.getIndexAngle(index); - return { - x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, - y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter - }; - }, - draw: function() { - if (this.display) { - var ctx = this.ctx; - each(this.yLabels, function(label, index) { - // Don't draw a centre value - if (index > 0) { - var yCenterOffset = index * (this.drawingArea / this.steps), - yHeight = this.yCenter - yCenterOffset, - pointPosition; + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.elements.bar.datasetSpacing) + barWidth / 2; + }, + }); + this.scales[xScale.id] = xScale; - // Draw circular lines around the scale - if (this.lineWidth > 0) { - ctx.strokeStyle = this.lineColor; - ctx.lineWidth = this.lineWidth; + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + calculateRange: calculateYRange, + calculateBarBase: function(datasetIndex, index) { + var base = 0; - if (this.lineArc) { - ctx.beginPath(); - ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); - ctx.closePath(); - ctx.stroke(); + if (self.options.stacked) { + + var value = self.data.datasets[datasetIndex].data[index]; + + if (value < 0) { + for (var i = 0; i < datasetIndex; i++) { + if (self.data.datasets[i].yAxisID === this.id) { + base += self.data.datasets[i].data[index] < 0 ? self.data.datasets[i].data[index] : 0; + } + } } else { - ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { - pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.min + (index * this.stepValue))); - if (i === 0) { - ctx.moveTo(pointPosition.x, pointPosition.y); - } else { - ctx.lineTo(pointPosition.x, pointPosition.y); + for (var j = 0; j < datasetIndex; j++) { + if (self.data.datasets[j].yAxisID === this.id) { + base += self.data.datasets[j].data[index] > 0 ? self.data.datasets[j].data[index] : 0; } } - ctx.closePath(); - ctx.stroke(); - } - } - if (this.showLabels) { - ctx.font = fontString(this.fontSize, this._fontStyle, this._fontFamily); - if (this.showLabelBackdrop) { - var labelWidth = ctx.measureText(label).width; - ctx.fillStyle = this.backdropColor; - ctx.fillRect( - this.xCenter - labelWidth / 2 - this.backdropPaddingX, - yHeight - this.fontSize / 2 - this.backdropPaddingY, - labelWidth + this.backdropPaddingX * 2, - this.fontSize + this.backdropPaddingY * 2 - ); } - ctx.textAlign = 'center'; - ctx.textBaseline = "middle"; - ctx.fillStyle = this.fontColor; - ctx.fillText(label, this.xCenter, yHeight); + + return this.getPixelForValue(base); } - } - }, this); - if (!this.lineArc) { - ctx.lineWidth = this.angleLineWidth; - ctx.strokeStyle = this.angleLineColor; - for (var i = this.valuesCount - 1; i >= 0; i--) { - if (this.angleLineWidth > 0) { - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); - ctx.beginPath(); - ctx.moveTo(this.xCenter, this.yCenter); - ctx.lineTo(outerPosition.x, outerPosition.y); - ctx.stroke(); - ctx.closePath(); + base = this.getPixelForValue(this.min); + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.getPixelForValue(0); + base += this.options.gridLines.lineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.getPixelForValue(this.max); } - // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); - ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily); - ctx.fillStyle = this.pointLabelFontColor; - var labelsCount = this.labels.length, - halfLabelsCount = this.labels.length / 2, - quarterLabelsCount = halfLabelsCount / 2, - upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), - exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); - if (i === 0) { - ctx.textAlign = 'center'; - } else if (i === halfLabelsCount) { - ctx.textAlign = 'center'; - } else if (i < halfLabelsCount) { - ctx.textAlign = 'left'; - } else { - ctx.textAlign = 'right'; + return base; + + }, + calculateBarY: function(datasetIndex, index) { + + var value = self.data.datasets[datasetIndex].data[index]; + + if (self.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (self.data.datasets[i].data[index] < 0) { + sumNeg += self.data.datasets[i].data[index] || 0; + } else { + sumPos += self.data.datasets[i].data[index] || 0; + } + } + + if (value < 0) { + return this.getPixelForValue(sumNeg + value); + } else { + return this.getPixelForValue(sumPos + value); + } + + return this.getPixelForValue(value); } - // Set the correct text baseline based on outer positioning - if (exactQuarter) { - ctx.textBaseline = 'middle'; - } else if (upperHalf) { - ctx.textBaseline = 'bottom'; - } else { - ctx.textBaseline = 'top'; + var offset = 0; + + for (var j = datasetIndex; j < self.data.datasets.length; j++) { + if (j === datasetIndex && value) { + offset += value; + } else { + offset = offset + value; + } } - ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); - } - } + return this.getPixelForValue(value); + }, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + //Draw all the bars for each dataset + this.eachElement(function(bar, index, datasetIndex) { + bar.transition(easingDecimal).draw(); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + + // If exiting chart + if (e.type == 'mouseout') { + return this; } - } - }); - Chart.animationService = { - frameDuration: 17, - animations: [], - dropFrames: 0, - addAnimation: function(chartInstance, animationObject, duration) { + this.lastActive = this.lastActive || []; - if (!duration) { - chartInstance.animating = true; + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); } - for (var index = 0; index < this.animations.length; ++index) { - if (this.animations[index].chartInstance === chartInstance) { - // replacing an in progress animation - this.animations[index].animationObject = animationObject; - return; + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); } } - this.animations.push({ - chartInstance: chartInstance, - animationObject: animationObject - }); + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; - // If there are no animations queued, manually kickstart a digest, for lack of a better word - if (this.animations.length == 1) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - }, - // Cancel the animation for a given chart instance - cancelAnimation: function(chartInstance) { - var index = helpers.findNextWhere(this.animations, function(animationWrapper) { - return animationWrapper.chartInstance === chartInstance; - }); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; - if (index) { - this.animations.splice(index, 1); - chartInstance.animating = false; + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } } - }, - // calls startDigest with the proper context - digestWrapper: function() { - Chart.animationService.startDigest.call(Chart.animationService); - }, - startDigest: function() { - var startTime = Date.now(); - var framesToDrop = 0; + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; - if (this.dropFrames > 1) { - framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } } - for (var i = 0; i < this.animations.length; i++) { - if (this.animations[i].animationObject.currentStep === null) { - this.animations[i].animationObject.currentStep = 0; - } + // Built in Tooltips + if (this.options.tooltips.enabled) { - this.animations[i].animationObject.currentStep += 1 + framesToDrop; - if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { - this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; - } + // The usual updates + this.tooltip.initialize(); - this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; - if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { - // executed the last frame. Remove the animation. - this.animations[i].chartInstance.animating = false; - this.animations.splice(i, 1); - // Keep the index in place to offset the splice - i--; + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; } } - var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; - if (frameDelay > 1) { - this.dropFrames += frameDelay; - } + this.tooltip.pivot(); + + // Hover animations + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + }); + + +}).call(this); + +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; + + var defaultConfig = { + + animation: { + //Boolean - Whether we animate the rotation of the Doughnut + animateRotate: true, + + //Boolean - Whether we animate scaling the Doughnut from the centre + animateScale: false, + }, + + //The percentage of the chart that we cut out of the middle. + + cutoutPercentage: 50, + + }; + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "Doughnut", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { + + //Set up tooltip events on the chart + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.resetElements(); + + // Update the chart with the latest data. + this.update(); + + }, + + calculateCircumference: function(dataset, value) { + if (dataset.total > 0) { + return (Math.PI * 2) * (value / dataset.total); + } else { + return 0; + } + }, + resetElements: function() { + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; + + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + // So that calculateCircumference works + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + helpers.extend(slice, { + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, + innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + slice.pivot(); + }, this); + + }, this); + }, + update: function() { + + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; + + + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + + helpers.extend(slice, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + circumference: this.calculateCircumference(dataset, dataset.data[index]), + outerRadius: dataset.outerRadius, + innerRadius: dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + if (index === 0) { + slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + } else { + slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; + } + + slice._model.endAngle = slice._model.startAngle + slice._model.circumference; + + + //Check to see if it's the last slice, if not get the next and update its start angle + if (index < dataset.data.length - 1) { + dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; + } + + slice.pivot(); + }, this); + + }, this); + + this.render(); + }, + draw: function(easeDecimal) { + easeDecimal = easeDecimal || 1; + this.clear(); + + this.eachElement(function(slice) { + slice.transition(easeDecimal).draw(); + }, this); + + this.tooltip.transition(easeDecimal).draw(); + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); + + Chart.types.Doughnut.extend({ + name: "Pie", + defaults: helpers.merge(defaultConfig, { + cutoutPercentage: 0 + }) + }); + +}).call(this); + +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + + stacked: false, + + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + scaleType: "dataset", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + beginAtZero: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, + }; + + + Chart.Type.extend({ + name: "Line", + defaults: defaultConfig, + initialize: function() { + + var _this = this; + + // Events + helpers.bindEvents(this, this.options.events, this.events); + + // Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); + + dataset.metaData = []; + + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + + }, this); + + // The line chart onlty supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; + + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } + + }, this); + + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[index]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[index]; + }, + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max <0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScalePoint, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function() { + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + var yScale = this.scales[dataset.yAxisID]; + + helpers.extend(dataset.metaDataset, { + // Utility + _scale: yScale, + _datasetIndex: datasetIndex, + // Data + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: yScale.getPixelForValue(0), + }, + }); + + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(); + }, + buildScale: function() { + var self = this; + + // Function to determine the range of all the + var calculateYRange = function() { + this.min = null; + this.max = null; + + var positiveValues = []; + var negativeValues = []; + + if (self.options.stacked) { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + + if (self.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); + } + }, this); + + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); + } else { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }; + + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); + var xScale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scales.xAxes[0], + calculateRange: function() { + this.labels = self.data.labels; + this.min = 0; + this.max = this.labels.length; + }, + id: this.options.scales.xAxes[0].id, + }); + this.scales[xScale.id] = xScale; + + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + calculateRange: calculateYRange, + getPointPixelForValue: function(value, index, datasetIndex) { + if (self.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + + for (var i = 0; i < datasetIndex; ++i) { + if (self.data.datasets[i].data[index] < 0) { + offsetNeg += self.data.datasets[i].data[index]; + } else { + offsetPos += self.data.datasets[i].data[index]; + } + } + + if (value < 0) { + return this.getPixelForValue(offsetNeg + value); + } else { + return this.getPixelForValue(offsetPos + value); + } + } else { + return this.getPixelForValue(value); + } + }, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + }); + + +}).call(this); + +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; + + var defaultConfig = { + + scale: { + scaleType: "radialLinear", + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate: false, + + lineArc: true, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, + + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + } + }, + + //Boolean - Whether to animate the rotation of the chart + animateRotate: true, + }; + + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "PolarArea", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { + + // Scale setup + var self = this; + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleClass({ + options: this.options.scale, + lineArc: true, + width: this.chart.width, + height: this.chart.height, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + valuesCount: this.data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets[0].data, function(value) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }); + + helpers.bindEvents(this, this.options.events, this.events); + + //Set up tooltip events on the chart + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Fit the scale before we animate + this.updateScaleRange(); + this.scale.calculateRange(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // so that we animate nicely + this.resetElements(); + + // Update the chart with the latest data. + this.update(); + + }, + updateScaleRange: function() { + helpers.extend(this.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2 + }); + }, + resetElements: function() { + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: 0, + startAngle: Math.PI * 1.5, + endAngle: Math.PI * 1.5, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + + slice.pivot(); + }, this); + }, + update: function() { + + this.updateScaleRange(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: this.scale.calculateCenterOffset(value), + startAngle: startAngle, + endAngle: endAngle, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + slice.pivot(); + + console.log(slice); + + }, this); + + this.render(); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + + this.clear(); + + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + slice.transition(easingDecimal).draw(); + }, this); + + this.scale.draw(); + + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); - // Do we have more stuff to animate? - if (this.animations.length > 0) { - helpers.requestAnimFrame.call(window, this.digestWrapper); + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } } - } - }; - // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function() { - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function() { - clearTimeout(timeout); - timeout = setTimeout(function() { - each(Chart.instances, function(instance) { - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive) { - instance.resize(); - instance.update(); - instance.render(); - } - }); - }, 50); - }; - })()); + // Remember Last Active + this.lastActive = this.active; + return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + var location = helpers.getRelativePosition(e); - if (amd) { - define(function() { - return Chart; - }); - } else if (typeof module === 'object' && module.exports) { - module.exports = Chart; - } + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; - root.Chart = Chart; + var location = helpers.getRelativePosition(e); - Chart.noConflict = function() { - root.Chart = previous; - return Chart; - }; + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); }).call(this); @@ -2379,203 +3943,360 @@ helpers = Chart.helpers; - var defaultConfig = { - //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)", + Chart.Type.extend({ + name: "Radar", + defaults: { - //Number - Width of the grid lines - scaleGridLineWidth: 1, + scale: { + scaleType: "radialLinear", + display: true, - //Boolean - Whether to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, + //Boolean - Whether to animate scaling the chart from the centre + animate: false, - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, + lineArc: false, - //Number - Pixel width of the bar border - barBorderWidth: 2, + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, - //Number - Spacing between each of the X value sets - barValueSpacing: 5, + angleLines: { + show: true, + color: "rgba(0,0,0,.1)", + lineWidth: 1 + }, - //Number - Spacing between data sets within X values - barDatasetSpacing: 1, + // scale numbers + beginAtZero: true, - //Boolean - Whether bars should be rendered on a percentage base - relativeBars: false, + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, - }; + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, - Chart.Type.extend({ - name: "Bar", - defaults: defaultConfig, - initialize: function(data) { + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + }, - // Save data as a source for updating of values & methods - this.data = data; + pointLabels: { + //String - Point label font declaration + fontFamily: "'Arial'", - var options = this.options; + //String - Point label font weight + fontStyle: "normal", - var _this = this; + //Number - Point label font size in pixels + fontSize: 10, - // Custom Scale Methods and Options - this.ScaleClass = Chart.Scale.extend({ - offsetGridLines: true, - calculateBarBase: function(datasetIndex, index) { + //String - Point label font colour + fontColor: "#666", + }, + }, - var base = 0; + elements: { + line: { + tension: 0, // no bezier in radar + } + }, - if (_this.options.stacked) { - var bar = _this.data.datasets[datasetIndex].metaData[index]; - if (bar.value < 0) { - for (var i = 0; i < datasetIndex; i++) { - base += _this.data.datasets[i].metaData[index].value < base ? _this.data.datasets[i].metaData[index].value : 0; - } - } else { - for (var i = 0; i < datasetIndex; i++) { - base += _this.data.datasets[i].metaData[index].value > base ? _this.data.datasets[i].metaData[index].value : 0; - } - } - return this.calculateY(base); - } + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - base = this.endPoint; + }, - if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { - base = this.calculateY(0); - base += _this.options.scaleGridLineWidth; - } else if (this.min < 0 && this.max < 0) { - // All values are negative. Use the top as the base - base = this.startPoint; - } + initialize: function() { + // Events + helpers.bindEvents(this, this.options.events, this.events); - return base; + // Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { - }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.calculateX(elementIndex) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + _loop: true + }); - if (_this.options.stacked) { - return xAbsolute + barWidth / 2; - } + dataset.metaData = []; - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth / 2; - }, - calculateBarY: function(datasets, datasetIndex, barIndex, value) { + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); - if (_this.options.stacked) { + }, this); + }, this); - var sumPos = 0, - sumNeg = 0; + // Build the scale. + this.buildScale(); - for (var i = 0; i < datasetIndex; i++) { - if (datasets[i].metaData[barIndex].value < 0) { - sumNeg += datasets[i].metaData[barIndex].value || 0; - } else { - sumPos += datasets[i].metaData[barIndex].value || 0; - } - } + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); - if (value < 0) { - return this.calculateY(sumNeg + value); - } else { - return this.calculateY(sumPos + value); - } + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - /*if (options.relativeBars) { - offset = offset / sum * 100; - }*/ + // Reset so that we animation from the baseline + this.resetElements(); - return this.calculateY(0); - } + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[0]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[collection.length - 1]; + }, + resetElements: function() { - var offset = 0; + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _scale: this.scale, + + // Desired view properties + _model: { + x: this.scale.xCenter, + y: this.scale.yCenter, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); - for (i = datasetIndex; i < datasets.length; i++) { - if (i === datasetIndex && value) { - offset += value; - } else { - offset = offset + (datasets[i].metaData[barIndex].value); - } - } + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); - return this.calculateY(value); - }, - calculateBaseWidth: function() { - return (this.calculateX(1) - this.calculateX(0)) - (2 * options.barValueSpacing); - }, - calculateBaseHeight: function() { - return (this.calculateY(1) - this.calculateY(0)); - }, - calculateBarWidth: function(datasetCount) { + point._model.controlPointPreviousX = this.scale.xCenter; + point._model.controlPointPreviousY = this.scale.yCenter; + point._model.controlPointNextX = this.scale.xCenter; + point._model.controlPointNextY = this.scale.yCenter; - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing); + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function() { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - if (_this.options.stacked) { - return baseWidth; - } - return (baseWidth / datasetCount); - }, - }); + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + helpers.extend(dataset.metaDataset, { + // Utility + _datasetIndex: datasetIndex, - // Events - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); + // Data + _children: dataset.metaData, + + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + + // Scale + scaleTop: this.scale.top, + scaleBottom: this.scale.bottom, + scaleZero: this.scale.getPointPosition(0), + }, + }); - //Declare the extension of the default point, to cater for the options passed in to the constructor - this.BarClass = Chart.Rectangle.extend({ - ctx: this.chart.ctx, + dataset.metaDataset.pivot(); }); - // Build Scale - this.buildScale(this.data.labels); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new this.BarClass()); - }, this); - }, this); + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); - // Set defaults for bars - this.eachElement(function(bar, index, dataset, datasetIndex) { - helpers.extend(bar, { - base: this.scale.zeroPoint, - width: this.scale.calculateBarWidth(this.data.datasets.length), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), + helpers.extend(point, { + // Utility + _chart: this.chart, _datasetIndex: datasetIndex, _index: index, + + // Desired view properties + _model: { + x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: pointPosition.y, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, }); - // Copy to view model - bar.save(); }, this); - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); }, this); - // Update the chart with the latest data. - this.update(); + this.render(); + }, + buildScale: function() { + var self = this; + + var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleConstructor({ + options: this.options.scale, + height: this.chart.height, + width: this.chart.width, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + labels: this.data.labels, + valuesCount: this.data.datasets[0].data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }); + + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + this.scale.draw(this.chartArea); + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); }, - onHover: function(e) { - + events: function(e) { // If exiting chart if (e.type == 'mouseout') { @@ -2586,7 +4307,7 @@ // Find Active Elements this.active = function() { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': return this.getElementAtEvent(e); case 'label': @@ -2599,21 +4320,39 @@ }.call(this); // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } } + var dataset; + var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': - this.lastActive[0].backgroundColor = this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor; - this.lastActive[0].borderColor = this.data.datasets[this.lastActive[0]._datasetIndex].borderColor; + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { - this.lastActive[i].backgroundColor = this.data.datasets[this.lastActive[i]._datasetIndex].backgroundColor; - this.lastActive[i].borderColor = this.data.datasets[this.lastActive[i]._datasetIndex].borderColor; + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); } break; case 'dataset': @@ -2624,16 +4363,26 @@ } // Built in hover styling - if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { case 'single': - this.active[0].backgroundColor = this.data.datasets[this.active[0]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[0].backgroundColor).saturate(0.8).darken(0.2).rgbString(); - this.active[0].borderColor = this.data.datasets[this.active[0]._datasetIndex].hoverBorderColor || helpers.color(this.active[0].borderColor).saturate(0.8).darken(0.2).rgbString(); + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.active[i].backgroundColor = this.data.datasets[this.active[i]._datasetIndex].hoverBackgroundColor || helpers.color(this.active[i].backgroundColor).saturate(0.8).darken(0.2).rgbString(); - this.active[i].borderColor = this.data.datasets[this.active[i]._datasetIndex].hoverBorderColor || helpers.color(this.active[i].borderColor).saturate(0.8).darken(0.2).rgbString(); + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); } break; case 'dataset': @@ -2643,33 +4392,30 @@ } } - // Built in Tooltips - if (this.options.showTooltips) { + if (this.options.tooltips.enabled) { // The usual updates this.tooltip.initialize(); // Active if (this.active.length) { + this.tooltip._model.opacity = 1; + helpers.extend(this.tooltip, { - opacity: 1, _active: this.active, }); this.tooltip.update(); } else { // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.tooltip._model.opacity = 0; } } - + // Hover animations this.tooltip.pivot(); - // Hover animations if (!this.animating) { var changed; @@ -2685,7 +4431,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hoverAnimationDuration); + this.render(this.options.hover.animationDuration); } } @@ -2693,404 +4439,1163 @@ this.lastActive = this.active; return this; }, - update: function() { + }); +}).call(this); - this.scale.update(); +(function() { + "use strict"; - this.eachElement(function(bar, index, dataset, datasetIndex) { - helpers.extend(bar, { - value: this.data.datasets[datasetIndex].data[index], - }); - bar.pivot(); - }, this); + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - this.eachElement(function(bar, index, dataset, datasetIndex) { - helpers.extend(bar, { - base: this.scale.calculateBarBase(datasetIndex, index), - x: this.scale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: this.scale.calculateBarY(this.data.datasets, datasetIndex, index, this.data.datasets[datasetIndex].data[index]), - width: this.scale.calculateBarWidth(this.data.datasets.length), - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - borderColor: this.data.datasets[datasetIndex].borderColor, - borderWidth: this.data.datasets[datasetIndex].borderWidth, - backgroundColor: this.data.datasets[datasetIndex].backgroundColor, - _datasetIndex: datasetIndex, - _index: index, + // The scale service is used to resize charts along with all of their axes. We make this as + // a service where scales are registered with their respective charts so that changing the + // scales does not require + Chart.scaleService = { + // The interesting function + fitScalesForChart: function(chartInstance, width, height) { + var xPadding = 10; + var yPadding = 10; + + if (chartInstance) { + var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "left"; + }); + var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "right"; + }); + var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "top"; + }); + var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "bottom"; }); - bar.pivot(); - }, this); - this.render(); - }, - buildScale: function(labels) { - var self = this; + // Adjust the padding to take into account displaying labels + if (topScales.length === 0 || bottomScales.length === 0) { + var maxFontHeight = 0; - var dataTotal = function() { - var values = []; - var negativeValues = []; + var maxFontHeightFunction = function(scaleInstance) { + if (scaleInstance.options.labels.show) { + // Only consider font sizes for axes that actually show labels + maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); + } + }; - if (self.options.stacked) { - self.eachValue(function(value, index) { - values[index] = values[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - if (self.options.relativeBars) { - values[index] = 100; + helpers.each(leftScales, maxFontHeightFunction); + helpers.each(rightScales, maxFontHeightFunction); + + if (topScales.length === 0) { + // Add padding so that we can handle drawing the top nicely + yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides + } + + if (bottomScales.length === 0) { + // Add padding so that we can handle drawing the bottom nicely + yPadding += 1.5 * maxFontHeight; + } + } + + // Essentially we now have any number of scales on each of the 4 sides. + // Our canvas looks like the following. + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and + // B1 is the bottom axis + // |------------------------------------------------------| + // | | T1 | | + // |----|-----|-------------------------------------|-----| + // | | | | | + // | L1 | L2 | Chart area | R1 | + // | | | | | + // | | | | | + // |----|-----|-------------------------------------|-----| + // | | B1 | | + // | | | | + // |------------------------------------------------------| + + // What we do to find the best sizing, we do the following + // 1. Determine the minimum size of the chart area. + // 2. Split the remaining width equally between each vertical axis + // 3. Split the remaining height equally between each horizontal axis + // 4. Give each scale the maximum size it can be. The scale will return it's minimum size + // 5. Adjust the sizes of each axis based on it's minimum reported size. + // 6. Refit each axis + // 7. Position each axis in the final location + // 8. Tell the chart the final location of the chart area + + // Step 1 + var chartWidth = width / 2; // min 50% + var chartHeight = height / 2; // min 50% + var aspectRatio = chartHeight / chartWidth; + var screenAspectRatio; + + if (chartInstance.options.maintainAspectRatio) { + screenAspectRatio = height / width; + + if (aspectRatio != screenAspectRatio) { + chartHeight = chartWidth * screenAspectRatio; + aspectRatio = screenAspectRatio; + } + } + + chartWidth -= (2 * xPadding); + chartHeight -= (2 * yPadding); + + // Step 2 + var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); + + // Step 3 + var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); + + // Step 4; + var minimumScaleSizes = []; + + var verticalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); + minimumScaleSizes.push({ + horizontal: false, + minSize: minSize, + scale: scaleInstance, + }); + }; + + var horizontalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); + minimumScaleSizes.push({ + horizontal: true, + minSize: minSize, + scale: scaleInstance, + }); + }; + + // vertical scales + helpers.each(leftScales, verticalScaleMinSizeFunction); + helpers.each(rightScales, verticalScaleMinSizeFunction); + + // horizontal scales + helpers.each(topScales, horizontalScaleMinSizeFunction); + helpers.each(bottomScales, horizontalScaleMinSizeFunction); + + // Step 5 + var maxChartHeight = height - (2 * yPadding); + var maxChartWidth = width - (2 * xPadding); + + helpers.each(minimumScaleSizes, function(wrapper) { + if (wrapper.horizontal) { + maxChartHeight -= wrapper.minSize.height; + } else { + maxChartWidth -= wrapper.minSize.width; + } + }); + + // At this point, maxChartHeight and maxChartWidth are the size the chart area could + // be if the axes are drawn at their minimum sizes. + if (chartInstance.options.maintainAspectRatio) { + // Figure out what the real max size will be + var maxAspectRatio = maxChartHeight / maxChartWidth; + + if (maxAspectRatio != screenAspectRatio) { + // Need to adjust + if (maxChartHeight < maxChartWidth) { + maxChartWidth = maxChartHeight / screenAspectRatio; } else { - if (value < 0) { - negativeValues[index] += value; - } else { - values[index] += value; - } + maxChartHeight = maxChartWidth * screenAspectRatio; } - }); - return values.concat(negativeValues); + } } - self.eachValue(function(value, index) { - values.push(value); - }); + // Step 6 + var verticalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); - return values; + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight); + } + }; - }; + var horizontalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); - var scaleOptions = { - 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: labels.length, - beginAtZero: this.options.scaleBeginAtZero, - integersOnly: this.options.scaleIntegersOnly, - calculateYRange: function(currentHeight) { - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); - }, - xLabels: labels, - font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth: this.options.scaleLineWidth, - lineColor: this.options.scaleLineColor, - showHorizontalLines: this.options.scaleShowHorizontalLines, - showVerticalLines: this.options.scaleShowVerticalLines, - 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.borderWidth, - showLabels: this.options.scaleShowLabels, - display: this.options.showScale - }; + if (wrapper) { + scaleInstance.fit(maxChartWidth, wrapper.minSize.width); + } + }; + + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); + + // Step 7 + var totalLeftWidth = xPadding; + var totalTopHeight = yPadding; + + // Calculate total width of all left axes + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); - if (this.options.scaleOverride) { - helpers.extend(scaleOptions, { - calculateYRange: helpers.noop, - steps: this.options.scaleSteps, - stepValue: this.options.scaleStepWidth, - min: this.options.scaleStartValue, - max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth) + // Calculate total height of all top axes + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; }); + + // Position the scales + var left = xPadding; + var top = yPadding; + var right = 0; + var bottom = 0; + + var verticalScalePlacer = function(scaleInstance) { + scaleInstance.left = left; + scaleInstance.right = left + scaleInstance.width; + scaleInstance.top = totalTopHeight; + scaleInstance.bottom = totalTopHeight + maxChartHeight; + + // Move to next point + left = scaleInstance.right; + }; + + var horizontalScalePlacer = function(scaleInstance) { + scaleInstance.left = totalLeftWidth; + scaleInstance.right = totalLeftWidth + maxChartWidth; + scaleInstance.top = top; + scaleInstance.bottom = top + scaleInstance.height; + + // Move to next point + top = scaleInstance.bottom; + }; + + helpers.each(leftScales, verticalScalePlacer); + helpers.each(topScales, horizontalScalePlacer); + + // Account for chart width and height + left += maxChartWidth; + top += maxChartHeight; + + helpers.each(rightScales, verticalScalePlacer); + helpers.each(bottomScales, horizontalScalePlacer); + + // Step 8 + chartInstance.chartArea = { + left: totalLeftWidth, + top: totalTopHeight, + right: totalLeftWidth + maxChartWidth, + bottom: totalTopHeight + maxChartHeight, + }; } + } + }; - this.scale = new this.ScaleClass(scaleOptions); + // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then + // use the new chart options to grab the correct scale + Chart.scales = { + constructors: {}, + // Use a registration function so that we can move to an ES6 map when we no longer need to support + // old browsers + registerScaleType: function(scaleType, scaleConstructor) { + this.constructors[scaleType] = scaleConstructor; }, - // This should be incorportated into the init as something like a default value. "Reflow" seems like a weird word for a fredraw function - redraw: function() { - var base = this.scale.zeroPoint; - this.eachElement(function(element, index, datasetIndex) { - helpers.extend(element, { - y: base, - base: base - }); - }); - this.render(); + getScaleConstructor: function(scaleType) { + return this.constructors.hasOwnProperty(scaleType) ? this.constructors[scaleType] : undefined; + } + }; + + var LinearScale = Chart.Element.extend({ + calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; }, - draw: function(ease) { + generateTicks: function(width, height) { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph - var easingDecimal = ease || 1; - this.clear(); + var maxTicks; + + if (this.isHorizontal()) { + maxTicks = Math.min(11, Math.ceil(width / 50)); + } else { + // The factor of 2 used to scale the font size has been experimentally determined. + maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); + } - this.scale.draw(easingDecimal); + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } - //Draw all the bars for each dataset - this.eachElement(function(bar, index, datasetIndex) { - bar.transition(easingDecimal).draw(); + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + this.labels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.lables.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.labels.push(label ? label : ""); // empty string will not render so we're good }, this); + }, + getPixelForValue: function(value) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + var pixel; + var range = this.max - this.min; + + if (this.isHorizontal()) { + pixel = this.left + (this.width / range * (value - this.min)); + } else { + // Bottom - top since pixels increase downard on a screen + pixel = this.bottom - (this.height / range * (value - this.min)); + } - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); + return pixel; + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.generateTicks(maxWidth, maxHeight); + this.buildLabels(); + + var minSize = { + width: 0, + height: 0, + }; + + if (this.isHorizontal()) { + minSize.width = maxWidth; // fill all the width + + // In a horizontal axis, we need some room for the scale to be drawn + // + // ----------------------------------------------------- + // | | | | | + // + minSize.height = this.options.gridLines.show ? 25 : 0; + } else { + minSize.height = maxHeight; // fill all the height + + // In a vertical axis, we need some room for the scale to be drawn. + // The actual grid lines will be drawn on the chart area, however, we need to show + // ticks where the axis actually is. + // We will allocate 25px for this width + // | + // -| + // | + // | + // -| + // | + // | + // -| + minSize.width = this.options.gridLines.show ? 25 : 0; + } + + if (this.options.labels.show) { + // Don't bother fitting the labels if we are not showing them + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.isHorizontal()) { + // A horizontal axis is more constrained by the height. + var maxLabelHeight = maxHeight - minSize.height; + var labelHeight = 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + } else { + // A vertical axis is more constrained by the width. Labels are the dominant factor + // here, so get that length first + var maxLabelWidth = maxWidth - minSize.width; + var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (largestTextWidth < maxLabelWidth) { + // We don't need all the room + minSize.width += largestTextWidth; + } else { + // Expand to max size + minSize.width = maxWidth; + } + } + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + var hasZero; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + if (this.options.gridLines.show) { + // Draw the horizontal line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are vertical + var xValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the left if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xValue, chartArea.top); + this.ctx.lineTo(xValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartY; + + if (this.options.position == "top") { + labelStartY = this.top; + } else { + // bottom side + labelStartY = this.top + 20; + } + + this.ctx.textAlign = "center"; + this.ctx.textBaseline = "top"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var xValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, xValue, labelStartY); + }, this); + } + } else { + // Vertical + if (this.options.gridLines.show) { + + // Draw the vertical line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var xTickStart = this.options.position == "right" ? this.left : this.right - 10; + var xTickEnd = this.options.position == "right" ? this.left + 10 : this.right; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are horizontal + var yValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the bottom if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; // use boolean to indicate that we only want to do this once + } + + yValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(chartArea.left, yValue); + this.ctx.lineTo(chartArea.right, yValue); + } + + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartX; + var maxLabelWidth = this.width - 25; + + if (this.options.position == "left") { + labelStartX = this.left; + } else { + // right side + labelStartX = this.left + 20; + } + + this.ctx.textAlign = "left"; + this.ctx.textBaseline = "middle"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var yValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, labelStartX, yValue, maxLabelWidth); + }, this); + } + } + } } }); + Chart.scales.registerScaleType("linear", LinearScale); + var DatasetScale = Chart.Element.extend({ + // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset + calculateRange: helpers.noop, + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + getPixelForValue: function(value, index, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } -}).call(this); + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.max)); + } + }, + calculateLabelRotation: function(maxHeight) { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; -(function() { - "use strict"; + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + var firstRotated; + var lastRotated; - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; - var defaultConfig = { - //Boolean - Whether we should show a stroke on each segment - segmentShowStroke: true, + this.labelRotation = 0; - //String - The colour of each segment stroke - segmentStrokeColor: "#fff", + if (this.options.display) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; - //Number - The width of each segment stroke - borderWidth: 2, + this.labelWidth = originalLabelWidth; - //The percentage of the chart that we cut out of the middle. - cutoutPercentage: 50, + //Allow 3 pixels x2 padding either side for label readability + // only the index matters for a dataset scale, but we want a consistent interface between scales + var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; - // The duration of animations triggered by hover events - hoverAnimationDuration: 400, + //Max label rotate should be 90 - also act as a loop counter + while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); - //String - Animation easing effect - animationEasing: "easeOutQuart", + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; - //Boolean - Whether we animate the rotation of the Doughnut - animateRotate: true, + // We're right aligning the text now. + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; + } - //Boolean - Whether we animate scaling the Doughnut from the centre - animateScale: false, + this.paddingRight = this.options.labels.fontSize / 2; - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } + + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; + + } + } else { + this.labelWidth = 0; + this.paddingRight = this.padding; + this.paddingLeft = this.padding; + } + + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.calculateLabelRotation(); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (this.isHorizontal()) { + minSize.width = maxWidth; + this.width = maxWidth; + + var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else { + minSize.height = maxHeight; + this.height = maxHeight; + + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + + helpers.each(this.labels, function(label, index) { + var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } - }; + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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) { + // Draw the label area + this.ctx.beginPath(); - // Save data as a source for updating of values & methods - this.data = data; + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } - // Slice Type and defaults - this.Slice = Chart.Arc.extend({ - _chart: this.chart, - x: this.chart.width / 2, - y: this.chart.height / 2 - }); + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } - //Set up tooltip events on the chart - if (this.options.showTooltips) { - helpers.bindEvents(this, this.options.tooltipEvents, this.onHover); - } + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } - // Create new slice for each piece of data - this.data.metaData = []; - helpers.each(this.data.data, function(slice, index) { - var metaSlice = new this.Slice(); - if (typeof slice == 'number') { - helpers.extend(metaSlice, { - value: slice - }); + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); } else { - helpers.extend(metaSlice, slice); - } - helpers.extend(metaSlice, { - startAngle: Math.PI * 1.5, - circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animateScale) ? 0 : this.outerRadius, - innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout, - }); - if (!metaSlice.backgroundColor) { - slice.backgroundColor = 'hsl(' + (360 * index / data.length) + ', 100%, 50%)'; - } - metaSlice.save(); - this.data.metaData.push(metaSlice); - }, this); + // Vertical + if (this.options.gridLines.show) {} - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); + if (this.options.labels.show) { + // Draw the labels + } + } + } + } + }); + Chart.scales.registerScaleType("dataset", DatasetScale); - this.update(); + var LinearRadialScale = Chart.Element.extend({ + initialize: function() { + this.size = helpers.min([this.height, this.width]); + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, - onHover: function(e) { - - // If exiting chart - if (e.type == 'mouseout') { - return this; + calculateCenterOffset: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + return (value - this.min) * scalingFactor; + }, + update: function() { + if (!this.options.lineArc) { + this.setScaleSize(); + } else { + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); } - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = this.getSliceAtEvent(e); + this.buildYLabels(); + }, + calculateRange: helpers.noop, // overridden in chart + generateTicks: function() { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } - // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); - } + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - this.lastActive[0].backgroundColor = this.data.data[this.lastActive[0]._index].backgroundColor; + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } } - // Built in hover styling - if (this.active.length && this.options.hoverMode) { - this.active[0].backgroundColor = this.data.data[this.active[0]._index].hoverBackgroundColor || helpers.color(this.data.data[this.active[0]._index].backgroundColor).saturate(0.5).darken(0.35).rgbString(); + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); } - // Built in Tooltips - if (this.options.showTooltips) { + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildYLabels: function() { + this.yLabels = []; - // The usual updates - this.tooltip.initialize(); + helpers.each(this.ticks, function(tick, index, ticks) { + var label; - // Active - if (this.active.length) { - helpers.extend(this.tooltip, { - opacity: 1, - _active: this.active, + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick }); + } - this.tooltip.update(); - } else { - // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.yLabels.push(label ? label : ""); + }, this); + }, + getCircumference: function() { + return ((Math.PI * 2) / this.valuesCount); + }, + setScaleSize: function() { + /* + * Right, this is really confusing and there is a lot of maths going on here + * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 + * + * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif + * + * Solution: + * + * We assume the radius of the polygon is half the size of the canvas at first + * at each index we check if the text overlaps. + * + * Where it does, we store that angle and that index. + * + * After finding the largest index and angle we calculate how much we need to remove + * from the shape radius to move the point inwards by that x. + * + * We average the left and right distances to get the maximum shape radius that can fit in the box + * along with labels. + * + * Once we have that, we can find the centre point for the chart, by taking the x text protrusion + * on each side, removing that from the size, halving it and adding the left x protrusion width. + * + * This will mean we have a shape fitted to the canvas, as large as it can be with the labels + * and position it in the most space efficient manner + * + * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif + */ + + + // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. + // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points + var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), + pointPosition, + i, + textWidth, + halfTextWidth, + furthestRight = this.width, + furthestRightIndex, + furthestRightAngle, + furthestLeft = 0, + furthestLeftIndex, + furthestLeftAngle, + xProtrusionLeft, + xProtrusionRight, + radiusReductionRight, + radiusReductionLeft, + maxWidthRadius; + this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + for (i = 0; i < this.valuesCount; i++) { + // 5px to space the text slightly out - similar to what we do in the draw function. + pointPosition = this.getPointPosition(i, largestPossibleRadius); + textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { + value: this.labels[i] + })).width + 5; + if (i === 0 || i === this.valuesCount / 2) { + // If we're at index zero, or exactly the middle, we're at exactly the top/bottom + // of the radar chart, so text will be aligned centrally, so we'll half it and compare + // w/left and right text sizes + halfTextWidth = textWidth / 2; + if (pointPosition.x + halfTextWidth > furthestRight) { + furthestRight = pointPosition.x + halfTextWidth; + furthestRightIndex = i; + } + if (pointPosition.x - halfTextWidth < furthestLeft) { + furthestLeft = pointPosition.x - halfTextWidth; + furthestLeftIndex = i; + } + } else if (i < this.valuesCount / 2) { + // Less than half the values means we'll left align the text + if (pointPosition.x + textWidth > furthestRight) { + furthestRight = pointPosition.x + textWidth; + furthestRightIndex = i; + } + } else if (i > this.valuesCount / 2) { + // More than half the values means we'll right align the text + if (pointPosition.x - textWidth < furthestLeft) { + furthestLeft = pointPosition.x - textWidth; + furthestLeftIndex = i; + } } } + xProtrusionLeft = furthestLeft; - // Hover animations - this.tooltip.pivot(); + xProtrusionRight = Math.ceil(furthestRight - this.width); - if (!this.animating) { - var changed; + furthestRightAngle = this.getIndexAngle(furthestRightIndex); - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); + furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { + radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } + radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); - // Remember Last Active - this.lastActive = this.active; - return this; + // Ensure we actually need to reduce the size of the chart + radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; + radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; - }, - getSliceAtEvent: function(e) { - var elements = []; + this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; - var location = helpers.getRelativePosition(e); + //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) + this.setCenterPoint(radiusReductionLeft, radiusReductionRight); - helpers.each(this.data.metaData, function(slice, index) { - if (slice.inRange(location.x, location.y)) elements.push(slice); - }, this); - return elements; - }, - calculateCircumference: function(value) { - if (this.total > 0) { - return (Math.PI * 2) * (value / this.total); - } else { - return 0; - } }, - update: function() { + setCenterPoint: function(leftMovement, rightMovement) { - // Calc Total - this.total = 0; - helpers.each(this.data.data, function(slice) { - this.total += Math.abs(slice.value); - }, this); + var maxRight = this.width - rightMovement - this.drawingArea, + maxLeft = leftMovement + this.drawingArea; + + this.xCenter = (maxLeft + maxRight) / 2; + // Always vertically in the centre as the text height doesn't change + this.yCenter = (this.height / 2); + }, - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.borderWidth / 2) / 2; + getIndexAngle: function(index) { + var angleMultiplier = (Math.PI * 2) / this.valuesCount; + // Start from the top instead of right, so remove a quarter of the circle - // Map new data to data points - helpers.each(this.data.metaData, function(slice, index) { + return index * angleMultiplier - (Math.PI / 2); + }, + getPointPosition: function(index, distanceFromCenter) { + var thisAngle = this.getIndexAngle(index); + return { + x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, + y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter + }; + }, + draw: function() { + if (this.options.display) { + var ctx = this.ctx; + helpers.each(this.yLabels, function(label, index) { + // Don't draw a centre value + if (index > 0) { + var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), + yHeight = this.yCenter - yCenterOffset, + pointPosition; - var datapoint = this.data.data[index]; + // Draw circular lines around the scale + if (this.options.gridLines.show) { + ctx.strokeStyle = this.options.gridLines.color; + ctx.lineWidth = this.options.gridLines.lineWidth; - helpers.extend(slice, { - _index: index, - x: this.chart.width / 2, - y: this.chart.height / 2, - value: datapoint.value, - label: datapoint.label, - circumference: this.calculateCircumference(datapoint.value), - outerRadius: this.outerRadius, - innerRadius: (this.outerRadius / 100) * this.options.cutoutPercentage, - - backgroundColor: datapoint.backgroundColor, - hoverBackgroundColor: datapoint.hoverBackgroundColor || datapoint.backgroundColor, - borderWidth: this.options.borderWidth, - borderColor: this.options.segmentStrokeColor, - }); + if (this.options.lineArc) { + ctx.beginPath(); + ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); + ctx.closePath(); + ctx.stroke(); + } else { + ctx.beginPath(); + for (var i = 0; i < this.valuesCount; i++) { + pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); + if (i === 0) { + ctx.moveTo(pointPosition.x, pointPosition.y); + } else { + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + } + } - helpers.extend(slice, { - endAngle: slice.startAngle + slice.circumference, - }); + if (this.options.labels.show) { + ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - if (index === 0) { - slice.startAngle = Math.PI * 1.5; - } + if (this.showLabelBackdrop) { + var labelWidth = ctx.measureText(label).width; + ctx.fillStyle = this.options.labels.backdropColor; + ctx.fillRect( + this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, + yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, + labelWidth + this.options.labels.backdropPaddingX * 2, + this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 + ); + } - //Check to see if it's the last slice, if not get the next and update its start angle - if (index < this.data.data.length - 1) { - this.data.metaData[index + 1].startAngle = slice.endAngle; - } + ctx.textAlign = 'center'; + ctx.textBaseline = "middle"; + ctx.fillStyle = this.options.labels.fontColor; + ctx.fillText(label, this.xCenter, yHeight); + } + } + }, this); - slice.pivot(); + if (!this.options.lineArc) { + ctx.lineWidth = this.options.angleLines.lineWidth; + ctx.strokeStyle = this.options.angleLines.color; - }, this); + for (var i = this.valuesCount - 1; i >= 0; i--) { + if (this.options.angleLines.show) { + var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); + ctx.beginPath(); + ctx.moveTo(this.xCenter, this.yCenter); + ctx.lineTo(outerPosition.x, outerPosition.y); + ctx.stroke(); + ctx.closePath(); + } + // Extra 3px out for some label spacing + var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); + ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + ctx.fillStyle = this.options.pointLabels.fontColor; - this.render(); - }, - draw: function(easeDecimal) { - easeDecimal = easeDecimal || 1; - this.clear(); + var labelsCount = this.labels.length, + halfLabelsCount = this.labels.length / 2, + quarterLabelsCount = halfLabelsCount / 2, + upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), + exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); + if (i === 0) { + ctx.textAlign = 'center'; + } else if (i === halfLabelsCount) { + ctx.textAlign = 'center'; + } else if (i < halfLabelsCount) { + ctx.textAlign = 'left'; + } else { + ctx.textAlign = 'right'; + } - helpers.each(this.data.metaData, function(slice, index) { - slice.transition(easeDecimal).draw(); - }, this); + // Set the correct text baseline based on outer positioning + if (exactQuarter) { + ctx.textBaseline = 'middle'; + } else if (upperHalf) { + ctx.textBaseline = 'bottom'; + } else { + ctx.textBaseline = 'top'; + } - this.tooltip.transition(easeDecimal).draw(); + ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + } + } + } } }); - - Chart.types.Doughnut.extend({ - name: "Pie", - defaults: helpers.merge(defaultConfig, { - cutoutPercentage: 0 - }) - }); - + Chart.scales.registerScaleType("radialLinear", LinearRadialScale); }).call(this); (function() { @@ -3101,138 +5606,132 @@ helpers = Chart.helpers; var defaultConfig = { + hover: { + mode: 'single', + }, - ///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 to show horizontal lines (except X axis) - scaleShowHorizontalLines: true, - //Boolean - Whether to show vertical lines (except Y axis) - scaleShowVerticalLines: true, - //Boolean - Whether to horizontally center the label and point dot inside the grid - offsetGridLines: false, - - - - //Boolean - Whether to stack the lines essentially creating a stacked area chart. - stacked: false, - - - //Number - Tension of the bezier curve between points - tension: 0.4, - - - //Number - Radius of each point dot in pixels - pointRadius: 3, - //Number - Pixel width of point dot border - pointBorderWidth: 1, - //Number - Pixel width of point on hover - pointHoverRadius: 5, - //Number - Pixel width of point dot border on hover - pointHoverBorderWidth: 2, - pointBackgroundColor: Chart.defaults.global.defaultColor, - pointBorderColor: Chart.defaults.global.defaultColor, + scales: { + xAxes: [{ + scaleType: "linear", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, - //Number - amount extra to add to the radius to cater for hit detection outside the drawn point - pointHitRadius: 6, + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, - //Number - Pixel width of dataset border - borderWidth: 2, - //Number - Pixel width of dataset border on hover - hoverBorderWidth: 2, + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, //String - A legend template legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - + tooltips: { + template: "(<%= value.x %>, <%= value.y %>)", + multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", + }, }; Chart.Type.extend({ - name: "Line", + name: "Scatter", defaults: defaultConfig, initialize: function() { // Events helpers.bindEvents(this, this.options.events, this.events); - var _this = this; + //Custom Point Defaults + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); - // Build Scale - this.ScaleClass = Chart.Scale.extend({ - calculatePointY: function(index, datasetIndex) { + dataset.metaData = []; - var value = _this.data.datasets[datasetIndex].data[index]; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); - if (_this.options.stacked) { - var offsetPos = 0; - var offsetNeg = 0; - for (var i = 0; i < datasetIndex; i++) { - if (_this.data.datasets[i].data[index] < 0) { - offsetNeg += _this.data.datasets[i].data[index]; - } else { - offsetPos += _this.data.datasets[i].data[index]; - } - } - if (value < 0) { - return this.calculateY(offsetNeg + value); - } else { - return this.calculateY(offsetPos + value); - } - } + }, this); - return this.calculateY(value); + // The line chart onlty supports a single x axis because the x axis is always a dataset axis + if (!dataset.xAxisID) { + dataset.xAxisID = this.options.scales.xAxes[0].id; } - }); - this.buildScale(this.data.labels); + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } - //Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaDataset = new Chart.Line(); - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point()); - }, this); - }, this); - - // Set defaults for lines - this.eachDataset(function(dataset, datasetIndex) { - helpers.extend(dataset.metaDataset, { - _points: dataset.metaData, - _datasetIndex: datasetIndex, - _chart: this.chart, - }); - // Fill in dataset defaults from options - helpers.extend(dataset, helpers.merge(this.options, dataset)); - // Copy to view modele - dataset.metaDataset.save(); }, this); - // Set defaults for points - this.eachElement(function(point, index, dataset, datasetIndex) { - helpers.extend(point, { - x: this.scale.calculateX(index), - y: this.scale.calculateY(0), - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart - }); - - // Default bezier control points - helpers.extend(point, { - controlPointPreviousX: this.previousPoint(dataset, index).x, - controlPointPreviousY: this.nextPoint(dataset, index).y, - controlPointNextX: this.previousPoint(dataset, index).x, - controlPointNextY: this.nextPoint(dataset, index).y, - }); - // Copy to view model - point.save(); - }, this); + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ @@ -3241,195 +5740,298 @@ _options: this.options, }, this); + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz this.update(); }, nextPoint: function(collection, index) { - return collection[index - 1] || collection[index]; + return collection[index + 1] || collection[index]; }, previousPoint: function(collection, index) { - return collection[index + 1] || collection[index]; + return collection[index - 1] || collection[index]; }, - update: function() { + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), // value not used in dataset scale, but we want a consistent API between scales + y: yScalePoint, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } - // Update the scale - this.scale.update(); + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function() { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines this.eachDataset(function(dataset, datasetIndex) { + var yScale = this.scales[dataset.yAxisID]; + helpers.extend(dataset.metaDataset, { // Utility + _scale: yScale, _datasetIndex: datasetIndex, // Data - _points: dataset.metaData, - // Geometry - scaleTop: this.scale.startPoint, - scaleBottom: this.scale.endPoint, - scaleZero: this.scale.calculateY(0), - // Appearance - tension: dataset.tension || this.options.tension, - backgroundColor: dataset.backgroundColor || this.options.backgroundColor, - borderWidth: dataset.borderWidth || this.options.borderWidth, - borderColor: dataset.borderColor || this.options.borderColor, + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: yScale.getPixelForValue(0), + }, }); + dataset.metaDataset.pivot(); }); // Update the points this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + helpers.extend(point, { // Utility _chart: this.chart, + _xScale: xScale, + _yScale: yScale, _datasetIndex: datasetIndex, _index: index, - // Data - label: this.data.labels[index], - value: this.data.datasets[datasetIndex].data[index], - datasetLabel: this.data.datasets[datasetIndex].label, - // Geometry - offsetGridLines: this.options.offsetGridLines, - x: this.scale.calculateX(index), - y: this.scale.calculatePointY(index, datasetIndex), - tension: this.data.datasets[datasetIndex].metaDataset.tension, - // Appearnce - radius: this.data.datasets[datasetIndex].pointRadius || this.options.pointRadius, - backgroundColor: this.data.datasets[datasetIndex].pointBackgroundColor || this.options.pointBackgroundColor, - borderWidth: this.data.datasets[datasetIndex].pointBorderWidth || this.options.pointBorderWidth, - // Tooltip - hoverRadius: this.data.datasets[datasetIndex].pointHitRadius || this.options.pointHitRadius, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), + y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, }); }, this); + // Update control points for the bezier curve this.eachElement(function(point, index, dataset, datasetIndex) { var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index), - point, - this.nextPoint(dataset, index), - point.tension + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension ); - point.controlPointPreviousX = controlPoints.previous.x; - point.controlPointNextX = controlPoints.next.x; + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; // Prevent the bezier going outside of the bounds of the graph + // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.scale.endPoint) { - point.controlPointNextY = this.scale.endPoint; - } else if (controlPoints.next.y < this.scale.startPoint) { - point.controlPointNextY = this.scale.startPoint; + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; } else { - point.controlPointNextY = controlPoints.next.y; + point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.scale.endPoint) { - point.controlPointPreviousY = this.scale.endPoint; - } else if (controlPoints.previous.y < this.scale.startPoint) { - point.controlPointPreviousY = this.scale.startPoint; + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; } else { - point.controlPointPreviousY = controlPoints.previous.y; + point._model.controlPointPreviousY = controlPoints.previous.y; } + // Now pivot the point for animation point.pivot(); }, this); this.render(); }, - buildScale: function(labels) { + buildScale: function() { var self = this; - var dataTotal = function() { - var values = []; - var negativeValues = []; - - if (self.options.stacked) { - self.eachValue(function(value, index) { - values[index] = values[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - if (self.options.relativePoints) { - values[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - values[index] += value; + var calculateXRange = function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + // Only set the scale range for datasets that actually use this axis + if (dataset.xAxisID === this.id) { + helpers.each(dataset.data, function(value) { + if (this.min === null) { + this.min = value.x; + } else if (value.x < this.min) { + this.min = value.x; } - } - }); - return values.concat(negativeValues); - } - - self.eachValue(function(value, index) { - values.push(value); - }); - - return values; - + + if (this.max === null) { + this.max = value.x; + } else if (value.x > this.max) { + this.max = value.x; + } + }, this); + } + }, this); }; - var scaleOptions = { - templateString: this.options.scaleLabel, - height: this.chart.height, - width: this.chart.width, - ctx: this.chart.ctx, - textColor: this.options.scaleFontColor, - offsetGridLines: this.options.offsetGridLines, - fontSize: this.options.scaleFontSize, - fontStyle: this.options.scaleFontStyle, - fontFamily: this.options.scaleFontFamily, - valuesCount: labels.length, - beginAtZero: this.options.scaleBeginAtZero, - integersOnly: this.options.scaleIntegersOnly, - calculateYRange: function(currentHeight) { - var updatedRanges = helpers.calculateScaleRange( - dataTotal(), - currentHeight, - this.fontSize, - this.beginAtZero, - this.integersOnly - ); - helpers.extend(this, updatedRanges); - }, - xLabels: this.data.labels, - font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), - lineWidth: this.options.scaleLineWidth, - lineColor: this.options.scaleLineColor, - showHorizontalLines: this.options.scaleShowHorizontalLines, - showVerticalLines: this.options.scaleShowVerticalLines, - 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.pointRadius + this.options.pointBorderWidth, - showLabels: this.options.scaleShowLabels, - display: this.options.showScale + var calculateYRange = function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value) { + if (this.min === null) { + this.min = value.y; + } else if (value.y < this.min) { + this.min = value.y; + } + + if (this.max === null) { + this.max = value.y; + } else if (value.y > this.max) { + this.max = value.y; + } + }, this); + } + }, this); }; - if (this.options.scaleOverride) { - helpers.extend(scaleOptions, { - calculateYRange: helpers.noop, - steps: this.options.scaleSteps, - stepValue: this.options.scaleStepWidth, - min: this.options.scaleStartValue, - max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth) + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + calculateRange: calculateXRange, + id: xAxisOptions.id, }); - } - this.scale = new this.ScaleClass(scaleOptions); - }, - redraw: function() { + this.scales[scale.id] = scale; + }, this); + + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + calculateRange: calculateYRange, + id: yAxisOptions.id, + getPointPixelForValue: function(value, index, datasetIndex) { + return this.getPixelForValue(value); + } + }); + this.scales[scale.id] = scale; + }, this); }, draw: function(ease) { - var easingDecimal = ease || 1; this.clear(); - this.scale.draw(easingDecimal); + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); // reverse for-loop for proper stacking for (var i = this.data.datasets.length - 1; i >= 0; i--) { var dataset = this.data.datasets[i]; - var datasetIndex = i; // Transition Point Locations helpers.each(dataset.metaData, function(point, index) { @@ -3449,7 +6051,6 @@ this.tooltip.transition(easingDecimal).draw(); }, events: function(e) { - // If exiting chart if (e.type == 'mouseout') { return this; @@ -3459,7 +6060,7 @@ // Find Active Elements this.active = function() { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': return this.getElementAtEvent(e); case 'label': @@ -3472,36 +6073,33 @@ }.call(this); // On Hover hook - if (this.options.onHover) { - this.options.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); } - var dataset; + var dataset; + var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - switch (this.options.hoverMode) { + switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; - this.lastActive[0].radius = dataset.pointRadius; - this.lastActive[0].backgroundColor = dataset.pointBackgroundColor; - this.lastActive[0].borderColor = dataset.pointBorderColor; - this.lastActive[0].borderWidth = dataset.pointBorderWidth; + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; - this.lastActive[i].radius = dataset.pointRadius; - this.lastActive[i].backgroundColor = dataset.pointBackgroundColor; - this.lastActive[i].borderColor = dataset.pointBorderColor; - this.lastActive[i].borderWidth = dataset.pointBorderWidth; + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); } break; case 'dataset': @@ -3512,24 +6110,26 @@ } // Built in hover styling - if (this.active.length && this.options.hoverMode) { - switch (this.options.hoverMode) { + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { case 'single': dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; - this.active[0].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; - this.active[0].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[0].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; - this.active[i].radius = dataset.pointHoverRadius || dataset.pointRadius + 2; - this.active[i].backgroundColor = dataset.pointHoverBackgroundColor || helpers.color(dataset.pointBackgroundColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderColor = dataset.pointHoverBorderColor || helpers.color(dataset.pointBorderColor).saturate(0.5).darken(0.35).rgbString(); - this.active[i].borderWidth = dataset.pointHoverBorderWidth || dataset.pointBorderWidth + 2; + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); } break; case 'dataset': @@ -3539,30 +6139,27 @@ } } - // Built in Tooltips - if (this.options.showTooltips) { + if (this.options.tooltips.enabled) { // The usual updates this.tooltip.initialize(); // Active if (this.active.length) { + this.tooltip._model.opacity = 1; + helpers.extend(this.tooltip, { - opacity: 1, _active: this.active, }); this.tooltip.update(); } else { // Inactive - helpers.extend(this.tooltip, { - opacity: 0, - }); + this.tooltip._model.opacity = 0; } } - // Hover animations this.tooltip.pivot(); @@ -3588,653 +6185,11 @@ // Remember Last Active this.lastActive = this.active; return this; + }, }); -}).call(this); - -(function(){ - "use strict"; - - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; - - var defaultConfig = { - //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 segment. - 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, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    " - }; - - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "PolarArea", - //Providing a defaults will also register the deafults in the chart namespace - defaults : defaultConfig, - //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){ - // Save data as a source for updating of values & methods - this.data = data; - - this.segments = []; - //Declare segment class as a chart instance specific class, so it can share props for this instance - this.SegmentArc = Chart.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 Chart.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: true, - 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: data.length - }); - - this.updateScaleRange(data); - - this.scale.update(); - - helpers.each(data,function(segment,index){ - this.addData(segment,index,true); - },this); - - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ - var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : []; - helpers.each(this.segments,function(segment){ - segment.restore(["fillColor"]); - }); - helpers.each(activeSegments,function(activeSegment){ - activeSegment.fillColor = activeSegment.highlightColor; - }); - this.showTooltip(activeSegments); - }); - } - - this.render(); - }, - getSegmentsAtEvent : function(e){ - var segmentsArray = []; - - var location = helpers.getRelativePosition(e); - - helpers.each(this.segments,function(segment){ - if (segment.inRange(location.x,location.y)) segmentsArray.push(segment); - },this); - return segmentsArray; - }, - addData : function(segment, atIndex, silent){ - var index = atIndex || this.segments.length; - - this.segments.splice(index, 0, new this.SegmentArc({ - fillColor: segment.color, - highlightColor: segment.highlight || segment.color, - label: segment.label, - value: segment.value, - outerRadius: (this.options.animateScale) ? 0 : this.scale.calculateCenterOffset(segment.value), - circumference: (this.options.animateRotate) ? 0 : this.scale.getCircumference(), - startAngle: Math.PI * 1.5 - })); - if (!silent){ - this.reflow(); - this.update(); - } - }, - removeData: function(atIndex){ - var indexToDelete = (helpers.isNumber(atIndex)) ? atIndex : this.segments.length-1; - this.segments.splice(indexToDelete, 1); - this.reflow(); - this.update(); - }, - calculateTotal: function(data){ - this.total = 0; - helpers.each(data,function(segment){ - this.total += segment.value; - },this); - this.scale.valuesCount = this.segments.length; - }, - updateScaleRange: function(datapoints){ - var valuesArray = []; - helpers.each(datapoints,function(segment){ - valuesArray.push(segment.value); - }); - - var scaleSizes = (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) - } : - helpers.calculateScaleRange( - valuesArray, - helpers.min([this.chart.width, this.chart.height])/2, - this.options.scaleFontSize, - this.options.scaleBeginAtZero, - this.options.scaleIntegersOnly - ); - - helpers.extend( - this.scale, - scaleSizes, - { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width/2, - yCenter: this.chart.height/2 - } - ); - - }, - update : function(){ - - // Map new data to data points - if(this.data.length == this.segments.length){ - helpers.each(this.data, function(segment, i){ - helpers.extend(this.segments[i], { - fillColor: segment.color, - highlightColor: segment.highlight || segment.color, - label: segment.label, - value: segment.value, - }); - },this); - } else{ - // Data size changed without properly inserting, just redraw the chart - this.initialize(this.data); - } - - this.calculateTotal(this.segments); - - helpers.each(this.segments,function(segment){ - segment.save(); - }); - - this.reflow(); - this.render(); - }, - reflow : function(){ - helpers.extend(this.SegmentArc.prototype,{ - x : this.chart.width/2, - y : this.chart.height/2 - }); - this.updateScaleRange(this.segments); - this.scale.update(); - - helpers.extend(this.scale,{ - xCenter: this.chart.width/2, - yCenter: this.chart.height/2 - }); - - helpers.each(this.segments, function(segment){ - segment.update({ - outerRadius : this.scale.calculateCenterOffset(segment.value) - }); - }, this); - - }, - draw : function(ease){ - var easingDecimal = ease || 1; - //Clear & draw the canvas - this.clear(); - helpers.each(this.segments,function(segment, index){ - segment.transition({ - circumference : this.scale.getCircumference(), - outerRadius : this.scale.calculateCenterOffset(segment.value) - },easingDecimal); - - segment.endAngle = segment.startAngle + segment.circumference; - - // If we've removed the first segment we need to set the first one to - // start at the top. - if (index === 0){ - segment.startAngle = Math.PI * 1.5; - } - - //Check to see if it's the last segment, if not get the next and update the start angle - if (index < this.segments.length - 1){ - this.segments[index+1].startAngle = segment.endAngle; - } - segment.draw(); - }, this); - this.scale.draw(); - } - }); - -}).call(this); - -(function(){ - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - - - Chart.Type.extend({ - name: "Radar", - defaults:{ - //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, - - //String - A legend template - legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - - }, - - initialize: function(data){ - // Save data as a source for updating of values & methods - this.data = data; - - this.PointClass = Chart.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(data); - - //Set up tooltip events on the chart - if (this.options.showTooltips){ - helpers.bindEvents(this, this.options.tooltipEvents, function(evt){ - var activePointsCollection = (evt.type !== 'mouseout') ? this.getPointsAtEvent(evt) : []; - - this.eachPoints(function(point){ - point.restore(['fillColor', 'strokeColor']); - }); - helpers.each(activePointsCollection, function(activePoint){ - activePoint.fillColor = activePoint.highlightFill; - activePoint.strokeColor = activePoint.highlightStroke; - }); - - this.showTooltip(activePointsCollection); - }); - } - - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(data.datasets,function(dataset){ - - var datasetObject = { - label: dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - pointColor : dataset.pointColor, - pointStrokeColor : dataset.pointStrokeColor, - points : [] - }; - - this.datasets.push(datasetObject); - - helpers.each(dataset.data,function(dataPoint,index){ - //Add a new point for each piece of data, passing any required data to draw. - var pointPosition; - if (!this.scale.animation){ - pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(dataPoint)); - } - 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, - fillColor : dataset.pointColor, - highlightFill : dataset.pointHighlightFill || dataset.pointColor, - highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor - })); - },this); - - },this); - - this.render(); - }, - eachPoints : function(callback){ - helpers.each(this.datasets,function(dataset){ - helpers.each(dataset.points,callback,this); - },this); - }, - - getPointsAtEvent : function(evt){ - var mousePosition = helpers.getRelativePosition(evt), - fromCenter = helpers.getAngleFromPoint({ - x: this.scale.xCenter, - y: this.scale.yCenter - }, mousePosition); - - var anglePerIndex = (Math.PI * 2) /this.scale.valuesCount, - pointIndex = Math.round((fromCenter.angle - Math.PI * 1.5) / anglePerIndex), - activePointsCollection = []; - - // If we're at the top, make the pointIndex 0 to get the first of the array. - if (pointIndex >= this.scale.valuesCount || pointIndex < 0){ - pointIndex = 0; - } - - if (fromCenter.distance <= this.scale.drawingArea){ - helpers.each(this.datasets, function(dataset){ - activePointsCollection.push(dataset.points[pointIndex]); - }); - } - - return activePointsCollection; - }, - - buildScale : function(data){ - this.scale = new Chart.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, - // Point labels at the edge of each line - 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: data.labels, - valuesCount: data.datasets[0].data.length - }); - - this.scale.setScaleSize(); - this.updateScaleRange(data.datasets); - this.scale.buildYLabels(); - }, - updateScaleRange: function(datasets){ - var valuesArray = (function(){ - var totalDataArray = []; - helpers.each(datasets,function(dataset){ - if (dataset.data){ - totalDataArray = totalDataArray.concat(dataset.data); - } - else { - helpers.each(dataset.points, function(point){ - totalDataArray.push(point.value); - }); - } - }); - return totalDataArray; - })(); - - - var scaleSizes = (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) - } : - helpers.calculateScaleRange( - valuesArray, - helpers.min([this.chart.width, this.chart.height])/2, - this.options.scaleFontSize, - this.options.scaleBeginAtZero, - this.options.scaleIntegersOnly - ); - - helpers.extend( - this.scale, - scaleSizes - ); - - }, - addData : function(valuesArray,label){ - //Map the values array for each of the datasets - this.scale.valuesCount++; - helpers.each(valuesArray,function(value,datasetIndex){ - var pointPosition = this.scale.getPointPosition(this.scale.valuesCount, this.scale.calculateCenterOffset(value)); - this.datasets[datasetIndex].points.push(new this.PointClass({ - value : value, - label : label, - datasetLabel: this.datasets[datasetIndex].label, - x: pointPosition.x, - y: pointPosition.y, - strokeColor : this.datasets[datasetIndex].pointStrokeColor, - fillColor : this.datasets[datasetIndex].pointColor - })); - },this); - - this.scale.labels.push(label); - - this.reflow(); - - this.update(); - }, - removeData : function(){ - this.scale.valuesCount--; - this.scale.labels.shift(); - helpers.each(this.datasets,function(dataset){ - dataset.points.shift(); - },this); - this.reflow(); - this.update(); - }, - update : function(){ - //Iterate through each of the datasets, and build this into a property of the chart - helpers.each(this.data.datasets,function(dataset,datasetIndex){ - - helpers.extend(this.datasets[datasetIndex], { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - pointColor : dataset.pointColor, - pointStrokeColor : dataset.pointStrokeColor, - }); - - helpers.each(dataset.data,function(dataPoint,index){ - helpers.extend(this.datasets[datasetIndex].points[index], { - value : dataPoint, - label : this.data.labels[index], - datasetLabel: dataset.label, - strokeColor : dataset.pointStrokeColor, - fillColor : dataset.pointColor, - highlightFill : dataset.pointHighlightFill || dataset.pointColor, - highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor - }); - },this); - - },this); - - this.eachPoints(function(point){ - point.save(); - }); - this.reflow(); - this.render(); - }, - reflow: function(){ - helpers.extend(this.scale, { - width : this.chart.width, - height: this.chart.height, - size : helpers.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(ease){ - var easeDecimal = ease || 1, - ctx = this.chart.ctx; - this.clear(); - this.scale.draw(); - - helpers.each(this.datasets,function(dataset){ - - //Transition each point first so that the line and point drawing isn't out of sync - helpers.each(dataset.points,function(point,index){ - if (point.hasValue()){ - point.transition(this.scale.getPointPosition(index, this.scale.calculateCenterOffset(point.value)), easeDecimal); - } - },this); - - - - //Draw the line between all the points - ctx.lineWidth = this.options.datasetStrokeWidth; - ctx.strokeStyle = dataset.strokeColor; - ctx.beginPath(); - helpers.each(dataset.points,function(point,index){ - if (index === 0){ - ctx.moveTo(point.x,point.y); - } - else{ - ctx.lineTo(point.x,point.y); - } - },this); - ctx.closePath(); - ctx.stroke(); - - ctx.fillStyle = dataset.fillColor; - ctx.fill(); - - //Now draw the points over the line - //A little inefficient double looping, but better than the line - //lagging behind the point positions - helpers.each(dataset.points,function(point){ - if (point.hasValue()){ - point.draw(); - } - }); - - },this); - - } - - }); - - - - - }).call(this); !function e(r,t,n){function a(i,u){if(!t[i]){if(!r[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(s)return s(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var o=t[i]={exports:{}};r[i][0].call(o.exports,function(e){var t=r[i][1][e];return a(t?t:e)},o,o.exports,e,r,t,n)}return t[i].exports}for(var s="function"==typeof require&&require,i=0;i=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*r[0]+.7152*r[1]+.0722*r[2]},contrast:function(e){var r=this.luminosity(),t=e.luminosity();return r>t?(r+.05)/(t+.05):(t+.05)/(r+.05)},level:function(e){var r=this.contrast(e);return r>=7.1?"AAA":r>=4.5?"AA":""},dark:function(){var e=this.values.rgb,r=(299*e[0]+587*e[1]+114*e[2])/1e3;return 128>r},light:function(){return!this.dark()},negate:function(){for(var e=[],r=0;3>r;r++)e[r]=255-this.values.rgb[r];return this.setValues("rgb",e),this},lighten:function(e){return this.values.hsl[2]+=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},darken:function(e){return this.values.hsl[2]-=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},saturate:function(e){return this.values.hsl[1]+=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},desaturate:function(e){return this.values.hsl[1]-=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},whiten:function(e){return this.values.hwb[1]+=this.values.hwb[1]*e,this.setValues("hwb",this.values.hwb),this},blacken:function(e){return this.values.hwb[2]+=this.values.hwb[2]*e,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var e=this.values.rgb,r=.3*e[0]+.59*e[1]+.11*e[2];return this.setValues("rgb",[r,r,r]),this},clearer:function(e){return this.setValues("alpha",this.values.alpha-this.values.alpha*e),this},opaquer:function(e){return this.setValues("alpha",this.values.alpha+this.values.alpha*e),this},rotate:function(e){var r=this.values.hsl[0];return r=(r+e)%360,r=0>r?360+r:r,this.values.hsl[0]=r,this.setValues("hsl",this.values.hsl),this},mix:function(e,r){r=1-(null==r?.5:r);for(var t=2*r-1,n=this.alpha()-e.alpha(),a=((t*n==-1?t:(t+n)/(1+t*n))+1)/2,s=1-a,i=this.rgbArray(),u=e.rgbArray(),l=0;lr&&(r+=360),n=(u+l)/2,t=l==u?0:.5>=n?h/(l+u):h/(2-l-u),[r,100*t,100*n]}function s(e){var r,t,n,a=e[0],s=e[1],i=e[2],u=Math.min(a,s,i),l=Math.max(a,s,i),h=l-u;return t=0==l?0:h/l*1e3/10,l==u?r=0:a==l?r=(s-i)/h:s==l?r=2+(i-a)/h:i==l&&(r=4+(a-s)/h),r=Math.min(60*r,360),0>r&&(r+=360),n=l/255*1e3/10,[r,t,n]}function i(e){var r=e[0],t=e[1],n=e[2],s=a(e)[0],i=1/255*Math.min(r,Math.min(t,n)),n=1-1/255*Math.max(r,Math.max(t,n));return[s,100*i,100*n]}function u(e){var r,t,n,a,s=e[0]/255,i=e[1]/255,u=e[2]/255;return a=Math.min(1-s,1-i,1-u),r=(1-s-a)/(1-a)||0,t=(1-i-a)/(1-a)||0,n=(1-u-a)/(1-a)||0,[100*r,100*t,100*n,100*a]}function l(e){return X[JSON.stringify(e)]}function h(e){var r=e[0]/255,t=e[1]/255,n=e[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*r+.3576*t+.1805*n,s=.2126*r+.7152*t+.0722*n,i=.0193*r+.1192*t+.9505*n;return[100*a,100*s,100*i]}function o(e){var r,t,n,a=h(e),s=a[0],i=a[1],u=a[2];return s/=95.047,i/=100,u/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,r=116*i-16,t=500*(s-i),n=200*(i-u),[r,t,n]}function c(e){return J(o(e))}function v(e){var r,t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100;if(0==u)return s=255*l,[s,s,s];t=.5>l?l*(1+u):l+u-l*u,r=2*l-t,a=[0,0,0];for(var h=0;3>h;h++)n=i+1/3*-(h-1),0>n&&n++,n>1&&n--,s=1>6*n?r+6*(t-r)*n:1>2*n?t:2>3*n?r+(t-r)*(2/3-n)*6:r,a[h]=255*s;return a}function f(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return s*=2,a*=1>=s?s:2-s,t=(s+a)/2,r=2*a/(s+a),[n,100*r,100*t]}function d(e){return i(v(e))}function p(e){return u(v(e))}function m(e){return l(v(e))}function y(e){var r=e[0]/60,t=e[1]/100,n=e[2]/100,a=Math.floor(r)%6,s=r-Math.floor(r),i=255*n*(1-t),u=255*n*(1-t*s),l=255*n*(1-t*(1-s)),n=255*n;switch(a){case 0:return[n,l,i];case 1:return[u,n,i];case 2:return[i,n,l];case 3:return[i,u,n];case 4:return[l,i,n];case 5:return[n,i,u]}}function w(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return t=(2-a)*s,r=a*s,r/=1>=t?t:2-t,r=r||0,t/=2,[n,100*r,100*t]}function k(e){return i(y(e))}function M(e){return u(y(e))}function S(e){return l(y(e))}function x(e){var t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100,h=u+l;switch(h>1&&(u/=h,l/=h),t=Math.floor(6*i),n=1-l,a=6*i-t,0!=(1&t)&&(a=1-a),s=u+a*(n-u),t){default:case 6:case 0:r=n,g=s,b=u;break;case 1:r=s,g=n,b=u;break;case 2:r=u,g=n,b=s;break;case 3:r=u,g=s,b=n;break;case 4:r=s,g=u,b=n;break;case 5:r=n,g=u,b=s}return[255*r,255*g,255*b]}function V(e){return a(x(e))}function q(e){return s(x(e))}function A(e){return u(x(e))}function C(e){return l(x(e))}function F(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100,u=e[3]/100;return r=1-Math.min(1,a*(1-u)+u),t=1-Math.min(1,s*(1-u)+u),n=1-Math.min(1,i*(1-u)+u),[255*r,255*t,255*n]}function N(e){return a(F(e))}function z(e){return s(F(e))}function I(e){return i(F(e))}function O(e){return l(F(e))}function E(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100;return r=3.2406*a+-1.5372*s+i*-.4986,t=a*-.9689+1.8758*s+.0415*i,n=.0557*a+s*-.204+1.057*i,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=12.92*r,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:t=12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,r=Math.min(Math.max(0,r),1),t=Math.min(Math.max(0,t),1),n=Math.min(Math.max(0,n),1),[255*r,255*t,255*n]}function H(e){var r,t,n,a=e[0],s=e[1],i=e[2];return a/=95.047,s/=100,i/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,r=116*s-16,t=500*(a-s),n=200*(s-i),[r,t,n]}function U(e){return J(H(e))}function j(e){var r,t,n,a,s=e[0],i=e[1],u=e[2];return 8>=s?(t=100*s/903.3,a=7.787*(t/100)+16/116):(t=100*Math.pow((s+16)/116,3),a=Math.pow(t/100,1/3)),r=.008856>=r/95.047?r=95.047*(i/500+a-16/116)/7.787:95.047*Math.pow(i/500+a,3),n=.008859>=n/108.883?n=108.883*(a-u/200-16/116)/7.787:108.883*Math.pow(a-u/200,3),[r,t,n]}function J(e){var r,t,n,a=e[0],s=e[1],i=e[2];return r=Math.atan2(i,s),t=360*r/2/Math.PI,0>t&&(t+=360),n=Math.sqrt(s*s+i*i),[a,n,t]}function R(e){return E(j(e))}function $(e){var r,t,n,a=e[0],s=e[1],i=e[2];return n=i/360*2*Math.PI,r=s*Math.cos(n),t=s*Math.sin(n),[a,r,t]}function D(e){return j($(e))}function P(e){return R($(e))}function _(e){return W[e]}function L(e){return a(_(e))}function T(e){return s(_(e))}function B(e){return i(_(e))}function G(e){return u(_(e))}function K(e){return o(_(e))}function Q(e){return h(_(e))}t.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:i,rgb2cmyk:u,rgb2keyword:l,rgb2xyz:h,rgb2lab:o,rgb2lch:c,hsl2rgb:v,hsl2hsv:f,hsl2hwb:d,hsl2cmyk:p,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:k,hsv2cmyk:M,hsv2keyword:S,hwb2rgb:x,hwb2hsl:V,hwb2hsv:q,hwb2cmyk:A,hwb2keyword:C,cmyk2rgb:F,cmyk2hsl:N,cmyk2hsv:z,cmyk2hwb:I,cmyk2keyword:O,keyword2rgb:_,keyword2hsl:L,keyword2hsv:T,keyword2hwb:B,keyword2cmyk:G,keyword2lab:K,keyword2xyz:Q,xyz2rgb:E,xyz2lab:H,xyz2lch:U,lab2xyz:j,lab2rgb:R,lab2lch:J,lch2lab:$,lch2xyz:D,lch2rgb:P};var W={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},X={};for(var Y in W)X[JSON.stringify(W[Y])]=Y},{}],3:[function(e,r,t){var n=e("./conversions"),a=function(){return new h};for(var s in n){a[s+"Raw"]=function(e){return function(r){return"number"==typeof r&&(r=Array.prototype.slice.call(arguments)),n[e](r)}}(s);var i=/(\w+)2(\w+)/.exec(s),u=i[1],l=i[2];a[u]=a[u]||{},a[u][l]=a[s]=function(e){return function(r){"number"==typeof r&&(r=Array.prototype.slice.call(arguments));var t=n[e](r);if("string"==typeof t||void 0===t)return t;for(var a=0;ar||e[3]&&e[3]<1?c(e,r):"rgb("+e[0]+", "+e[1]+", "+e[2]+")"}function c(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+r+")"}function g(e,r){if(1>r||e[3]&&e[3]<1)return v(e,r);var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgb("+t+"%, "+n+"%, "+a+"%)"}function v(e,r){var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgba("+t+"%, "+n+"%, "+a+"%, "+(r||e[3]||1)+")"}function f(e,r){return 1>r||e[3]&&e[3]<1?d(e,r):"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)"}function d(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+r+")"}function b(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+(void 0!==r&&1!==r?", "+r:"")+")"}function p(e){return k[e.slice(0,3)]}function m(e,r,t){return Math.min(Math.max(r,e),t)}function y(e){var r=e.toString(16).toUpperCase();return r.length<2?"0"+r:r}var w=e("color-name");r.exports={getRgba:n,getHsla:a,getRgb:i,getHsl:u,getHwb:s,getAlpha:l,hexString:h,rgbString:o,rgbaString:c,percentString:g,percentaString:v,hslString:f,hslaString:d,hwbString:b,keyword:p};var k={};for(var M in w)k[w[M]]=M},{"color-name":5}],5:[function(e,r,t){r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/Chart.min.js b/Chart.min.js index 9490ea1e81d..f9d5c4179d2 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -1,13 +1,14 @@ /*! * Chart.js * http://chartjs.org/ - * Version: 1.0.2 + * Version: 2.0.0-alpha * * Copyright 2015 Nick Downie * 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;var i=function(t,i){return t["offset"+i]?t["offset"+i]:document.defaultView.getComputedStyle(t).getPropertyValue(i)},e=this.width=i(t.canvas,"Width")||t.canvas.width,s=this.height=i(t.canvas,"Height")||t.canvas.height;return t.canvas.width=e,t.canvas.height=s,e=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,a.retinaScale(this),this};e.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!1,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{mode:"label",onHover:null,animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:14,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:14,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",multiKeyBackground:"#fff"},defaultColor:"rgba(0,0,0,0.1)"}},e.types={};var a=e.helpers={},s=a.each=function(t,i,e){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;a--){var s=t[a];if(i(s))return s}},a.inherits=function(t){var i=this,e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},a=function(){this.constructor=e};return a.prototype=i.prototype,e.prototype=new a,e.extend=h,t&&o(e.prototype,t),e.__super__=i.prototype,e}),l=a.noop=function(){},c=a.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=a.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},d=a.amd="function"==typeof define&&define.amd,p=a.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=a.max=function(t){return Math.max.apply(Math,t)},f=a.min=function(t){return Math.min.apply(Math,t)},v=(a.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},a.cap=function(t,i,e){if(p(i)){if(t>i)return i}else if(p(e)&&e>t)return e;return t},a.getDecimalPlaces=function(t){if(t%1!==0&&p(t)){var i=t.toString();if(i.indexOf("e-")<0)return i.split(".")[1].length;if(i.indexOf(".")<0)return parseInt(i.split("e-")[1]);var e=i.split(".")[1].split("e-");return e[0].length+parseInt(e[1])}return 0},a.toRadians=function(t){return t*(Math.PI/180)},a.toDegrees=function(t){return t*(180/Math.PI)},a.getAngleFromPoint=function(t,i){var e=i.x-t.x,a=i.y-t.y,s=Math.sqrt(e*e+a*a),n=2*Math.PI+Math.atan2(a,e);return 0>e&&0>a&&(n+=2*Math.PI),{angle:n,distance:s}},a.aliasPixel=function(t){return t%2===0?0:.5},a.splineCurve=function(t,i,e,a){var s=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),o=a*s/(s+n),r=a*n/(s+n);return{next:{x:i.x-o*(e.x-t.x),y:i.y-o*(e.y-t.y)},previous:{x:i.x+r*(e.x-t.x),y:i.y+r*(e.y-t.y)}}},a.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),m=(a.calculateScaleRange=function(t,i,e,a,s){var n=2,o=Math.floor(i/(1.5*e)),r=n>=o,h=g(t),l=f(t);h===l&&(h+=.5,l>=.5&&!a?l-=.5:h+=.5);for(var c=Math.abs(h-l),u=v(c),d=Math.ceil(h/(1*Math.pow(10,u)))*Math.pow(10,u),p=a?0:Math.floor(l/(1*Math.pow(10,u)))*Math.pow(10,u),m=d-p,b=Math.pow(10,u),x=Math.round(m/b);(x>o||o>2*x)&&!r;)if(x>o)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(s&&u>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=n,b=m/x),{steps:x,stepValue:b,min:p,max:p+x*b}},a.niceNum=function(t,i){var e,a=Math.floor(Math.log10(t)),s=t/Math.pow(10,a);return e=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,e*Math.pow(10,a)},a.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('');"):a[t]=a[t];return i?e(i):e}if(t instanceof Function)return t(i);var a={};return e(t,i)}),b=(a.generateLabels=function(t,i,e,a){var n=new Array(i);return t&&s(n,function(i,s){n[s]=m(t,{value:e+a*(s+1)})}),n},a.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,a=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e):a*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}}),x=a.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),y=(a.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),a.animationLoop=function(t,i,e,a,s,n){var o=0,r=b[e]||b.linear,h=function(){o++;var e=o/i,l=r(e);t.call(n,l,e,o),a.call(n,l,e),i>o?n.animationFrame=x(h):s.apply(n)};x(h)},a.getRelativePosition=function(t){var i,e,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,n=s.getBoundingClientRect();return a.touches?(i=a.touches[0].clientX-n.left,e=a.touches[0].clientY-n.top):(i=a.clientX-n.left,e=a.clientY-n.top),{x:i,y:e}},a.addEvent=function(t,i,e){t.addEventListener?t.addEventListener(i,e):t.attachEvent?t.attachEvent("on"+i,e):t["on"+i]=e}),w=a.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=l},C=(a.bindEvents=function(t,i,e){t.events||(t.events={}),s(i,function(i){t.events[i]=function(){e.apply(t,arguments)},y(t.chart.canvas,i,t.events[i])})},a.unbindEvents=function(t,i){s(i,function(i,e){w(t.chart.canvas,e,i)})}),k=a.getMaximumWidth=function(t){var i=t.parentNode,e=parseInt(S(i,"padding-left"))+parseInt(S(i,"padding-right"));return i.clientWidth-e},A=a.getMaximumHeight=function(t){var i=t.parentNode,e=parseInt(S(i,"padding-bottom"))+parseInt(S(i,"padding-top"));return i.clientHeight-e},S=a.getStyle=function(t,i){return t.currentStyle?t.currentStyle[i]:document.defaultView.getComputedStyle(t,null).getPropertyValue(i)},P=(a.getMaximumSize=a.getMaximumWidth,a.retinaScale=function(t){var i=t.ctx,e=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(i.canvas.style.width=e+"px",i.canvas.style.height=a+"px",i.canvas.height=a*window.devicePixelRatio,i.canvas.width=e*window.devicePixelRatio,i.scale(window.devicePixelRatio,window.devicePixelRatio))}),M=a.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},_=a.fontString=function(t,i,e){return i+" "+t+"px "+e},R=a.longestText=function(t,i,e){t.font=i;var a=0;return s(e,function(i){var e=t.measureText(i).width;a=e>a?e:a}),a},I=a.drawRoundedRectangle=function(t,i,e,a,s,n){t.beginPath(),t.moveTo(i+n,e),t.lineTo(i+a-n,e),t.quadraticCurveTo(i+a,e,i+a,e+n),t.lineTo(i+a,e+s-n),t.quadraticCurveTo(i+a,e+s,i+a-n,e+s),t.lineTo(i+n,e+s),t.quadraticCurveTo(i,e+s,i,e+s-n),t.lineTo(i,e+n),t.quadraticCurveTo(i,e,i+n,e),t.closePath()};a.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},a.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};e.instances={},e.Type=function(t,i){this.data=t.data,this.options=t.options,this.chart=i,this.id=c(),e.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},o(e.Type.prototype,{initialize:function(){return this},clear:function(){return M(this.chart),this},stop:function(){return e.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=k(this.chart.canvas),e=this.options.maintainAspectRatio?i/this.chart.aspectRatio:A(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=e,P(this.chart),this},redraw:l,render:function(t){if(0!==this.options.animation.duration){var i=new e.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var e=a.easingEffects[i.easing],s=i.currentStep/i.numSteps,n=e(s);t.draw(n,s,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,e.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){a.each(this.data.datasets,function(i,e){a.each(i.metaData,t,this,i.metaData,e)},this)},eachValue:function(t){a.each(this.data.datasets,function(i,e){a.each(i.data,t,this,e)},this)},eachDataset:function(t){a.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var i,e=[],s=a.getRelativePosition(t),n=function(t){e.push(t.metaData[i])},o=0;o0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.defaultColor,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}}),e.Line=e.Element.extend({draw:function(){var t=this._vm,i=this._chart.ctx;a.each(t._points,function(e,a){if(0===a)i.moveTo(e._vm.x,e._vm.y);else if(t._tension>0,0)i.lineTo(e._vm.x,e._vm.y);else{var s=this.previousPoint(e,t._points,a);i.bezierCurveTo(s._vm.controlPointNextX,s._vm.controlPointNextY,e._vm.controlPointPreviousX,e._vm.controlPointPreviousY,e._vm.x,e._vm.y)}},this),t._points.length>0&&(i.lineTo(t._points[t._points.length-1].x,t.scaleZero),i.lineTo(t._points[0].x,t.scaleZero),i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.closePath(),i.fill()),i.lineWidth=t.borderWidth||e.defaults.global.defaultColor,i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.beginPath(),a.each(t._points,function(e,a){if(0===a)i.moveTo(e._vm.x,e._vm.y);else if(t._tension>0,0)i.lineTo(e._vm.x,e._vm.y);else{var s=this.previousPoint(e,t._points,a);i.bezierCurveTo(s._vm.controlPointNextX,s._vm.controlPointNextY,e._vm.controlPointPreviousX,e._vm.controlPointPreviousY,e._vm.x,e._vm.y)}},this),i.stroke()},previousPoint:function(t,i,e){return a.findPreviousWhere(i,function(){return!0},e)||t}}),e.Arc=e.Element.extend({inRange:function(t,i){var e=this._vm,s=a.getAngleFromPoint(e,{x:t,y:i}),n=s.angle>=e.startAngle&&s.angle<=e.endAngle,o=s.distance>=e.innerRadius&&s.distance<=e.outerRadius;return n&&o},tooltipPosition:function(){var t=this._vm,i=t.startAngle+(t.endAngle-t.startAngle)/2,e=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(i)*e,y:t.y+Math.sin(i)*e}},draw:function(){var t=this._chart.ctx,i=this._vm;t.beginPath(),t.arc(i.x,i.y,i.outerRadius,i.startAngle,i.endAngle),t.arc(i.x,i.y,i.innerRadius,i.endAngle,i.startAngle,!0),t.closePath(),t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,t.fill(),t.lineJoin="bevel",i.borderWidth&&t.stroke()}}),e.Rectangle=e.Element.extend({draw:function(){var t=this._vm,i=this.ctx,e=t.width/2,a=t.x-e,s=t.x+e,n=t.base-(t.base-t.y),o=t.borderWidth/2;t.borderWidth&&(a+=o,s-=o,n+=o),i.beginPath(),i.fillStyle=t.backgroundColor,i.strokeStyle=t.borderColor,i.lineWidth=t.borderWidth,i.moveTo(a,t.base),i.lineTo(a,n),i.lineTo(s,n),i.lineTo(s,t.base),i.fill(),t.borderWidth&&i.stroke()},height:function(){var t=this._vm;return t.base-t.y},inRange:function(t,i){var e=this._vm;return e.y=e.x-e.width/2&&t<=e.x+e.width/2&&i>=e.y&&i<=e.base:t>=e.x-e.width/2&&t<=e.x+e.width/2&&i>=e.base&&i<=e.y},inGroupRange:function(t){var i=this._vm;return t>=i.x-i.width/2&&t<=i.x+i.width/2},tooltipPosition:function(){var t=this._vm;return t.y=0&&(e=this._data.datasets[h].metaData,s=r(e,this._active[0]),-1===s);h--);var l=function(t){var i,e,r,h,l,c=[],u=[],d=[];return a.each(this._data.datasets,function(t){i=t.metaData,i[s]&&i[s].hasValue()&&c.push(i[s])}),a.each(c,function(t){u.push(t._vm.x),d.push(t._vm.y),n.push(a.template(this._options.tooltips.multiTemplate,t)),o.push({fill:t._vm.backgroundColor,stroke:t._vm.borderColor})},this),l=f(d),r=g(d),h=f(u),e=g(u),{x:h>this._chart.width/2?h:e,y:(l+r)/2}}.call(this,s);a.extend(this,{x:l.x,y:l.y,labels:n,title:this._active.length?this._active[0].label:"",legendColors:o,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this.height=n.length*this.fontSize+(n.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize;var c=t.measureText(this.title).width,u=R(t,this.font,n)+this.fontSize+3,d=g([u,c]);this.width=d+2*this.xPadding;var p=this.height/2;this.y-p<0?this.y=p:this.y+p>this._chart.height&&(this.y=this._chart.height-p),this.x>this._chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset}return this},draw:function(){var t=this._chart.ctx,i=this._vm;switch(this._options.hover.mode){case"single":t.font=_(i.fontSize,i._fontStyle,i._fontFamily),i.xAlign="center",i.yAlign="above";var e=i.caretPadding||2,s=t.measureText(i.text).width+2*i.xPadding,n=i.fontSize+2*i.yPadding,o=n+i.caretHeight+e;i.x+s/2>this._chart.width?i.xAlign="left":i.x-s/2<0&&(i.xAlign="right"),i.y-o<0&&(i.yAlign="below");var r=i.x-s/2,h=i.y-o;if(t.fillStyle=a.color(i.backgroundColor).alpha(i.opacity).rgbString(),this._custom)this._custom(this._vm);else{switch(i.yAlign){case"above":t.beginPath(),t.moveTo(i.x,i.y-e),t.lineTo(i.x+i.caretHeight,i.y-(e+i.caretHeight)),t.lineTo(i.x-i.caretHeight,i.y-(e+i.caretHeight)),t.closePath(),t.fill();break;case"below":h=i.y+e+i.caretHeight,t.beginPath(),t.moveTo(i.x,i.y+e),t.lineTo(i.x+i.caretHeight,i.y+e+i.caretHeight),t.lineTo(i.x-i.caretHeight,i.y+e+i.caretHeight),t.closePath(),t.fill()}switch(i.xAlign){case"left":r=i.x-s+(i.cornerRadius+i.caretHeight);break;case"right":r=i.x-(i.cornerRadius+i.caretHeight)}I(t,r,h,s,n,i.cornerRadius),t.fill(),t.fillStyle=a.color(i.textColor).alpha(i.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(i.text,r+s/2,h+n/2)}break;case"label":I(t,i.x,i.y-i.height/2,i.width,i.height,i.cornerRadius),t.fillStyle=a.color(i.backgroundColor).alpha(i.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.color(i.titleTextColor).alpha(i.opacity).rgbString(),t.font=_(i.fontSize,i._titleFontStyle,i._titleFontFamily),t.fillText(i.title,i.x+i.xPadding,this.getLineHeight(0)),t.font=_(i.fontSize,i._fontStyle,i._fontFamily),a.each(i.labels,function(e,s){t.fillStyle=a.color(i.textColor).alpha(i.opacity).rgbString(),t.fillText(e,i.x+i.xPadding+i.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=a.color(i.legendBackgroundColor).alpha(i.opacity).rgbString(),t.fillRect(i.x+i.xPadding,this.getLineHeight(s+1)-i.fontSize/2,i.fontSize,i.fontSize),t.fillStyle=a.color(i.legendColors[s].fill).alpha(i.opacity).rgbString(),t.fillRect(i.x+i.xPadding,this.getLineHeight(s+1)-i.fontSize/2,i.fontSize,i.fontSize)},this)}},getLineHeight:function(t){var i=this._vm.y-this._vm.height/2+this._vm.yPadding,e=t-1;return 0===t?i+this._vm.titleFontSize/2:i+(1.5*this._vm.fontSize*e+this._vm.fontSize/2)+1.5*this._vm.titleFontSize}}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,i,e){e||(t.animating=!0);for(var s=0;s1&&(i=Math.floor(this.dropFrames),this.dropFrames-=i);for(var e=0;ethis.animations[e].animationObject.numSteps&&(this.animations[e].animationObject.currentStep=this.animations[e].animationObject.numSteps),this.animations[e].animationObject.render(this.animations[e].chartInstance,this.animations[e].animationObject),this.animations[e].animationObject.currentStep==this.animations[e].animationObject.numSteps&&(this.animations[e].chartInstance.animating=!1,this.animations.splice(e,1),e--);var s=Date.now(),n=s-t-this.frameDuration,o=n/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&a.requestAnimFrame.call(window,this.digestWrapper)}},a.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){s(e.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),d?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,a={scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},bars:{borderWidth:2,valueSpacing:5,datasetSpacing:1},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};i.Type.extend({name:"Bar",defaults:a,initialize:function(){e.bindEvents(this,this.options.events,this.onHover),this.BarClass=i.Rectangle.extend({ctx:this.chart.ctx}),e.each(this.data.datasets,function(t,i){t.metaData=[],e.each(t.data,function(i,e){t.metaData.push(new this.BarClass)},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),i.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,i,a,s){var n=this.scales[this.data.datasets[s].xAxisID],o=this.scales[this.data.datasets[s].yAxisID];e.extend(t,{base:o.getPixelForValue(0),width:n.calculateBarWidth(this.data.datasets.length),x:n.calculateBarX(this.data.datasets.length,s,i),y:o.calculateBarY(this.data.datasets,s,i,this.data.datasets[s].data[i]),_datasetIndex:s,_index:i}),t.save()},this),this.tooltip=new i.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length)switch(this.options.hover.mode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].backgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].borderColor;break;case"label":for(var i=0;ie?i[s]+=e:t[s]+=e},this)},this);var s=t.concat(i);this.min=e.min(s),this.max=e.max(s)}else e.each(a.data.datasets,function(t){t.yAxisID===this.id&&e.each(t.data,function(t,i){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var n=i.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),o=new n({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=a.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*a.options.bars.valueSpacing},calculateBarWidth:function(t){var i=this.calculateBaseWidth()-(t-1)*a.options.bars.datasetSpacing;return a.options.stacked?i:i/t},calculateBarX:function(t,i,e){var s=this.calculateBaseWidth(),n=this.getPixelForValue(null,e,!0)-s/2,o=this.calculateBarWidth(t);return a.options.stacked?n+o/2:n+o*i+i*a.options.bars.datasetSpacing+o/2}});this.scales[o.id]=o,e.each(this.options.scales.yAxes,function(t){var e=i.scales.getScaleConstructor(t.scaleType),n=new e({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,i){var e=0;if(a.options.stacked){var s=a.data.datasets[t].metaData[i];if(s.value<0)for(var n=0;t>n;n++)a.data.datasets[n].yAxisID===this.id&&(e+=a.data.datasets[n].metaData[i].valuen;n++)a.data.datasets[n].yAxisID===this.id&&(e+=a.data.datasets[n].metaData[i].value>e?a.data.datasets[n].metaData[i].value:0); -return this.getPixelForValue(e)}return e=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(e=this.getPixelForValue(0),e+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(e=this.getPixelForValue(this.max)),e},calculateBarY:function(t,i,e,s){if(a.options.stacked){for(var n=0,o=0,r=0;i>r;r++)t[r].metaData[e].value<0?o+=t[r].metaData[e].value||0:n+=t[r].metaData[e].value||0;return this.getPixelForValue(0>s?o+s:n+s)}var h=0;for(r=i;r=0?n=s.getPixelForValue(0):s.min<0&&s.max<0&&(n=s.getPixelForValue(s.max)),e.extend(t,{y:n,base:n})}),this.render()},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.eachElement(function(t,e,a){t.transition(i).draw()},this),this.tooltip.transition(i).draw()}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,a={segments:{showStroke:!0,strokeColor:"#fff",borderWidth:2},hover:{animationDuration:400},animation:{animateRotate:!0,animateScale:!1},cutoutPercentage:50,legendTemplate:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};i.Type.extend({name:"Doughnut",defaults:a,initialize:function(){this.Slice=i.Arc.extend({_chart:this.chart,x:this.chart.width/2,y:this.chart.height/2}),this.options.tooltips.enabled&&e.bindEvents(this,this.options.events,this.onHover),this.data.metaData=[],e.each(this.data.data,function(t,i){var a=new this.Slice;"number"==typeof t?e.extend(a,{value:t}):e.extend(a,t),e.extend(a,{startAngle:1.5*Math.PI,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(a.value),outerRadius:this.options.animation.animateScale?0:this.outerRadius,innerRadius:this.options.animation.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout}),a.backgroundColor||(t.backgroundColor="hsl("+360*i/this.data.data.length+", 100%, 50%)"),a.save(),this.data.metaData.push(a)},this),this.tooltip=new i.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},onHover:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=this.getSliceAtEvent(t),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length&&(this.lastActive[0].backgroundColor=this.data.data[this.lastActive[0]._index].backgroundColor),this.active.length&&this.options.hover.mode&&(this.active[0].backgroundColor=this.data.data[this.active[0]._index].hoverBackgroundColor||e.color(this.data.data[this.active[0]._index].backgroundColor).saturate(.5).darken(.35).rgbString()),this.options.tooltips.enabled&&(this.tooltip.initialize(),this.active.length?(e.extend(this.tooltip,{opacity:1,_active:this.active}),this.tooltip.update()):e.extend(this.tooltip,{opacity:0})),this.tooltip.pivot(),!this.animating){var i;e.each(this.active,function(t,e){t!==this.lastActive[e]&&(i=!0)},this),(!this.lastActive.length&&this.active.length||this.lastActive.length&&!this.active.length||this.lastActive.length&&this.active.length&&i)&&(this.stop(),this.render(this.options.hover.animationDuration))}return this.lastActive=this.active,this},getSliceAtEvent:function(t){var i=[],a=e.getRelativePosition(t);return e.each(this.data.metaData,function(t,e){t.inRange(a.x,a.y)&&i.push(t)},this),i},calculateCircumference:function(t){return this.total>0?2*Math.PI*(t/this.total):0},update:function(){this.total=0,e.each(this.data.data,function(t){this.total+=Math.abs(t.value)},this),this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segments.borderWidth/2)/2,e.each(this.data.metaData,function(t,i){var a=this.data.data[i];e.extend(t,{_index:i,x:this.chart.width/2,y:this.chart.height/2,value:a.value,label:a.label,circumference:this.calculateCircumference(a.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.cutoutPercentage,backgroundColor:a.backgroundColor,hoverBackgroundColor:a.hoverBackgroundColor||a.backgroundColor,borderWidth:this.options.segments.borderWidth,borderColor:this.options.segments.strokeColor}),e.extend(t,{endAngle:t.startAngle+t.circumference}),0===i&&(t.startAngle=1.5*Math.PI),i",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},stacked:!1,points:{radius:3,borderWidth:1,hoverRadius:5,hoverBorderWidth:2,backgroundColor:i.defaults.global.defaultColor,borderColor:i.defaults.global.defaultColor,hitRadius:6},lines:{tension:.4},borderWidth:2,hoverBorderWidth:2,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '};i.Type.extend({name:"Line",defaults:a,initialize:function(){e.bindEvents(this,this.options.events,this.events);e.each(this.data.datasets,function(t,a){t.metaDataset=new i.Line,t.metaData=[],e.each(t.data,function(e,a){t.metaData.push(new i.Point)},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),i.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,i){e.extend(t.metaDataset,{_points:t.metaData,_datasetIndex:i,_chart:this.chart}),e.extend(t,e.merge(this.options,t)),t.metaDataset.save()},this),this.eachElement(function(t,i,a,s){var n=this.scales[this.data.datasets[s].xAxisID];e.extend(t,{x:n.getPixelForValue(null,i,!0),y:this.chartArea.bottom,_datasetIndex:s,_index:i,_chart:this.chart}),e.extend(t,{controlPointPreviousX:this.previousPoint(a,i).x,controlPointPreviousY:this.nextPoint(a,i).y,controlPointNextX:this.previousPoint(a,i).x,controlPointNextY:this.nextPoint(a,i).y}),t.save()},this),this.tooltip=new i.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},nextPoint:function(t,i){return t[i-1]||t[i]},previousPoint:function(t,i){return t[i+1]||t[i]},update:function(){i.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,i){var a=this.scales[t.yAxisID];e.extend(t.metaDataset,{_datasetIndex:i,_points:t.metaData,scaleTop:a.top,scaleBottom:a.bottom,scaleZero:a.getPixelForValue(0),tension:t.tension||this.options.lines.tension,backgroundColor:t.backgroundColor||this.options.backgroundColor,borderWidth:t.borderWidth||this.options.borderWidth,borderColor:t.borderColor||this.options.borderColor}),t.metaDataset.pivot()}),this.eachElement(function(t,i,a,s){var n=this.scales[this.data.datasets[s].xAxisID],o=this.scales[this.data.datasets[s].yAxisID];e.extend(t,{_chart:this.chart,_datasetIndex:s,_index:i,label:this.data.labels[i],value:this.data.datasets[s].data[i],datasetLabel:this.data.datasets[s].label,offsetGridLines:this.options.offsetGridLines,x:n.getPixelForValue(null,i,!0),y:o.getPointPixelForValue(this.data.datasets[s].data[i],i,s),tension:this.data.datasets[s].metaDataset.tension,radius:this.data.datasets[s].pointRadius||this.options.points.radius,backgroundColor:this.data.datasets[s].pointBackgroundColor||this.options.points.backgroundColor,borderWidth:this.data.datasets[s].pointBorderWidth||this.options.pointsborderWidth,hoverRadius:this.data.datasets[s].pointHitRadius||this.options.points.hitRadius})},this),this.eachElement(function(t,i,a,s){var n=e.splineCurve(this.previousPoint(a,i),t,this.nextPoint(a,i),t.tension);t.controlPointPreviousX=n.previous.x,t.controlPointNextX=n.next.x,n.next.y>this.chartArea.bottom?t.controlPointNextY=this.chartArea.bottom:n.next.ythis.chartArea.bottom?t.controlPointPreviousY=this.chartArea.bottom:n.previous.ye?a[s]+=e:i[s]+=e},this)},this);var s=i.concat(a);this.min=e.min(s),this.max=e.max(s)}else e.each(t.data.datasets,function(t){t.yAxisID===this.id&&e.each(t.data,function(t,i){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=i.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[n.id]=n,e.each(this.options.scales.yAxes,function(e){var s=i.scales.getScaleConstructor(e.scaleType),n=new s({ctx:this.chart.ctx,options:e,calculateRange:a,getPointPixelForValue:function(i,e,a){if(t.options.stacked){for(var s=0,n=0,o=0;a>o;++o)t.data.datasets[o].data[e]<0?n+=t.data.datasets[o].data[e]:s+=t.data.datasets[o].data[e];return this.getPixelForValue(0>i?n+i:s+i)}return this.getPixelForValue(i)},id:e.id});this.scales[n.id]=n},this)},redraw:function(){},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var a=this.data.datasets.length-1;a>=0;a--){var s=this.data.datasets[a];e.each(s.metaData,function(t,e){t.transition(i)},this),s.metaDataset.transition(i).draw(),e.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(i).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var i;if(this.lastActive.length)switch(this.options.hover.mode){case"single":i=this.data.datasets[this.lastActive[0]._datasetIndex],this.lastActive[0].radius=i.pointRadius,this.lastActive[0].backgroundColor=i.pointBackgroundColor,this.lastActive[0].borderColor=i.pointBorderColor,this.lastActive[0].borderWidth=i.pointBorderWidth;break;case"label":for(var a=0;a",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0,legendTemplate:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};i.Type.extend({name:"PolarArea",defaults:a,initialize:function(){var t=this,a=i.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new a({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,e.each(t.data.data,function(t){null===this.min?this.min=t.value:t.valuethis.max&&(this.max=t.value)},this)}}),this.Slice=i.Arc.extend(),this.options.showTooltips&&e.bindEvents(this,this.options.events,this.onHover),this.data.metaData=[],e.each(this.data.data,function(t,i){var a=new this.Slice({_chart:this.chart,innerRadius:0,startAngle:1.5*Math.PI,endAngle:1.5*Math.PI,x:this.chart.width/2,y:this.chart.height/2});"number"==typeof t?e.extend(a,{value:t}):e.extend(a,t),a.backgroundColor||(t.backgroundColor="hsl("+360*i/this.data.data.length+", 100%, 50%)"),a.save(),this.data.metaData.push(a)},this),this.tooltip=new i.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},updateScaleRange:function(){e.extend(this.scale,{size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segment.borderWidth/2)/2;var t=1/this.data.data.length*2;e.each(this.data.metaData,function(i,a){var s=this.data.data[a],n=1.5*Math.PI+Math.PI*t*a,o=n+t*Math.PI;e.extend(i,{_index:a,x:this.chart.width/2,y:this.chart.height/2,value:s.value,label:s.label,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(i.value),startAngle:n,endAngle:o,backgroundColor:s.backgroundColor,hoverBackgroundColor:s.hoverBackgroundColor||s.backgroundColor,borderWidth:this.options.borderWidth,borderColor:this.options.segmentStrokeColor}),i.pivot()},this),this.render()},draw:function(t){var i=t||1;this.clear(),e.each(this.data.metaData,function(t,e){t.transition(i).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:{scale:{scaleType:"radialLinear",display:!0,animate:!1,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0,.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},pointDot:!0,pointRadius:3,pointBorderWidth:1,pointHoverRadius:5,pointHoverBorderWidth:2,pointBackgroundColor:i.defaults.global.defaultColor,pointBorderColor:i.defaults.global.defaultColor,pointHitRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){this.PointClass=i.Point.extend({display:this.options.pointDot,_chart:this.chart}),this.datasets=[],this.buildScale(this.data),this.options.showTooltips&&e.bindEvents(this,this.options.events,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(this.data.datasets,function(t){var i={label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor,points:[]};this.datasets.push(i),e.each(t.data,function(e,a){var s;this.scale.animation||(s=this.scale.getPointPosition(a,this.scale.calculateCenterOffset(e))),i.points.push(new this.PointClass({value:e,label:this.data.labels[a],datasetLabel:t.label,x:this.options.animation?this.scale.xCenter:s.x,y:this.options.animation?this.scale.yCenter:s.y,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor,radius:t.pointRadius||this.options.pointRadius,backgroundColor:t.pointBackgroundColor||this.options.pointBackgroundColor,borderWidth:t.pointBorderWidth||this.options.pointBorderWidth,hoverRadius:t.pointHitRadius||this.options.pointHitRadius}))},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),a=e.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},i),s=2*Math.PI/this.scale.valuesCount,n=Math.round((a.angle-1.5*Math.PI)/s),o=[];return(n>=this.scale.valuesCount||0>n)&&(n=0),a.distance<=this.scale.drawingArea&&e.each(this.datasets,function(t){o.push(t.points[n])}),o},buildScale:function(t){var a=this,s=i.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new s({options:this.options.scale,height:this.chart.height,width:this.chart.width,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,labels:t.labels,valuesCount:t.datasets[0].data.length,calculateRange:function(){this.min=null,this.max=null,e.each(a.data.datasets,function(t){t.yAxisID===this.id&&e.each(t.data,function(t,i){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},addData:function(t,i){this.scale.valuesCount++,e.each(t,function(t,e){var a=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[e].points.push(new this.PointClass({value:t,label:i,datasetLabel:this.datasets[e].label,x:a.x,y:a.y,strokeColor:this.datasets[e].pointStrokeColor,fillColor:this.datasets[e].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(){e.each(this.data.datasets,function(t,i){e.extend(this.datasets[i],{label:t.label||null,fillColor:t.fillColor,strokeColor:t.strokeColor,pointColor:t.pointColor,pointStrokeColor:t.pointStrokeColor}),e.each(t.data,function(a,s){e.extend(this.datasets[i].points[s],{value:a,label:this.data.labels[s],datasetLabel:t.label,strokeColor:t.pointStrokeColor,fillColor:t.pointColor,highlightFill:t.pointHighlightFill||t.pointColor,highlightStroke:t.pointHighlightStroke||t.pointStrokeColor})},this)},this),this.eachPoints(function(t){t.save()}),this.reflow(),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.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var i=t||1,a=this.chart.ctx;this.clear(),this.scale.draw(),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.hasValue()&&t.transition(i)},this),a.lineWidth=this.options.datasetStrokeWidth,a.strokeStyle=t.strokeColor,a.beginPath(),e.each(t.points,function(t,i){0===i?a.moveTo(t.x,t.y):a.lineTo(t.x,t.y)},this),a.closePath(),a.stroke(),a.fillStyle=t.fillColor,a.fill(),e.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers;i.scaleService={fitScalesForChart:function(t,i,a){var s=10,n=10;if(t){var o=e.where(t.scales,function(t){return"left"==t.options.position}),r=e.where(t.scales,function(t){return"right"==t.options.position}),h=e.where(t.scales,function(t){return"top"==t.options.position}),l=e.where(t.scales,function(t){return"bottom"==t.options.position});if(0===h.length||0===l.length){var c=0,u=function(t){t.options.labels.show&&(c=Math.max(c,t.options.labels.fontSize))};e.each(o,u),e.each(r,u),0===h.length&&(n+=.75*c),0===l.length&&(n+=1.5*c)}var d,p=i/2,g=a/2,f=g/p;t.options.maintainAspectRatio&&(d=a/i,f!=d&&(g=p*d,f=d)),p-=2*s,g-=2*n;var v=(i-p)/(o.length+r.length),m=(a-g)/(h.length+l.length),b=[],x=function(t){var i=t.fit(v,g);b.push({horizontal:!1,minSize:i,scale:t})},y=function(t){var i=t.fit(p,m);b.push({horizontal:!0,minSize:i,scale:t})};e.each(o,x),e.each(r,x),e.each(h,y),e.each(l,y);var w=a-2*n,C=i-2*s;if(e.each(b,function(t){t.horizontal?w-=t.minSize.height:C-=t.minSize.width}),t.options.maintainAspectRatio){var k=w/C;k!=d&&(C>w?C=w/d:w=C*d)}var A=function(t){var i=e.findNextWhere(b,function(i){return i.scale===t});i&&t.fit(i.minSize.width,w)},S=function(t){var i=e.findNextWhere(b,function(i){return i.scale===t});i&&t.fit(C,i.minSize.width)};e.each(o,A),e.each(r,A),e.each(h,S),e.each(l,S);var P=s,M=n;e.each(o,function(t){P+=t.width}),e.each(h,function(t){M+=t.height});var _=s,R=n,I=function(t){t.left=_,t.right=_+t.width,t.top=M,t.bottom=M+w,_=t.right},z=function(t){t.left=P,t.right=P+C,t.top=R,t.bottom=R+t.height,R=t.bottom};e.each(o,I),e.each(h,z),_+=C,R+=w,e.each(r,I),e.each(l,z),t.chartArea={left:P,top:M,right:P+C,bottom:M+w}}}},i.scales={constructors:{},registerScaleType:function(t,i){this.constructors[t]=i},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}};var a=i.Element.extend({calculateRange:e.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,i){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var n;if(n=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(i/(2*this.options.labels.fontSize))),n=Math.max(2,n),this.options.beginAtZero){var o=e.sign(this.min),r=e.sign(this.max);0>o&&0>r?this.max=0:o>0&&r>0&&(this.min=0)}for(var h=e.niceNum(this.max-this.min,!1),l=e.niceNum(h/(n-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=e.max(this.ticks),this.min=e.min(this.ticks)},buildLabels:function(){this.labels=[],e.each(this.ticks,function(t,i,a){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,i,a):this.options.labels.template&&(s=e.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var i,e=this.max-this.min;return i=this.isHorizontal()?this.left+this.width/e*(t-this.min):this.bottom-this.height/e*(t-this.min)},fit:function(t,i){this.calculateRange(),this.generateTicks(t,i),this.buildLabels();var a={width:0,height:0};if(this.isHorizontal()?(a.width=t,a.height=this.options.gridLines.show?25:0):(a.height=i,a.width=this.options.gridLines.show?25:0),this.options.labels.show){var s=e.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var n=(i-a.height,1.5*this.options.labels.fontSize);a.height=Math.min(i,a.height+n)}else{var o=t-a.width,r=e.longestText(this.ctx,s,this.labels);o>r?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var i,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){i=!0,a=void 0!==e.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-10,n="bottom"==this.options.position?this.top+10:this.bottom;e.each(this.ticks,function(o,r){var h=this.getPixelForValue(o);0===o||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,i=!0):i&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,i=!1),h+=e.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var o;o="top"==this.options.position?this.top:this.top+20,this.ctx.textAlign="center",this.ctx.textBaseline="top",this.ctx.font=e.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),e.each(this.labels,function(t,i){var e=this.getPixelForValue(this.ticks[i]);this.ctx.fillText(t,e,o)},this)}}else{if(this.options.gridLines.show){i=!0,a=void 0!==e.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-10,h="right"==this.options.position?this.left+10:this.right;e.each(this.ticks,function(s,n){var o=this.getPixelForValue(s);0===s||!a&&0===n?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,i=!0):i&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,i=!1),o+=e.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,o),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,o),this.ctx.lineTo(t.right,o)),this.ctx.stroke()},this)}if(this.options.labels.show){var l,c=this.width-25;l="left"==this.options.position?this.left:this.left+20,this.ctx.textAlign="left",this.ctx.textBaseline="middle",this.ctx.font=e.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),e.each(this.labels,function(t,i){var e=this.getPixelForValue(this.ticks[i]);this.ctx.fillText(t,l,e,c)},this)}}}}});i.scales.registerScaleType("linear",a);var s=i.Element.extend({calculateRange:e.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,i,e){if(this.isHorizontal()){var a=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=a/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),n=s*i+this.paddingLeft;return this.options.gridLines.offsetGridLines&&e&&(n+=s/2),this.left+Math.round(n)}return this.top+i*(this.height/this.max)},calculateLabelRotation:function(t){var i=e.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=i;var a,s,n=this.ctx.measureText(this.labels[0]).width,o=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=o/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var r,h,l=e.longestText(this.ctx,i,this.labels);this.labelWidth=l;for(var c=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>c&&0===this.labelRotation||this.labelWidth>c&&this.labelRotation<=90&&this.labelRotation>0;){if(r=Math.cos(e.toRadians(this.labelRotation)),h=Math.sin(e.toRadians(this.labelRotation)),a=r*n,s=r*o,a+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=a+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,h*l>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=r*l}}else this.labelWidth=0,this.paddingRight=this.padding,this.paddingLeft=this.padding},fit:function(t,i){this.calculateRange(),this.calculateLabelRotation();var a={width:0,height:0},s=e.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=e.longestText(this.ctx,s,this.labels);if(this.isHorizontal()){a.width=t,this.width=t;var o=Math.cos(e.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;a.height=Math.min(o,i)}else a.height=i,this.height=i,a.width=Math.min(n+6,t);return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var i;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){i=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,n=0!==this.labelRotation;e.each(this.labels,function(o,r){var h=this.getPixelForValue(o,r,!1),l=this.getPixelForValue(o,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,i=!0):i&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,i=!1),h+=e.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,n?this.top+12:this.top+8),this.ctx.rotate(-1*e.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=n?"right":"center",this.ctx.textBaseline=n?"middle":"top",this.ctx.fillText(o,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});i.scales.registerScaleType("dataset",s);var n=i.Element.extend({initialize:function(){ -this.size=e.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var i=this.drawingArea/(this.max-this.min);return(t-this.min)*i},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:e.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var i=this.options.override.start+t*this.options.override.stepWidth;ticks.push(i)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=e.sign(this.min),n=e.sign(this.max);0>s&&0>n?this.max=0:s>0&&n>0&&(this.min=0)}for(var o=e.niceNum(this.max-this.min,!1),r=e.niceNum(o/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=e.max(this.ticks),this.min=e.min(this.ticks)},buildYLabels:function(){this.yLabels=[],e.each(this.ticks,function(t,i,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,i,a):this.options.labels.template&&(s=e.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,i,a,s,n,o,r,h,l,c,u,d,p=e.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),g=this.width,f=0;for(this.ctx.font=e.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),i=0;ig&&(g=t.x+s,n=i),t.x-sg&&(g=t.x+a,n=i):i>this.valuesCount/2&&t.x-a0){var s,n=a*(this.drawingArea/Math.max(this.ticks.length,1)),o=this.yCenter-n;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;i--){if(this.options.angleLines.show){var a=this.getPointPosition(i,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(i,this.calculateCenterOffset(this.max)+5);t.font=e.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var n=this.labels.length,o=this.labels.length/2,r=o/2,h=r>i||i>n-r,l=i===r||i===n-r;0===i?t.textAlign="center":i===o?t.textAlign="center":o>i?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[i],s.x,s.y)}}}}});i.scales.registerScaleType("radialLinear",n)}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,a={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},tension:.4,pointRadius:4,pointBorderWidth:1,pointHoverRadius:20,borderWidth:2,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= dataX %>, <%= dataY %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= dataX %>, <%= dataY %>)"}};i.Type.extend({name:"Scatter",defaults:a,initialize:function(){this.PointClass=i.Point.extend({_chart:this.chart,offsetGridLines:this.options.offsetGridLines,borderWidth:this.options.pointBorderWidth,radius:this.options.pointRadius,hoverRadius:this.options.pointHoverRadius}),e.bindEvents(this,this.options.events,this.events),this.buildScale(),i.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,a){t.metaDataset=new i.Line,t.metaData=[],e.each(t.data,function(i,e){t.metaData.push(new this.PointClass)},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.eachDataset(function(t,i){t=e.merge(this.options,t),e.extend(t.metaDataset,{_points:t.metaData,_datasetIndex:i,_chart:this.chart}),t.metaDataset.save()},this),this.eachElement(function(t,i,a,s){var n=this.scales[this.data.datasets[s].xAxisID];e.extend(t,{x:n.getPixelForValue(i),y:this.chartArea.bottom,_datasetIndex:s,_index:i,_chart:this.chart}),e.extend(t,{controlPointPreviousX:this.previousPoint(a,i).x,controlPointPreviousY:this.nextPoint(a,i).y,controlPointNextX:this.previousPoint(a,i).x,controlPointNextY:this.nextPoint(a,i).y}),t.save()},this),this.tooltip=new i.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.update()},nextPoint:function(t,i){return t[i-1]||t[i]},previousPoint:function(t,i){return t[i+1]||t[i]},events:function(t){if("mouseout"==t.type)return this;if(this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.onHover&&this.options.onHover.call(this,this.active),this.lastActive.length)switch(this.options.hover.mode){case"single":this.lastActive[0].backgroundColor=this.data.datasets[this.lastActive[0]._datasetIndex].pointBackgroundColor,this.lastActive[0].borderColor=this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderColor,this.lastActive[0].borderWidth=this.data.datasets[this.lastActive[0]._datasetIndex].pointBorderWidth;break;case"label":for(var i=0;ithis.chartArea.bottom?t.controlPointNextY=this.chartArea.bottom:n.next.ythis.chartArea.bottom?t.controlPointPreviousY=this.chartArea.bottom:n.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,e.each(t.data.datasets,function(t){t.yAxisID===this.id&&e.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},e.each(this.options.scales.xAxes,function(t){var e=i.scales.getScaleConstructor(t.scaleType),s=new e({ctx:this.chart.ctx,options:t,calculateRange:a,id:t.id});this.scales[s.id]=s},this),e.each(this.options.scales.yAxes,function(t){var e=i.scales.getScaleConstructor(t.scaleType),a=new e({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id});this.scales[a.id]=a},this)},redraw:function(){},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.eachDataset(function(t,a){e.each(t.metaData,function(t,e){t.transition(i)},this),t.metaDataset.transition(i).draw(),e.each(t.metaData,function(t){t.draw()})},this),this.tooltip.transition(i).draw()}})}.call(this),!function t(i,e,a){function s(o,r){if(!e[o]){if(!i[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(n)return n(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=e[o]={exports:{}};i[o][0].call(c.exports,function(t){var e=i[o][1][t];return s(e?e:t)},c,c.exports,t,i,e,a)}return e[o].exports}for(var n="function"==typeof require&&require,o=0;o=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*i[0]+.7152*i[1]+.0722*i[2]},contrast:function(t){var i=this.luminosity(),e=t.luminosity();return i>e?(i+.05)/(e+.05):(e+.05)/(i+.05)},level:function(t){var i=this.contrast(t);return i>=7.1?"AAA":i>=4.5?"AA":""},dark:function(){var t=this.values.rgb,i=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>i},light:function(){return!this.dark()},negate:function(){for(var t=[],i=0;3>i;i++)t[i]=255-this.values.rgb[i];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,i=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[i,i,i]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var i=this.values.hsl[0];return i=(i+t)%360,i=0>i?360+i:i,this.values.hsl[0]=i,this.setValues("hsl",this.values.hsl),this},mix:function(t,i){i=1-(null==i?.5:i);for(var e=2*i-1,a=this.alpha()-t.alpha(),s=((e*a==-1?e:(e+a)/(1+e*a))+1)/2,n=1-s,o=this.rgbArray(),r=t.rgbArray(),h=0;hi&&(i+=360),a=(r+h)/2,e=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[i,100*e,100*a]}function s(t){var i,e,a,s=t[0],n=t[1],o=t[2],r=Math.min(s,n,o),h=Math.max(s,n,o),l=h-r;return e=0==h?0:l/h*1e3/10,h==r?i=0:s==h?i=(n-o)/l:n==h?i=2+(o-s)/l:o==h&&(i=4+(s-n)/l),i=Math.min(60*i,360),0>i&&(i+=360),a=h/255*1e3/10,[i,e,a]}function n(t){var i=t[0],e=t[1],s=t[2],n=a(t)[0],o=1/255*Math.min(i,Math.min(e,s)),s=1-1/255*Math.max(i,Math.max(e,s));return[n,100*o,100*s]}function o(t){var i,e,a,s,n=t[0]/255,o=t[1]/255,r=t[2]/255;return s=Math.min(1-n,1-o,1-r),i=(1-n-s)/(1-s)||0,e=(1-o-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*i,100*e,100*a,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var i=t[0]/255,e=t[1]/255,a=t[2]/255;i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*i+.3576*e+.1805*a,n=.2126*i+.7152*e+.0722*a,o=.0193*i+.1192*e+.9505*a;return[100*s,100*n,100*o]}function c(t){var i,e,a,s=l(t),n=s[0],o=s[1],r=s[2];return n/=95.047,o/=100,r/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,i=116*o-16,e=500*(n-o),a=200*(o-r),[i,e,a]}function u(t){return H(c(t))}function d(t){var i,e,a,s,n,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return n=255*h,[n,n,n];e=.5>h?h*(1+r):h+r-h*r,i=2*h-e,s=[0,0,0];for(var l=0;3>l;l++)a=o+1/3*-(l-1),0>a&&a++,a>1&&a--,n=1>6*a?i+6*(e-i)*a:1>2*a?e:2>3*a?i+(e-i)*(2/3-a)*6:i,s[l]=255*n;return s}function p(t){var i,e,a=t[0],s=t[1]/100,n=t[2]/100;return n*=2,s*=1>=n?n:2-n,e=(n+s)/2,i=2*s/(n+s),[a,100*i,100*e]}function f(t){return n(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function x(t){var i=t[0]/60,e=t[1]/100,a=t[2]/100,s=Math.floor(i)%6,n=i-Math.floor(i),o=255*a*(1-e),r=255*a*(1-e*n),h=255*a*(1-e*(1-n)),a=255*a;switch(s){case 0:return[a,h,o];case 1:return[r,a,o];case 2:return[o,a,h];case 3:return[o,r,a];case 4:return[h,o,a];case 5:return[a,o,r]}}function y(t){var i,e,a=t[0],s=t[1]/100,n=t[2]/100;return e=(2-s)*n,i=s*n,i/=1>=e?e:2-e,i=i||0,e/=2,[a,100*i,100*e]}function w(t){return n(x(t))}function C(t){return o(x(t))}function k(t){return h(x(t))}function A(t){var i,e,a,s,n=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),i=Math.floor(6*n),e=1-h,a=6*n-i,0!=(1&i)&&(a=1-a),s=o+a*(e-o),i){default:case 6:case 0:r=e,g=s,b=o;break;case 1:r=s,g=e,b=o;break;case 2:r=o,g=e,b=s;break;case 3:r=o,g=s,b=e;break;case 4:r=s,g=o,b=e;break;case 5:r=e,g=o,b=s}return[255*r,255*g,255*b]}function S(t){return a(A(t))}function P(t){return s(A(t))}function M(t){return o(A(t))}function _(t){return h(A(t))}function R(t){var i,e,a,s=t[0]/100,n=t[1]/100,o=t[2]/100,r=t[3]/100;return i=1-Math.min(1,s*(1-r)+r),e=1-Math.min(1,n*(1-r)+r),a=1-Math.min(1,o*(1-r)+r),[255*i,255*e,255*a]}function I(t){return a(R(t))}function z(t){return s(R(t))}function T(t){return n(R(t))}function W(t){return h(R(t))}function L(t){var i,e,a,s=t[0]/100,n=t[1]/100,o=t[2]/100;return i=3.2406*s+-1.5372*n+o*-.4986,e=s*-.9689+1.8758*n+.0415*o,a=.0557*s+n*-.204+1.057*o,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,i=Math.min(Math.max(0,i),1),e=Math.min(Math.max(0,e),1),a=Math.min(Math.max(0,a),1),[255*i,255*e,255*a]}function F(t){var i,e,a,s=t[0],n=t[1],o=t[2];return s/=95.047,n/=100,o/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,i=116*n-16,e=500*(s-n),a=200*(n-o),[i,e,a]}function D(t){return H(F(t))}function B(t){var i,e,a,s,n=t[0],o=t[1],r=t[2];return 8>=n?(e=100*n/903.3,s=7.787*(e/100)+16/116):(e=100*Math.pow((n+16)/116,3),s=Math.pow(e/100,1/3)),i=.008856>=i/95.047?i=95.047*(o/500+s-16/116)/7.787:95.047*Math.pow(o/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[i,e,a]}function H(t){var i,e,a,s=t[0],n=t[1],o=t[2];return i=Math.atan2(o,n),e=360*i/2/Math.PI,0>e&&(e+=360),a=Math.sqrt(n*n+o*o),[s,a,e]}function O(t){return L(B(t))}function E(t){var i,e,a,s=t[0],n=t[1],o=t[2];return a=o/360*2*Math.PI,i=n*Math.cos(a),e=n*Math.sin(a),[s,i,e]}function V(t){return B(E(t))}function N(t){return O(E(t))}function q(t){return U[t]}function Y(t){return a(q(t))}function j(t){return s(q(t))}function X(t){return n(q(t))}function Z(t){return o(q(t))}function G(t){return c(q(t))}function Q(t){return l(q(t))}i.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:n,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:p,hsl2hwb:f,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:k,hwb2rgb:A,hwb2hsl:S,hwb2hsv:P,hwb2cmyk:M,hwb2keyword:_,cmyk2rgb:R,cmyk2hsl:I,cmyk2hsv:z,cmyk2hwb:T,cmyk2keyword:W,keyword2rgb:q,keyword2hsl:Y,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:G,keyword2xyz:Q,xyz2rgb:L,xyz2lab:F,xyz2lch:D,lab2xyz:B,lab2rgb:O,lab2lch:H,lch2lab:E,lch2xyz:V,lch2rgb:N};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,i,e){var a=t("./conversions"),s=function(){return new l};for(var n in a){s[n+"Raw"]=function(t){return function(i){return"number"==typeof i&&(i=Array.prototype.slice.call(arguments)),a[t](i)}}(n);var o=/(\w+)2(\w+)/.exec(n),r=o[1],h=o[2];s[r]=s[r]||{},s[r][h]=s[n]=function(t){return function(i){"number"==typeof i&&(i=Array.prototype.slice.call(arguments));var e=a[t](i);if("string"==typeof e||void 0===e)return e;for(var s=0;si||t[3]&&t[3]<1?u(t,i):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,i){return void 0===i&&(i=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+i+")"}function d(t,i){if(1>i||t[3]&&t[3]<1)return p(t,i);var e=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+e+"%, "+a+"%, "+s+"%)"}function p(t,i){var e=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+e+"%, "+a+"%, "+s+"%, "+(i||t[3]||1)+")"}function g(t,i){return 1>i||t[3]&&t[3]<1?f(t,i):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,i){return void 0===i&&(i=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+i+")"}function v(t,i){return void 0===i&&(i=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==i&&1!==i?", "+i:"")+")"}function m(t){return w[t.slice(0,3)]}function b(t,i,e){return Math.min(Math.max(i,t),e)}function x(t){var i=t.toString(16).toUpperCase();return i.length<2?"0"+i:i}var y=t("color-name");i.exports={getRgba:a,getHsla:s,getRgb:o,getHsl:r,getHwb:n,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:p,hslString:g,hslaString:f,hwbString:v,keyword:m};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,i,e){i.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:6,hoverRadius:4,hoverBorderWidth:2},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&n(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},p=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=2*Math.PI+Math.atan2(o,i);return 0>i&&0>o&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),r=o*s/(s+a),n=o*a/(s+a);return{previous:{x:e.x-r*(i.x-t.x),y:e.y-r*(i.y-t.y)},next:{x:e.x+n*(i.x-t.x),y:e.y+n*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,r=Math.floor(e/(1.5*i)),n=a>=r,h=p(t),l=g(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>r||r>2*x)&&!n;)if(x>r)b*=2,x=Math.round(m/b),x%1!==0&&(n=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return n&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(Math.log10(t)),s=t/Math.pow(10,o);return i=e?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),y=(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,e,i,o,s,a){var r=0,n=x[i]||x.linear,h=function(){r++;var i=r/e,l=n(i);t.call(a,l,i,r),o.call(a,l,i),e>r?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),C=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},y(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){C(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(S(e,"padding-left"))+parseInt(S(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(S(e,"padding-bottom"))+parseInt(S(e,"padding-top"));return e.clientHeight-i},S=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},P=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),I=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},O=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},n(i.Type.prototype,{initialize:function(){return this},clear:function(){return I(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,P(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},r=0;r0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)=i.startAngle&&o.angle<=i.endAngle,r=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return a&&r},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),r=e.borderWidth/2;e.borderWidth&&(o+=r,s-=r,a+=r),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[n].metaData,o=h(i,this._active[0]),-1===o);n--);var l=function(t){var e,i,n,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),r.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=g(u),n=p(u),h=g(d),i=p(d),{x:h>this._chart.width/2?h:i,y:(l+n)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:r,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=p([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,r=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-r<0&&(e.yAlign="below");var n=e.x-o/2,h=e.y-r;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":n=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":n=e.x-(e.cornerRadius+e.caretHeight)}O(t,n,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,n+o/2,h+a/2)}break;case"label":O(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,r=a/this.frameDuration;r>1&&(this.dropFrames+=r),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.calculateBarX(this.data.datasets.length,s,e),y:a,base:n.calculateBarBase(s,e),width:r.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:r,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:r.calculateBarY(s,e),base:r.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render()},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),r=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing; +return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,r=this.calculateBarWidth(t);return o.options.stacked?a+r/2:a+r*e+e*o.options.elements.bar.datasetSpacing+r/2}});this.scales[r.id]=r,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var r=0;t>r;r++)o.data.datasets[r].yAxisID===this.id&&(i+=o.data.datasets[r].data[e]>0?o.data.datasets[r].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,r=0;t>r;r++)o.data.datasets[r].data[e]<0?a+=o.data.datasets[r].data[e]||0:s+=o.data.datasets[r].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var n=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,r=0;o>r;++r)t.data.datasets[r].data[i]<0?a+=t.data.datasets[r].data[i]:s+=t.data.datasets[r].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){var t=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(e,o){var s=(this.data.datasets[0].data[o],1.5*Math.PI+Math.PI*t*o);s+t*Math.PI;i.extend(e,{_index:o,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:1.5*Math.PI,endAngle:1.5*Math.PI,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,o,this.data.datasets[0].labels[o])}}),e.pivot(); +},this)},update:function(){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var t=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(e,o){var s=this.data.datasets[0].data[o],a=1.5*Math.PI+Math.PI*t*o,r=a+t*Math.PI;i.extend(e,{_index:o,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:r,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,o,this.data.datasets[0].labels[o])}}),e.pivot(),console.log(e)},this),this.render()},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:this.scale.getPointPosition(0)}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sy?C=y/u:y=C*u)}var w=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(e.minSize.width,y)},k=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(C,e.minSize.width)};i.each(r,w),i.each(n,w),i.each(h,k),i.each(l,k);var S=s,P=a;i.each(r,function(t){S+=t.width}),i.each(h,function(t){P+=t.height});var I=s,W=a,D=function(t){t.left=I,t.right=I+t.width,t.top=P,t.bottom=P+y,I=t.right},O=function(t){t.left=S,t.right=S+C,t.top=W,t.bottom=W+t.height,W=t.bottom};i.each(r,D),i.each(h,O),I+=C,W+=y,i.each(n,D),i.each(l,O),t.chartArea={left:S,top:P,right:S+C,bottom:P+y}}}},e.scales={constructors:{},registerScaleType:function(t,e){this.constructors[t]=e},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}};var o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var r=i.sign(this.min),n=i.sign(this.max);0>r&&0>n?this.max=0:r>0&&n>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?25:0):(o.height=e,o.width=this.options.gridLines.show?25:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var r=t-o.width,n=i.longestText(this.ctx,s,this.labels);r>n?o.width+=n:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-10,a="bottom"==this.options.position?this.top+10:this.bottom;i.each(this.ticks,function(r,n){var h=this.getPixelForValue(r);0===r||!o&&0===n?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var r;r="top"==this.options.position?this.top:this.top+20,this.ctx.textAlign="center",this.ctx.textBaseline="top",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,r)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var n="right"==this.options.position?this.left:this.right-10,h="right"==this.options.position?this.left+10:this.right;i.each(this.ticks,function(s,a){var r=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),r+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(n,r),this.ctx.lineTo(h,r)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,r),this.ctx.lineTo(t.right,r)),this.ctx.stroke()},this)}if(this.options.labels.show){var l,c=this.width-25;l="left"==this.options.position?this.left:this.left+20,this.ctx.textAlign="left",this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i,c)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t){var e=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=e;var o,s,a=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=a/2+3,this.labelRotation=0,this.options.display){var n,h,l=i.longestText(this.ctx,e,this.labels);this.labelWidth=l;for(var c=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>c&&0===this.labelRotation||this.labelWidth>c&&this.labelRotation<=90&&this.labelRotation>0;){if(n=Math.cos(i.toRadians(this.labelRotation)),h=Math.sin(i.toRadians(this.labelRotation)),o=n*a,s=n*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,h*l>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=n*l}}else this.labelWidth=0,this.paddingRight=this.padding,this.paddingLeft=this.padding},fit:function(t,e){this.calculateRange(),this.calculateLabelRotation();var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),a=i.longestText(this.ctx,s,this.labels);if(this.isHorizontal()){o.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*a+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else o.height=e,this.height=e,o.width=Math.min(a+6,t);return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(r,n){var h=this.getPixelForValue(r,n,!1),l=this.getPixelForValue(r,n,!0);this.options.gridLines.show&&(0===n?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var r=i.niceNum(this.max-this.min,!1),n=i.niceNum(r/(o-1),!0),h=Math.floor(this.min/n)*n,l=Math.ceil(this.max/n)*n,c=h;l>=c;c+=n)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,r,n,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),r=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,r=this.labels.length/2,n=r/2,h=n>e||e>a-n,l=e===n||e===a-n;0===e?t.textAlign="center":e===r?t.textAlign="center":r>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e].x||"number"!=typeof this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,r=this.rgbArray(),n=t.rgbArray(),h=0;he&&(e+=360),o=(n+h)/2,i=h==n?0:.5>=o?l/(h+n):l/(2-h-n),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],r=t[2],n=Math.min(s,a,r),h=Math.max(s,a,r),l=h-n;return i=0==h?0:l/h*1e3/10,h==n?e=0:s==h?e=(a-r)/l:a==h?e=2+(r-s)/l:r==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],r=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*r,100*s]}function n(t){var e,i,o,s,a=t[0]/255,r=t[1]/255,n=t[2]/255;return s=Math.min(1-a,1-r,1-n),e=(1-a-s)/(1-s)||0,i=(1-r-s)/(1-s)||0,o=(1-n-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,r=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*r]}function c(t){var e,i,o,s=l(t),a=s[0],r=s[1],n=s[2];return a/=95.047,r/=100,n/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*r-16,i=500*(a-r),o=200*(r-n),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,r=t[0]/360,n=t[1]/100,h=t[2]/100;if(0==n)return a=255*h,[a,a,a];i=.5>h?h*(1+n):h+n-h*n,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=r+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function v(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return h(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),r=255*o*(1-i),n=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,r];case 1:return[n,o,r];case 2:return[r,o,h];case 3:return[r,n,o];case 4:return[h,r,o];case 5:return[o,r,n]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function y(t){return a(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function S(t){return s(w(t))}function P(t){return n(w(t))}function I(t){return h(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,r=t[2]/100,n=t[3]/100;return e=1-Math.min(1,s*(1-n)+n),i=1-Math.min(1,a*(1-n)+n),o=1-Math.min(1,r*(1-n)+n),[255*e,255*i,255*o]}function D(t){return o(W(t))}function O(t){return s(W(t))}function R(t){return a(W(t))}function V(t){return h(W(t))}function B(t){var e,i,o,s=t[0]/100,a=t[1]/100,r=t[2]/100;return e=3.2406*s+-1.5372*a+r*-.4986,i=s*-.9689+1.8758*a+.0415*r,o=.0557*s+a*-.204+1.057*r,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function M(t){var e,i,o,s=t[0],a=t[1],r=t[2];return s/=95.047,a/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*a-16,i=500*(s-a),o=200*(a-r),[e,i,o]}function T(t){return L(M(t))}function z(t){var e,i,o,s,a=t[0],r=t[1],n=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(r/500+s-16/116)/7.787:95.047*Math.pow(r/500+s,3),o=.008859>=o/108.883?o=108.883*(s-n/200-16/116)/7.787:108.883*Math.pow(s-n/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],r=t[2];return e=Math.atan2(r,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+r*r),[s,o,i]}function F(t){return B(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],r=t[2];return o=r/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return l(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:v,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:y,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:S,hwb2cmyk:P,hwb2keyword:I,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:O,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:B,xyz2lab:M,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new l};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var r=/(\w+)2(\w+)/.exec(a),n=r[1],h=r[2];s[n]=s[n]||{},s[n][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return v(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function v(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return y[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:r,getHsl:n,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:v,hslString:m,hslaString:p,hwbString:g,keyword:f};var y={};for(var C in A)y[A[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From 09eae7ff281b3cd91139a73b9fcdcdbcdf7a5e64 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 4 Jun 2015 18:31:44 -0400 Subject: [PATCH 103/424] Fix angle calculation in determining which arcs are underneath the event point --- src/Chart.Core.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 02689a5d61b..9afe5f5bbc5 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -370,12 +370,10 @@ distanceFromYCenter = anglePoint.y - centrePoint.y, radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); - var angle = Math.PI * 2 + Math.atan2(distanceFromYCenter, distanceFromXCenter); - - //If the segment is in the top left quadrant, we need to add another rotation to the angle - if (distanceFromXCenter < 0 && distanceFromYCenter < 0) { - angle += Math.PI * 2; + if (angle < (-0.5 * Math.PI)) { + angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2] } return { @@ -1443,8 +1441,12 @@ y: chartY }); + // Put into the range of (-PI/2, 3PI/2] + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle + //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= vm.startAngle && pointRelativePosition.angle <= vm.endAngle), + var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); return (betweenAngles && withinRadius); From 205163641fd789a099290c95fc5b0c9b3b2f3725 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 4 Jun 2015 16:39:05 -0600 Subject: [PATCH 104/424] Doughnut/Pie Fixes --- src/Chart.Doughnut.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 41bc7d0cd9e..863b50d2797 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -16,6 +16,10 @@ animateScale: false, }, + hover: { + mode: 'single' + }, + //The percentage of the chart that we cut out of the middle. cutoutPercentage: 50, @@ -255,20 +259,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': From e63d5a336766c8e6acbdd4a048a3f4aaccbc5c01 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 5 Jun 2015 18:03:35 -0400 Subject: [PATCH 105/424] Only skip when the data is null, not when it is not a number --- src/Chart.Core.js | 2 +- src/Chart.Line.js | 4 ++-- src/Chart.Radar.js | 4 ++-- src/Chart.Scatter.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 9afe5f5bbc5..5920d909c2c 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1443,7 +1443,7 @@ // Put into the range of (-PI/2, 3PI/2] var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle; - var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle; //Check if within the range of the open/close angle var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), diff --git a/src/Chart.Line.js b/src/Chart.Line.js index c456bddd84d..6598d8d1309 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -181,7 +181,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -283,7 +283,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index b8f0436b5f0..5f58cce7e54 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -161,7 +161,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -241,7 +241,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 23f30e9fa02..09f2b643f47 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -191,7 +191,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -292,7 +292,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), From 65ec618a48d1514f4354d9cf09b5de8aa7517493 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 6 Jun 2015 08:12:13 -0400 Subject: [PATCH 106/424] Some improvements to the linear scale. Made the tick marks smaller (5px vs 10px) and tightened up the drawing. Removed the use of maxWidth in ctx.fillText since that is not supported in Safari --- src/Chart.Scale.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index d87f80e57ee..86885c3cfb9 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -406,7 +406,7 @@ // ----------------------------------------------------- // | | | | | // - minSize.height = this.options.gridLines.show ? 25 : 0; + minSize.height = this.options.gridLines.show ? 10 : 0; } else { minSize.height = maxHeight; // fill all the height @@ -422,7 +422,7 @@ // | // | // -| - minSize.width = this.options.gridLines.show ? 25 : 0; + minSize.width = this.options.gridLines.show ? 10 : 0; } if (this.options.labels.show) { @@ -473,8 +473,8 @@ hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; + var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; helpers.each(this.ticks, function(tick, index) { // Grid lines are vertical @@ -542,8 +542,8 @@ hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; - var xTickStart = this.options.position == "right" ? this.left : this.right - 10; - var xTickEnd = this.options.position == "right" ? this.left + 10 : this.right; + var xTickStart = this.options.position == "right" ? this.left : this.right - 5; + var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; helpers.each(this.ticks, function(tick, index) { // Grid lines are horizontal @@ -584,22 +584,22 @@ // Draw the labels var labelStartX; - var maxLabelWidth = this.width - 25; - + if (this.options.position == "left") { - labelStartX = this.left; + labelStartX = this.right - 10; + this.ctx.textAlign = "right"; } else { // right side - labelStartX = this.left + 20; + labelStartX = this.left + 5; + this.ctx.textAlign = "left" } - this.ctx.textAlign = "left"; this.ctx.textBaseline = "middle"; this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); helpers.each(this.labels, function(label, index) { var yValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, labelStartX, yValue, maxLabelWidth); + this.ctx.fillText(label, labelStartX, yValue); }, this); } } From a89ede0d72d91f483c0b1f4d119fd8019115471d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 6 Jun 2015 08:21:16 -0400 Subject: [PATCH 107/424] Bring linear axis labels closer to the tick marks when in a horizontal configuration. Reduced excess whitespace. --- src/Chart.Scale.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 86885c3cfb9..9a99e912713 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -11,8 +11,8 @@ Chart.scaleService = { // The interesting function fitScalesForChart: function(chartInstance, width, height) { - var xPadding = 10; - var yPadding = 10; + var xPadding = 5; + var yPadding = 5; if (chartInstance) { var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { @@ -518,14 +518,15 @@ var labelStartY; if (this.options.position == "top") { - labelStartY = this.top; + labelStartY = this.bottom - 10; + this.ctx.textBaseline = "bottom"; } else { // bottom side - labelStartY = this.top + 20; + labelStartY = this.top + 10; + this.ctx.textBaseline = "top"; } this.ctx.textAlign = "center"; - this.ctx.textBaseline = "top"; this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); helpers.each(this.labels, function(label, index) { @@ -584,7 +585,7 @@ // Draw the labels var labelStartX; - + if (this.options.position == "left") { labelStartX = this.right - 10; this.ctx.textAlign = "right"; From 4a3a9f1a214d2729f9ff409c68ace6224281ed73 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 6 Jun 2015 09:27:03 -0400 Subject: [PATCH 108/424] Change the scale fitting code from 2 pass fit to a 2.5 pass fit. The fit function is now passed a margin object that contains the margins on the left, top, right, and bottom of the scale. This is useful to know if you can draw outside of the width. This is used by the dataset scale so that extra padding is only added for long labels if absolutely required. If there is unused space underneath the vertical axes, that space is used first. --- src/Chart.Scale.js | 89 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 15 deletions(-) diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index 9a99e912713..d42fe9c69bb 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -176,30 +176,81 @@ return wrapper.scale === scaleInstance; }); + var scaleMargin = { + left: totalLeftWidth, + right: totalRightWidth, + top: 0, + bottom: 0, + }; + if (wrapper) { - scaleInstance.fit(maxChartWidth, wrapper.minSize.width); + scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); } }; - helpers.each(leftScales, verticalScaleFitFunction); - helpers.each(rightScales, verticalScaleFitFunction); - helpers.each(topScales, horizontalScaleFitFunction); - helpers.each(bottomScales, horizontalScaleFitFunction); - - // Step 7 var totalLeftWidth = xPadding; + var totalRightWidth = xPadding; var totalTopHeight = yPadding; + var totalBottomHeight = yPadding; + + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); - // Calculate total width of all left axes + // Figure out how much margin is on the left and right of the horizontal axes helpers.each(leftScales, function(scaleInstance) { totalLeftWidth += scaleInstance.width; }); - // Calculate total height of all top axes + helpers.each(rightScales, function(scaleInstance) { + totalRightWidth += scaleInstance.width; + }); + + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); + helpers.each(topScales, function(scaleInstance) { totalTopHeight += scaleInstance.height; }); + helpers.each(bottomScales, function(scaleInstance) { + totalBottomHeight += scaleInstance.height; + }); + + // Let the left scale know the final margin + helpers.each(leftScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + + helpers.each(rightScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + + // Step 7 // Position the scales var left = xPadding; var top = yPadding; @@ -592,7 +643,7 @@ } else { // right side labelStartX = this.left + 5; - this.ctx.textAlign = "left" + this.ctx.textAlign = "left"; } this.ctx.textBaseline = "middle"; @@ -633,7 +684,7 @@ return this.top + (index * (this.height / this.max)); } }, - calculateLabelRotation: function(maxHeight) { + calculateLabelRotation: function(maxHeight, margins) { //Get the width of each grid by calculating the difference //between x offsets between 0 and 1. var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); @@ -688,8 +739,16 @@ } } else { this.labelWidth = 0; - this.paddingRight = this.padding; - this.paddingLeft = this.padding; + this.paddingRight = 0; + this.paddingLeft = 0; + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); } }, @@ -697,9 +756,9 @@ // @param {number} maxWidth : the max width the axis can be // @param {number} maxHeight: the max height the axis can be // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { + fit: function(maxWidth, maxHeight, margins) { this.calculateRange(); - this.calculateLabelRotation(); + this.calculateLabelRotation(maxHeight, margins); var minSize = { width: 0, From d05d29aa66fb394361f4becfbecd01912904ee3a Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 6 Jun 2015 11:06:40 -0400 Subject: [PATCH 109/424] Make the angle calculations more robust. Also ensure that angles in polar area charts are calculated similarly to angles in doughnut / pie charts --- src/Chart.Core.js | 4 ++-- src/Chart.PolarArea.js | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 9afe5f5bbc5..861188c0c78 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1442,8 +1442,8 @@ }); // Put into the range of (-PI/2, 3PI/2] - var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle; - var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI): vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle //Check if within the range of the open/close angle var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index f0ceff750cc..b7e52682fd6 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -148,9 +148,6 @@ var value = this.data.datasets[0].data[index]; - var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); - helpers.extend(slice, { _index: index, _model: { @@ -158,8 +155,8 @@ y: this.chart.height / 2, innerRadius: 0, outerRadius: 0, - startAngle: Math.PI * 1.5, - endAngle: Math.PI * 1.5, + startAngle: Math.PI * -0.5, + endAngle: Math.PI * -0.5, backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), @@ -189,7 +186,7 @@ var value = this.data.datasets[0].data[index]; - var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; var endAngle = startAngle + (circumference * Math.PI); helpers.extend(slice, { From 679fa4e72e0927a712c328a64e20d0021e6d8197 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 8 Jun 2015 13:12:20 -0600 Subject: [PATCH 110/424] Clone in configMerge --- src/Chart.Core.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 861188c0c78..0da147fd476 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -189,7 +189,8 @@ return extend.apply(null, args); }, // Need a special merge function to chart configs since they are now grouped - configMerge = helpers.configMerge = function(base) { + configMerge = helpers.configMerge = function(_base) { + var base = clone(_base); helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { helpers.each(extension, function(value, key) { if (extension.hasOwnProperty(key)) { @@ -1442,7 +1443,7 @@ }); // Put into the range of (-PI/2, 3PI/2] - var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI): vm.startAngle; + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle //Check if within the range of the open/close angle From 24d32e9321f7f52581c3982de25ffaea4bed6477 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 8 Jun 2015 13:14:05 -0600 Subject: [PATCH 111/424] Gulp build --- Chart.js | 178 ++++++++++++++++++++++++++++++++++----------------- Chart.min.js | 10 +-- 2 files changed, 126 insertions(+), 62 deletions(-) diff --git a/Chart.js b/Chart.js index 2d1fde13a51..db5f2416e15 100644 --- a/Chart.js +++ b/Chart.js @@ -189,7 +189,8 @@ return extend.apply(null, args); }, // Need a special merge function to chart configs since they are now grouped - configMerge = helpers.configMerge = function(base) { + configMerge = helpers.configMerge = function(_base) { + var base = clone(_base); helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { helpers.each(extension, function(value, key) { if (extension.hasOwnProperty(key)) { @@ -370,12 +371,10 @@ distanceFromYCenter = anglePoint.y - centrePoint.y, radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); - var angle = Math.PI * 2 + Math.atan2(distanceFromYCenter, distanceFromXCenter); - - //If the segment is in the top left quadrant, we need to add another rotation to the angle - if (distanceFromXCenter < 0 && distanceFromYCenter < 0) { - angle += Math.PI * 2; + if (angle < (-0.5 * Math.PI)) { + angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2] } return { @@ -1443,8 +1442,12 @@ y: chartY }); + // Put into the range of (-PI/2, 3PI/2] + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle + //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= vm.startAngle && pointRelativePosition.angle <= vm.endAngle), + var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); return (betweenAngles && withinRadius); @@ -2564,6 +2567,10 @@ animateScale: false, }, + hover: { + mode: 'single' + }, + //The percentage of the chart that we cut out of the middle. cutoutPercentage: 50, @@ -2803,20 +2810,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': @@ -3093,7 +3100,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -3195,7 +3202,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -3681,9 +3688,6 @@ var value = this.data.datasets[0].data[index]; - var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); - helpers.extend(slice, { _index: index, _model: { @@ -3691,8 +3695,8 @@ y: this.chart.height / 2, innerRadius: 0, outerRadius: 0, - startAngle: Math.PI * 1.5, - endAngle: Math.PI * 1.5, + startAngle: Math.PI * -0.5, + endAngle: Math.PI * -0.5, backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), @@ -3722,7 +3726,7 @@ var value = this.data.datasets[0].data[index]; - var startAngle = Math.PI * 1.5 + (Math.PI * circumference) * index; + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; var endAngle = startAngle + (circumference * Math.PI); helpers.extend(slice, { @@ -4098,7 +4102,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -4178,7 +4182,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: typeof this.data.datasets[datasetIndex].data[index] != 'number', + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -4455,8 +4459,8 @@ Chart.scaleService = { // The interesting function fitScalesForChart: function(chartInstance, width, height) { - var xPadding = 10; - var yPadding = 10; + var xPadding = 5; + var yPadding = 5; if (chartInstance) { var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { @@ -4620,30 +4624,81 @@ return wrapper.scale === scaleInstance; }); + var scaleMargin = { + left: totalLeftWidth, + right: totalRightWidth, + top: 0, + bottom: 0, + }; + if (wrapper) { - scaleInstance.fit(maxChartWidth, wrapper.minSize.width); + scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); } }; - helpers.each(leftScales, verticalScaleFitFunction); - helpers.each(rightScales, verticalScaleFitFunction); - helpers.each(topScales, horizontalScaleFitFunction); - helpers.each(bottomScales, horizontalScaleFitFunction); - - // Step 7 var totalLeftWidth = xPadding; + var totalRightWidth = xPadding; var totalTopHeight = yPadding; + var totalBottomHeight = yPadding; - // Calculate total width of all left axes + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); + + // Figure out how much margin is on the left and right of the horizontal axes helpers.each(leftScales, function(scaleInstance) { totalLeftWidth += scaleInstance.width; }); - // Calculate total height of all top axes + helpers.each(rightScales, function(scaleInstance) { + totalRightWidth += scaleInstance.width; + }); + + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); + helpers.each(topScales, function(scaleInstance) { totalTopHeight += scaleInstance.height; }); + helpers.each(bottomScales, function(scaleInstance) { + totalBottomHeight += scaleInstance.height; + }); + + // Let the left scale know the final margin + helpers.each(leftScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + helpers.each(rightScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + + // Step 7 // Position the scales var left = xPadding; var top = yPadding; @@ -4850,7 +4905,7 @@ // ----------------------------------------------------- // | | | | | // - minSize.height = this.options.gridLines.show ? 25 : 0; + minSize.height = this.options.gridLines.show ? 10 : 0; } else { minSize.height = maxHeight; // fill all the height @@ -4866,7 +4921,7 @@ // | // | // -| - minSize.width = this.options.gridLines.show ? 25 : 0; + minSize.width = this.options.gridLines.show ? 10 : 0; } if (this.options.labels.show) { @@ -4917,8 +4972,8 @@ hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; + var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; helpers.each(this.ticks, function(tick, index) { // Grid lines are vertical @@ -4962,14 +5017,15 @@ var labelStartY; if (this.options.position == "top") { - labelStartY = this.top; + labelStartY = this.bottom - 10; + this.ctx.textBaseline = "bottom"; } else { // bottom side - labelStartY = this.top + 20; + labelStartY = this.top + 10; + this.ctx.textBaseline = "top"; } this.ctx.textAlign = "center"; - this.ctx.textBaseline = "top"; this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); helpers.each(this.labels, function(label, index) { @@ -4986,8 +5042,8 @@ hasZero = helpers.findNextWhere(this.ticks, function(tick) { return tick === 0; }) !== undefined; - var xTickStart = this.options.position == "right" ? this.left : this.right - 10; - var xTickEnd = this.options.position == "right" ? this.left + 10 : this.right; + var xTickStart = this.options.position == "right" ? this.left : this.right - 5; + var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; helpers.each(this.ticks, function(tick, index) { // Grid lines are horizontal @@ -5028,22 +5084,22 @@ // Draw the labels var labelStartX; - var maxLabelWidth = this.width - 25; if (this.options.position == "left") { - labelStartX = this.left; + labelStartX = this.right - 10; + this.ctx.textAlign = "right"; } else { // right side - labelStartX = this.left + 20; + labelStartX = this.left + 5; + this.ctx.textAlign = "left"; } - this.ctx.textAlign = "left"; this.ctx.textBaseline = "middle"; this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); helpers.each(this.labels, function(label, index) { var yValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, labelStartX, yValue, maxLabelWidth); + this.ctx.fillText(label, labelStartX, yValue); }, this); } } @@ -5076,7 +5132,7 @@ return this.top + (index * (this.height / this.max)); } }, - calculateLabelRotation: function(maxHeight) { + calculateLabelRotation: function(maxHeight, margins) { //Get the width of each grid by calculating the difference //between x offsets between 0 and 1. var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); @@ -5131,8 +5187,16 @@ } } else { this.labelWidth = 0; - this.paddingRight = this.padding; - this.paddingLeft = this.padding; + this.paddingRight = 0; + this.paddingLeft = 0; + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); } }, @@ -5140,9 +5204,9 @@ // @param {number} maxWidth : the max width the axis can be // @param {number} maxHeight: the max height the axis can be // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { + fit: function(maxWidth, maxHeight, margins) { this.calculateRange(); - this.calculateLabelRotation(); + this.calculateLabelRotation(maxHeight, margins); var minSize = { width: 0, @@ -5791,7 +5855,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), @@ -5892,7 +5956,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (typeof this.data.datasets[datasetIndex].data[index].x != 'number') || (typeof this.data.datasets[datasetIndex].data[index].y != 'number'), + skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), // Tooltip hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), diff --git a/Chart.min.js b/Chart.min.js index f9d5c4179d2..05abe32cc03 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,8 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:6,hoverRadius:4,hoverBorderWidth:2},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&n(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},p=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=2*Math.PI+Math.atan2(o,i);return 0>i&&0>o&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),r=o*s/(s+a),n=o*a/(s+a);return{previous:{x:e.x-r*(i.x-t.x),y:e.y-r*(i.y-t.y)},next:{x:e.x+n*(i.x-t.x),y:e.y+n*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,r=Math.floor(e/(1.5*i)),n=a>=r,h=p(t),l=g(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>r||r>2*x)&&!n;)if(x>r)b*=2,x=Math.round(m/b),x%1!==0&&(n=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return n&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(Math.log10(t)),s=t/Math.pow(10,o);return i=e?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),y=(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,e,i,o,s,a){var r=0,n=x[i]||x.linear,h=function(){r++;var i=r/e,l=n(i);t.call(a,l,i,r),o.call(a,l,i),e>r?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),C=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},y(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){C(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(S(e,"padding-left"))+parseInt(S(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(S(e,"padding-bottom"))+parseInt(S(e,"padding-top"));return e.clientHeight-i},S=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},P=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),I=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},O=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},n(i.Type.prototype,{initialize:function(){return this},clear:function(){return I(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,P(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},r=0;r0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)=i.startAngle&&o.angle<=i.endAngle,r=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return a&&r},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),r=e.borderWidth/2;e.borderWidth&&(o+=r,s-=r,a+=r),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[n].metaData,o=h(i,this._active[0]),-1===o);n--);var l=function(t){var e,i,n,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),r.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=g(u),n=p(u),h=g(d),i=p(d),{x:h>this._chart.width/2?h:i,y:(l+n)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:r,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=p([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,r=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-r<0&&(e.yAlign="below");var n=e.x-o/2,h=e.y-r;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":n=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":n=e.x-(e.cornerRadius+e.caretHeight)}O(t,n,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,n+o/2,h+a/2)}break;case"label":O(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,r=a/this.frameDuration;r>1&&(this.dropFrames+=r),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.calculateBarX(this.data.datasets.length,s,e),y:a,base:n.calculateBarBase(s,e),width:r.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:r,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:r.calculateBarY(s,e),base:r.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render()},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),r=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing; -return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,r=this.calculateBarWidth(t);return o.options.stacked?a+r/2:a+r*e+e*o.options.elements.bar.datasetSpacing+r/2}});this.scales[r.id]=r,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var r=0;t>r;r++)o.data.datasets[r].yAxisID===this.id&&(i+=o.data.datasets[r].data[e]>0?o.data.datasets[r].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,r=0;t>r;r++)o.data.datasets[r].data[e]<0?a+=o.data.datasets[r].data[e]||0:s+=o.data.datasets[r].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var n=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,r=0;o>r;++r)t.data.datasets[r].data[i]<0?a+=t.data.datasets[r].data[i]:s+=t.data.datasets[r].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){var t=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(e,o){var s=(this.data.datasets[0].data[o],1.5*Math.PI+Math.PI*t*o);s+t*Math.PI;i.extend(e,{_index:o,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:1.5*Math.PI,endAngle:1.5*Math.PI,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,o,this.data.datasets[0].labels[o])}}),e.pivot(); -},this)},update:function(){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var t=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(e,o){var s=this.data.datasets[0].data[o],a=1.5*Math.PI+Math.PI*t*o,r=a+t*Math.PI;i.extend(e,{_index:o,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:r,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,o,this.data.datasets[0].labels[o])}}),e.pivot(),console.log(e)},this),this.render()},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:this.scale.getPointPosition(0)}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sy?C=y/u:y=C*u)}var w=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(e.minSize.width,y)},k=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(C,e.minSize.width)};i.each(r,w),i.each(n,w),i.each(h,k),i.each(l,k);var S=s,P=a;i.each(r,function(t){S+=t.width}),i.each(h,function(t){P+=t.height});var I=s,W=a,D=function(t){t.left=I,t.right=I+t.width,t.top=P,t.bottom=P+y,I=t.right},O=function(t){t.left=S,t.right=S+C,t.top=W,t.bottom=W+t.height,W=t.bottom};i.each(r,D),i.each(h,O),I+=C,W+=y,i.each(n,D),i.each(l,O),t.chartArea={left:S,top:P,right:S+C,bottom:P+y}}}},e.scales={constructors:{},registerScaleType:function(t,e){this.constructors[t]=e},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}};var o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var r=i.sign(this.min),n=i.sign(this.max);0>r&&0>n?this.max=0:r>0&&n>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?25:0):(o.height=e,o.width=this.options.gridLines.show?25:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var r=t-o.width,n=i.longestText(this.ctx,s,this.labels);r>n?o.width+=n:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-10,a="bottom"==this.options.position?this.top+10:this.bottom;i.each(this.ticks,function(r,n){var h=this.getPixelForValue(r);0===r||!o&&0===n?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var r;r="top"==this.options.position?this.top:this.top+20,this.ctx.textAlign="center",this.ctx.textBaseline="top",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,r)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var n="right"==this.options.position?this.left:this.right-10,h="right"==this.options.position?this.left+10:this.right;i.each(this.ticks,function(s,a){var r=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),r+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(n,r),this.ctx.lineTo(h,r)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,r),this.ctx.lineTo(t.right,r)),this.ctx.stroke()},this)}if(this.options.labels.show){var l,c=this.width-25;l="left"==this.options.position?this.left:this.left+20,this.ctx.textAlign="left",this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i,c)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t){var e=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=e;var o,s,a=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=a/2+3,this.labelRotation=0,this.options.display){var n,h,l=i.longestText(this.ctx,e,this.labels);this.labelWidth=l;for(var c=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>c&&0===this.labelRotation||this.labelWidth>c&&this.labelRotation<=90&&this.labelRotation>0;){if(n=Math.cos(i.toRadians(this.labelRotation)),h=Math.sin(i.toRadians(this.labelRotation)),o=n*a,s=n*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,h*l>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=n*l}}else this.labelWidth=0,this.paddingRight=this.padding,this.paddingLeft=this.padding},fit:function(t,e){this.calculateRange(),this.calculateLabelRotation();var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),a=i.longestText(this.ctx,s,this.labels);if(this.isHorizontal()){o.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*a+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else o.height=e,this.height=e,o.width=Math.min(a+6,t);return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(r,n){var h=this.getPixelForValue(r,n,!1),l=this.getPixelForValue(r,n,!0);this.options.gridLines.show&&(0===n?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var r=i.niceNum(this.max-this.min,!1),n=i.niceNum(r/(o-1),!0),h=Math.floor(this.min/n)*n,l=Math.ceil(this.max/n)*n,c=h;l>=c;c+=n)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,r,n,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),r=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,r=this.labels.length/2,n=r/2,h=n>e||e>a-n,l=e===n||e===a-n;0===e?t.textAlign="center":e===r?t.textAlign="center":r>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:"number"!=typeof this.data.datasets[s].data[e].x||"number"!=typeof this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,r=this.rgbArray(),n=t.rgbArray(),h=0;he&&(e+=360),o=(n+h)/2,i=h==n?0:.5>=o?l/(h+n):l/(2-h-n),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],r=t[2],n=Math.min(s,a,r),h=Math.max(s,a,r),l=h-n;return i=0==h?0:l/h*1e3/10,h==n?e=0:s==h?e=(a-r)/l:a==h?e=2+(r-s)/l:r==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],r=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*r,100*s]}function n(t){var e,i,o,s,a=t[0]/255,r=t[1]/255,n=t[2]/255;return s=Math.min(1-a,1-r,1-n),e=(1-a-s)/(1-s)||0,i=(1-r-s)/(1-s)||0,o=(1-n-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,r=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*r]}function c(t){var e,i,o,s=l(t),a=s[0],r=s[1],n=s[2];return a/=95.047,r/=100,n/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*r-16,i=500*(a-r),o=200*(r-n),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,r=t[0]/360,n=t[1]/100,h=t[2]/100;if(0==n)return a=255*h,[a,a,a];i=.5>h?h*(1+n):h+n-h*n,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=r+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function v(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return h(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),r=255*o*(1-i),n=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,r];case 1:return[n,o,r];case 2:return[r,o,h];case 3:return[r,n,o];case 4:return[h,r,o];case 5:return[o,r,n]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function y(t){return a(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function S(t){return s(w(t))}function P(t){return n(w(t))}function I(t){return h(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,r=t[2]/100,n=t[3]/100;return e=1-Math.min(1,s*(1-n)+n),i=1-Math.min(1,a*(1-n)+n),o=1-Math.min(1,r*(1-n)+n),[255*e,255*i,255*o]}function D(t){return o(W(t))}function O(t){return s(W(t))}function R(t){return a(W(t))}function V(t){return h(W(t))}function B(t){var e,i,o,s=t[0]/100,a=t[1]/100,r=t[2]/100;return e=3.2406*s+-1.5372*a+r*-.4986,i=s*-.9689+1.8758*a+.0415*r,o=.0557*s+a*-.204+1.057*r,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function M(t){var e,i,o,s=t[0],a=t[1],r=t[2];return s/=95.047,a/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*a-16,i=500*(s-a),o=200*(a-r),[e,i,o]}function T(t){return L(M(t))}function z(t){var e,i,o,s,a=t[0],r=t[1],n=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(r/500+s-16/116)/7.787:95.047*Math.pow(r/500+s,3),o=.008859>=o/108.883?o=108.883*(s-n/200-16/116)/7.787:108.883*Math.pow(s-n/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],r=t[2];return e=Math.atan2(r,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+r*r),[s,o,i]}function F(t){return B(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],r=t[2];return o=r/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return l(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:v,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:y,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:S,hwb2cmyk:P,hwb2keyword:I,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:O,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:B,xyz2lab:M,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new l};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var r=/(\w+)2(\w+)/.exec(a),n=r[1],h=r[2];s[n]=s[n]||{},s[n][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return v(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function v(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return y[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:r,getHsl:n,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:v,hslString:m,hslaString:p,hwbString:g,keyword:f};var y={};for(var C in A)y[A[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:6,hoverRadius:4,hoverBorderWidth:2},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},p=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,h=p(t),l=g(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(Math.log10(t)),s=t/Math.pow(10,o);return i=e?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,h=function(){n++;var i=n/e,l=r(i);t.call(a,l,i,n),o.call(a,l,i),e>n?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},I=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),S=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},R=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return S(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,I(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,h=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=h(i,this._active[0]),-1===o);r--);var l=function(t){var e,i,r,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=g(u),r=p(u),h=g(d),i=p(d),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=p([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}R(t,r,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+a/2)}break;case"label":R(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render()},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing; +},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(){this.updateScaleRange(),this.scale.calculateRange(), +this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var t=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(e,o){var s=this.data.datasets[0].data[o],a=-.5*Math.PI+Math.PI*t*o,n=a+t*Math.PI;i.extend(e,{_index:o,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,o,this.data.datasets[0].labels[o])}}),e.pivot(),console.log(e)},this),this.render()},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:this.scale.getPointPosition(0)}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sC?y=C/u:C=y*u)}var w=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(e.minSize.width,C)},k=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:P,right:I,top:0,bottom:0};e&&t.fit(y,e.minSize.height,o)},P=s,I=s,S=a,W=a;i.each(n,w),i.each(r,w),i.each(n,function(t){P+=t.width}),i.each(r,function(t){I+=t.width}),i.each(h,k),i.each(l,k),i.each(h,function(t){S+=t.height}),i.each(l,function(t){W+=t.height}),i.each(n,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)}),i.each(r,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)});var D=s,R=a,O=function(t){t.left=D,t.right=D+t.width,t.top=S,t.bottom=S+C,D=t.right},V=function(t){t.left=P,t.right=P+y,t.top=R,t.bottom=R+t.height,R=t.bottom};i.each(n,O),i.each(h,V),D+=y,R+=C,i.each(r,O),i.each(l,V),t.chartArea={left:P,top:S,right:P+y,bottom:S+C}}}},e.scales={constructors:{},registerScaleType:function(t,e){this.constructors[t]=e},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}};var o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,a=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,!1),l=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),o=(r+h)/2,i=h==r?0:.5>=o?l/(h+r):l/(2-h-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),h=Math.max(s,a,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(a-n)/l:a==h?e=2+(n-s)/l:n==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=l(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=n+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function v(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return h(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,n];case 1:return[r,o,n];case 2:return[n,o,h];case 3:return[n,r,o];case 4:return[h,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return h(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function I(t){return n(w(t))}function S(t){return h(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function R(t){return s(W(t))}function O(t){return a(W(t))}function V(t){return h(W(t))}function M(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function B(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(B(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return M(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return l(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:v,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:I,hwb2keyword:S,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:R,cmyk2hwb:O,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:M,xyz2lab:B,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new l};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments)); +var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return v(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function v(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:v,hslString:m,hslaString:p,hwbString:g,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From 8f5d702a866518f20fcdeba9107ce5d4fae84c5a Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 8 Jun 2015 15:57:47 -0600 Subject: [PATCH 112/424] chart.update(animationDuration) support --- Chart.js | 26 +++++++++++++------------- Chart.min.js | 6 +++--- src/Chart.Bar.js | 6 +++--- src/Chart.Core.js | 2 +- src/Chart.Doughnut.js | 4 ++-- src/Chart.Line.js | 6 +++--- src/Chart.PolarArea.js | 4 ++-- src/Chart.Radar.js | 4 ++-- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Chart.js b/Chart.js index db5f2416e15..d52cfbc57b6 100644 --- a/Chart.js +++ b/Chart.js @@ -989,7 +989,7 @@ redraw: noop, render: function(duration) { - if (this.options.animation.duration !== 0) { + if (this.options.animation.duration !== 0 || duration) { var animation = new Chart.Animation(); animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps animation.easing = this.options.animation.easing; @@ -2123,7 +2123,7 @@ var yScalePoint; - if (yScale.min < 0 && yScale.max <0) { + if (yScale.min < 0 && yScale.max < 0) { // all less than 0. use the top yScalePoint = yScale.getPixelForValue(yScale.max); } else if (yScale.min > 0 && yScale.max > 0) { @@ -2160,7 +2160,7 @@ bar.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { // Update the scale sizes Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); @@ -2198,7 +2198,7 @@ }, this); - this.render(); + this.render(animationDuration); }, buildScale: function(labels) { var self = this; @@ -2663,7 +2663,7 @@ }, this); }, - update: function() { + update: function(animationDuration) { this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; @@ -2727,7 +2727,7 @@ }, this); - this.render(); + this.render(animationDuration); }, draw: function(easeDecimal) { easeDecimal = easeDecimal || 1; @@ -3072,7 +3072,7 @@ var yScalePoint; - if (yScale.min < 0 && yScale.max <0) { + if (yScale.min < 0 && yScale.max < 0) { // all less than 0. use the top yScalePoint = yScale.getPixelForValue(yScale.max); } else if (yScale.min > 0 && yScale.max > 0) { @@ -3144,7 +3144,7 @@ point.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); @@ -3247,7 +3247,7 @@ point.pivot(); }, this); - this.render(); + this.render(animationDuration); }, buildScale: function() { var self = this; @@ -3710,7 +3710,7 @@ slice.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { this.updateScaleRange(); this.scale.calculateRange(); @@ -3753,7 +3753,7 @@ }, this); - this.render(); + this.render(animationDuration); }, draw: function(ease) { var easingDecimal = ease || 1; @@ -4128,7 +4128,7 @@ point.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines @@ -4227,7 +4227,7 @@ point.pivot(); }, this); - this.render(); + this.render(animationDuration); }, buildScale: function() { var self = this; diff --git a/Chart.min.js b/Chart.min.js index 05abe32cc03..1783a879a49 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,8 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:6,hoverRadius:4,hoverBorderWidth:2},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},p=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,h=p(t),l=g(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(Math.log10(t)),s=t/Math.pow(10,o);return i=e?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,h=function(){n++;var i=n/e,l=r(i);t.call(a,l,i,n),o.call(a,l,i),e>n?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},I=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),S=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},R=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return S(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,I(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,h=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=h(i,this._active[0]),-1===o);r--);var l=function(t){var e,i,r,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=g(u),r=p(u),h=g(d),i=p(d),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=p([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}R(t,r,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+a/2)}break;case"label":R(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render()},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing; -},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(){this.updateScaleRange(),this.scale.calculateRange(), -this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var t=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(e,o){var s=this.data.datasets[0].data[o],a=-.5*Math.PI+Math.PI*t*o,n=a+t*Math.PI;i.extend(e,{_index:o,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,o,this.data.datasets[0].labels[o])}}),e.pivot(),console.log(e)},this),this.render()},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:this.scale.getPointPosition(0)}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sC?y=C/u:C=y*u)}var w=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(e.minSize.width,C)},k=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:P,right:I,top:0,bottom:0};e&&t.fit(y,e.minSize.height,o)},P=s,I=s,S=a,W=a;i.each(n,w),i.each(r,w),i.each(n,function(t){P+=t.width}),i.each(r,function(t){I+=t.width}),i.each(h,k),i.each(l,k),i.each(h,function(t){S+=t.height}),i.each(l,function(t){W+=t.height}),i.each(n,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)}),i.each(r,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)});var D=s,R=a,O=function(t){t.left=D,t.right=D+t.width,t.top=S,t.bottom=S+C,D=t.right},V=function(t){t.left=P,t.right=P+y,t.top=R,t.bottom=R+t.height,R=t.bottom};i.each(n,O),i.each(h,V),D+=y,R+=C,i.each(r,O),i.each(l,V),t.chartArea={left:P,top:S,right:P+y,bottom:S+C}}}},e.scales={constructors:{},registerScaleType:function(t,e){this.constructors[t]=e},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}};var o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,a=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,!1),l=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:6,hoverRadius:4,hoverBorderWidth:2},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},p=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,h=p(t),l=g(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(Math.log10(t)),s=t/Math.pow(10,o);return i=e?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,h=function(){n++;var i=n/e,l=r(i);t.call(a,l,i,n),o.call(a,l,i),e>n?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},I=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),S=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},R=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return S(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,I(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,h=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=h(i,this._active[0]),-1===o);r--);var l=function(t){var e,i,r,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=g(u),r=p(u),h=g(d),i=p(d),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=p([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}R(t,r,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+a/2)}break;case"label":R(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing; +},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(), +this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,n=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:this.scale.getPointPosition(0)}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sC?y=C/u:C=y*u)}var w=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(e.minSize.width,C)},k=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:P,right:I,top:0,bottom:0};e&&t.fit(y,e.minSize.height,o)},P=s,I=s,S=a,W=a;i.each(n,w),i.each(r,w),i.each(n,function(t){P+=t.width}),i.each(r,function(t){I+=t.width}),i.each(h,k),i.each(l,k),i.each(h,function(t){S+=t.height}),i.each(l,function(t){W+=t.height}),i.each(n,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)}),i.each(r,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)});var D=s,R=a,O=function(t){t.left=D,t.right=D+t.width,t.top=S,t.bottom=S+C,D=t.right},V=function(t){t.left=P,t.right=P+y,t.top=R,t.bottom=R+t.height,R=t.bottom};i.each(n,O),i.each(h,V),D+=y,R+=C,i.each(r,O),i.each(l,V),t.chartArea={left:P,top:S,right:P+y,bottom:S+C}}}},e.scales={constructors:{},registerScaleType:function(t,e){this.constructors[t]=e},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}};var o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,a=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,!1),l=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),o=(r+h)/2,i=h==r?0:.5>=o?l/(h+r):l/(2-h-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),h=Math.max(s,a,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(a-n)/l:a==h?e=2+(n-s)/l:n==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=l(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=n+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function v(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return h(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,n];case 1:return[r,o,n];case 2:return[n,o,h];case 3:return[n,r,o];case 4:return[h,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return h(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function I(t){return n(w(t))}function S(t){return h(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function R(t){return s(W(t))}function O(t){return a(W(t))}function V(t){return h(W(t))}function M(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function B(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(B(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return M(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return l(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:v,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:I,hwb2keyword:S,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:R,cmyk2hwb:O,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:M,xyz2lab:B,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new l};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments)); var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return v(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function v(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:v,hslString:m,hslaString:p,hwbString:g,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index e1234cabd66..33d27410c99 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -134,7 +134,7 @@ var yScalePoint; - if (yScale.min < 0 && yScale.max <0) { + if (yScale.min < 0 && yScale.max < 0) { // all less than 0. use the top yScalePoint = yScale.getPixelForValue(yScale.max); } else if (yScale.min > 0 && yScale.max > 0) { @@ -171,7 +171,7 @@ bar.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { // Update the scale sizes Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); @@ -209,7 +209,7 @@ }, this); - this.render(); + this.render(animationDuration); }, buildScale: function(labels) { var self = this; diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 0da147fd476..8034efabff0 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -989,7 +989,7 @@ redraw: noop, render: function(duration) { - if (this.options.animation.duration !== 0) { + if (this.options.animation.duration !== 0 || duration) { var animation = new Chart.Animation(); animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps animation.easing = this.options.animation.easing; diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 863b50d2797..6249069b3de 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -112,7 +112,7 @@ }, this); }, - update: function() { + update: function(animationDuration) { this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; @@ -176,7 +176,7 @@ }, this); - this.render(); + this.render(animationDuration); }, draw: function(easeDecimal) { easeDecimal = easeDecimal || 1; diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 6598d8d1309..a5386300d01 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -153,7 +153,7 @@ var yScalePoint; - if (yScale.min < 0 && yScale.max <0) { + if (yScale.min < 0 && yScale.max < 0) { // all less than 0. use the top yScalePoint = yScale.getPixelForValue(yScale.max); } else if (yScale.min > 0 && yScale.max > 0) { @@ -225,7 +225,7 @@ point.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); @@ -328,7 +328,7 @@ point.pivot(); }, this); - this.render(); + this.render(animationDuration); }, buildScale: function() { var self = this; diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index b7e52682fd6..969c44dc28c 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -170,7 +170,7 @@ slice.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { this.updateScaleRange(); this.scale.calculateRange(); @@ -213,7 +213,7 @@ }, this); - this.render(); + this.render(animationDuration); }, draw: function(ease) { var easingDecimal = ease || 1; diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index 5f58cce7e54..924eb996fee 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -187,7 +187,7 @@ point.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines @@ -286,7 +286,7 @@ point.pivot(); }, this); - this.render(); + this.render(animationDuration); }, buildScale: function() { var self = this; From 2bddccaaf08af2807803fc751b155fe745d6ea6f Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 8 Jun 2015 19:03:47 -0400 Subject: [PATCH 113/424] Use the correct base for linear scales. This gives the correct fill for lines and animations start at the correct point --- src/Chart.Line.js | 11 ++++++++++- src/Chart.Radar.js | 12 +++++++++++- src/Chart.Scatter.js | 11 ++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 6598d8d1309..c715855ed46 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -232,6 +232,15 @@ // Update the lines this.eachDataset(function(dataset, datasetIndex) { var yScale = this.scales[dataset.yAxisID]; + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } helpers.extend(dataset.metaDataset, { // Utility @@ -252,7 +261,7 @@ // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom, - scaleZero: yScale.getPixelForValue(0), + scaleZero: scaleBase, }, }); diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index 5f58cce7e54..cb2d819914d 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -192,6 +192,16 @@ // Update the lines this.eachDataset(function(dataset, datasetIndex) { + var scaleBase; + + if (this.scale.min < 0 && this.scale.max < 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.max); + } else if (this.scale.min > 0 && this.scale.max > 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.min); + } else { + scaleBase = this.scale.getPointPosition(0, 0); + } + helpers.extend(dataset.metaDataset, { // Utility _datasetIndex: datasetIndex, @@ -213,7 +223,7 @@ // Scale scaleTop: this.scale.top, scaleBottom: this.scale.bottom, - scaleZero: this.scale.getPointPosition(0), + scaleZero: scaleBase, }, }); diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index 09f2b643f47..c32b876a49b 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -241,6 +241,15 @@ // Update the lines this.eachDataset(function(dataset, datasetIndex) { var yScale = this.scales[dataset.yAxisID]; + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } helpers.extend(dataset.metaDataset, { // Utility @@ -261,7 +270,7 @@ // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom, - scaleZero: yScale.getPixelForValue(0), + scaleZero: scaleBase, }, }); From 29743e1d63353008d53276cce6db962c636d6c39 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 9 Jun 2015 18:24:43 -0400 Subject: [PATCH 114/424] Use a polyfill when Math.log10 does not exist --- src/Chart.Core.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8034efabff0..8fd4dfc0a04 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -329,6 +329,13 @@ return x > 0 ? 1 : -1; } }, + log10 = helpers.log10 = function(x) { + if (Math.log10) { + return Math.log10(x) + } else { + return Math.log(x) / Math.LN10; + } + }, cap = helpers.cap = function(valueToCap, maxValue, minValue) { if (isNumber(maxValue)) { if (valueToCap > maxValue) { @@ -484,7 +491,7 @@ }, // Implementation of the nice number algorithm used in determining where axis labels will go niceNum = helpers.niceNum = function(range, round) { - var exponent = Math.floor(Math.log10(range)); + var exponent = Math.floor(helpers.log10(range)); var fraction = range / Math.pow(10, exponent); var niceFraction; From 97a2232fbfe9ced143167f59f8cf7ae679270a30 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 9 Jun 2015 18:43:33 -0400 Subject: [PATCH 115/424] Forgot that `typeof null === 'object'` Added a check for this condition so that merge works correctly --- src/Chart.Core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8034efabff0..fac8424b887 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -206,7 +206,7 @@ baseArray.push(valueObj); // nothing to merge } }); - } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && typeof value == "object") { + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { // If we are overwriting an object with an object, do a merge of the properties. base[key] = helpers.configMerge(base[key], value); } else { From 55cf07926c78ddd0ddd9f310775992feb21ad065 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 10 Jun 2015 20:08:12 -0400 Subject: [PATCH 116/424] By default use toLocaleString() when generating labels for the axes. This prevents misformatted numbers due to doubles. It also makes large numbers nicer with commas by default. --- src/Chart.Line.js | 2 +- src/Chart.PolarArea.js | 2 +- src/Chart.Radar.js | 2 +- src/Chart.Scatter.js | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 12e4259e3b3..e7310d152bb 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -66,7 +66,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index 969c44dc28c..cd48a86077a 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -30,7 +30,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index 53a3d22eda2..e329dd7acb1 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -39,7 +39,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index c32b876a49b..032d057adb2 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -36,7 +36,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", @@ -68,7 +68,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", From 11773a5825c8f449c9d0399f1e306826ca9f71d9 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 11 Jun 2015 01:05:44 -0600 Subject: [PATCH 117/424] Hover states, Scale padding, and mouse out fixes --- src/Chart.Bar.js | 8 +++--- src/Chart.Core.js | 15 ++++++----- src/Chart.Doughnut.js | 40 +++++++++++++-------------- src/Chart.Line.js | 61 +++++++++++++++++++++--------------------- src/Chart.PolarArea.js | 16 +++++------ src/Chart.Radar.js | 8 +++--- src/Chart.Scale.js | 13 --------- src/Chart.Scatter.js | 32 +++++++++++----------- 8 files changed, 89 insertions(+), 104 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 33d27410c99..723cdf67e6e 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -485,8 +485,8 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); break; case 'label': @@ -494,8 +494,8 @@ dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); } break; diff --git a/src/Chart.Core.js b/src/Chart.Core.js index b78acb09e43..70ff45163e8 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -120,9 +120,9 @@ borderWidth: 1, borderColor: defaultColor, // Hover - hitRadius: 6, + hitRadius: 1, hoverRadius: 4, - hoverBorderWidth: 2, + hoverBorderWidth: 1, }, bar: { backgroundColor: defaultColor, @@ -1222,14 +1222,14 @@ Chart.Point = Chart.Element.extend({ inRange: function(mouseX, mouseY) { var vm = this._view; - var hoverRange = vm.hoverRadius + vm.radius; + var hoverRange = vm.hitRadius + vm.radius; return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); }, inGroupRange: function(mouseX) { var vm = this._view; if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); } else { return false; } @@ -1256,11 +1256,11 @@ ctx.beginPath(); - ctx.arc(vm.x, vm.y, vm.radius, 0, Math.PI * 2); + ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); ctx.closePath(); ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; @@ -1665,7 +1665,8 @@ } }, this); - helpers.each(elements, function(element) { + // Reverse labels if stacked + helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { xPositions.push(element._view.x); yPositions.push(element._view.y); diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 6249069b3de..9d114f03034 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -190,26 +190,26 @@ }, events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (e.type == 'mouseout') { + this.active = []; +} else { + + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } // On Hover hook if (this.options.hover.onHover) { @@ -259,8 +259,7 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); break; @@ -269,8 +268,7 @@ dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); } diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 12e4259e3b3..1bf67bd7ddc 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -177,14 +177,14 @@ // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), }, }); }, this); @@ -288,14 +288,14 @@ // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), }, }); }, this); @@ -480,26 +480,25 @@ }, events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } // On Hover hook if (this.options.hover.onHover) { @@ -521,7 +520,7 @@ dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; index = this.lastActive[0]._index; - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); @@ -531,7 +530,7 @@ dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; index = this.lastActive[i]._index; - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); @@ -551,20 +550,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index 969c44dc28c..cd13793d791 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -299,20 +299,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': diff --git a/src/Chart.Radar.js b/src/Chart.Radar.js index 53a3d22eda2..30cf4d04e5c 100644 --- a/src/Chart.Radar.js +++ b/src/Chart.Radar.js @@ -443,8 +443,8 @@ index = this.active[0]._index; this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); break; case 'label': @@ -453,8 +453,8 @@ index = this.active[i]._index; this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); } break; diff --git a/src/Chart.Scale.js b/src/Chart.Scale.js index d42fe9c69bb..4d1224cc932 100644 --- a/src/Chart.Scale.js +++ b/src/Chart.Scale.js @@ -146,19 +146,6 @@ // At this point, maxChartHeight and maxChartWidth are the size the chart area could // be if the axes are drawn at their minimum sizes. - if (chartInstance.options.maintainAspectRatio) { - // Figure out what the real max size will be - var maxAspectRatio = maxChartHeight / maxChartWidth; - - if (maxAspectRatio != screenAspectRatio) { - // Need to adjust - if (maxChartHeight < maxChartWidth) { - maxChartWidth = maxChartHeight / screenAspectRatio; - } else { - maxChartHeight = maxChartWidth * screenAspectRatio; - } - } - } // Step 6 var verticalScaleFitFunction = function(scaleInstance) { diff --git a/src/Chart.Scatter.js b/src/Chart.Scatter.js index c32b876a49b..f995e7cd5b6 100644 --- a/src/Chart.Scatter.js +++ b/src/Chart.Scatter.js @@ -16,7 +16,7 @@ display: true, position: "bottom", id: "x-axis-1", // need an ID so datasets can reference the scale - + // grid line settings gridLines: { show: true, @@ -48,7 +48,7 @@ display: true, position: "left", id: "y-axis-1", - + // grid line settings gridLines: { show: true, @@ -292,7 +292,7 @@ // Desired view properties _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), // Appearance @@ -354,7 +354,7 @@ var calculateXRange = function() { this.min = null; this.max = null; - + helpers.each(self.data.datasets, function(dataset) { // Only set the scale range for datasets that actually use this axis if (dataset.xAxisID === this.id) { @@ -364,7 +364,7 @@ } else if (value.x < this.min) { this.min = value.x; } - + if (this.max === null) { this.max = value.x; } else if (value.x > this.max) { @@ -378,7 +378,7 @@ var calculateYRange = function() { this.min = null; this.max = null; - + helpers.each(self.data.datasets, function(dataset) { if (dataset.yAxisID === this.id) { helpers.each(dataset.data, function(value) { @@ -387,7 +387,7 @@ } else if (value.y < this.min) { this.min = value.y; } - + if (this.max === null) { this.max = value.y; } else if (value.y > this.max) { @@ -486,7 +486,7 @@ this.options.hover.onHover.call(this, this.active); } - var dataset; + var dataset; var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { @@ -525,20 +525,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': From 15a32f4c78e32ce8eb25c1a68259e03d6dfaa0ad Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 11 Jun 2015 09:48:17 -0600 Subject: [PATCH 118/424] Gulp build --- Chart.js | 248 ++++++++++++++++++++++++++++----------------------- Chart.min.js | 10 +-- 2 files changed, 139 insertions(+), 119 deletions(-) diff --git a/Chart.js b/Chart.js index d52cfbc57b6..cdcdb7f9770 100644 --- a/Chart.js +++ b/Chart.js @@ -120,9 +120,9 @@ borderWidth: 1, borderColor: defaultColor, // Hover - hitRadius: 6, + hitRadius: 1, hoverRadius: 4, - hoverBorderWidth: 2, + hoverBorderWidth: 1, }, bar: { backgroundColor: defaultColor, @@ -206,7 +206,7 @@ baseArray.push(valueObj); // nothing to merge } }); - } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && typeof value == "object") { + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { // If we are overwriting an object with an object, do a merge of the properties. base[key] = helpers.configMerge(base[key], value); } else { @@ -329,6 +329,13 @@ return x > 0 ? 1 : -1; } }, + log10 = helpers.log10 = function(x) { + if (Math.log10) { + return Math.log10(x) + } else { + return Math.log(x) / Math.LN10; + } + }, cap = helpers.cap = function(valueToCap, maxValue, minValue) { if (isNumber(maxValue)) { if (valueToCap > maxValue) { @@ -484,7 +491,7 @@ }, // Implementation of the nice number algorithm used in determining where axis labels will go niceNum = helpers.niceNum = function(range, round) { - var exponent = Math.floor(Math.log10(range)); + var exponent = Math.floor(helpers.log10(range)); var fraction = range / Math.pow(10, exponent); var niceFraction; @@ -1215,14 +1222,14 @@ Chart.Point = Chart.Element.extend({ inRange: function(mouseX, mouseY) { var vm = this._view; - var hoverRange = vm.hoverRadius + vm.radius; + var hoverRange = vm.hitRadius + vm.radius; return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); }, inGroupRange: function(mouseX) { var vm = this._view; if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); } else { return false; } @@ -1249,11 +1256,11 @@ ctx.beginPath(); - ctx.arc(vm.x, vm.y, vm.radius, 0, Math.PI * 2); + ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); ctx.closePath(); ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; @@ -1658,7 +1665,8 @@ } }, this); - helpers.each(elements, function(element) { + // Reverse labels if stacked + helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { xPositions.push(element._view.x); yPositions.push(element._view.y); @@ -2474,8 +2482,8 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); break; case 'label': @@ -2483,8 +2491,8 @@ dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); } break; @@ -2741,26 +2749,26 @@ }, events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (e.type == 'mouseout') { + this.active = []; +} else { + + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } // On Hover hook if (this.options.hover.onHover) { @@ -2810,8 +2818,7 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); break; @@ -2820,8 +2827,7 @@ dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); } @@ -2985,7 +2991,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", @@ -3096,14 +3102,14 @@ // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), }, }); }, this); @@ -3151,6 +3157,15 @@ // Update the lines this.eachDataset(function(dataset, datasetIndex) { var yScale = this.scales[dataset.yAxisID]; + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } helpers.extend(dataset.metaDataset, { // Utility @@ -3171,7 +3186,7 @@ // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom, - scaleZero: yScale.getPixelForValue(0), + scaleZero: scaleBase, }, }); @@ -3198,14 +3213,14 @@ // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), }, }); }, this); @@ -3390,26 +3405,25 @@ }, events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } // On Hover hook if (this.options.hover.onHover) { @@ -3431,7 +3445,7 @@ dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; index = this.lastActive[0]._index; - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); @@ -3441,7 +3455,7 @@ dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; index = this.lastActive[i]._index; - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); @@ -3461,20 +3475,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': @@ -3570,7 +3584,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", @@ -3839,20 +3853,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': @@ -3980,7 +3994,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", @@ -4133,6 +4147,16 @@ // Update the lines this.eachDataset(function(dataset, datasetIndex) { + var scaleBase; + + if (this.scale.min < 0 && this.scale.max < 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.max); + } else if (this.scale.min > 0 && this.scale.max > 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.min); + } else { + scaleBase = this.scale.getPointPosition(0, 0); + } + helpers.extend(dataset.metaDataset, { // Utility _datasetIndex: datasetIndex, @@ -4154,7 +4178,7 @@ // Scale scaleTop: this.scale.top, scaleBottom: this.scale.bottom, - scaleZero: this.scale.getPointPosition(0), + scaleZero: scaleBase, }, }); @@ -4374,8 +4398,8 @@ index = this.active[0]._index; this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); break; case 'label': @@ -4384,8 +4408,8 @@ index = this.active[i]._index; this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); } break; @@ -4594,19 +4618,6 @@ // At this point, maxChartHeight and maxChartWidth are the size the chart area could // be if the axes are drawn at their minimum sizes. - if (chartInstance.options.maintainAspectRatio) { - // Figure out what the real max size will be - var maxAspectRatio = maxChartHeight / maxChartWidth; - - if (maxAspectRatio != screenAspectRatio) { - // Need to adjust - if (maxChartHeight < maxChartWidth) { - maxChartWidth = maxChartHeight / screenAspectRatio; - } else { - maxChartHeight = maxChartWidth * screenAspectRatio; - } - } - } // Step 6 var verticalScaleFitFunction = function(scaleInstance) { @@ -5680,7 +5691,7 @@ display: true, position: "bottom", id: "x-axis-1", // need an ID so datasets can reference the scale - + // grid line settings gridLines: { show: true, @@ -5700,7 +5711,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", @@ -5712,7 +5723,7 @@ display: true, position: "left", id: "y-axis-1", - + // grid line settings gridLines: { show: true, @@ -5732,7 +5743,7 @@ // label settings labels: { show: true, - template: "<%=value%>", + template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", @@ -5905,6 +5916,15 @@ // Update the lines this.eachDataset(function(dataset, datasetIndex) { var yScale = this.scales[dataset.yAxisID]; + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } helpers.extend(dataset.metaDataset, { // Utility @@ -5925,7 +5945,7 @@ // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom, - scaleZero: yScale.getPixelForValue(0), + scaleZero: scaleBase, }, }); @@ -5947,7 +5967,7 @@ // Desired view properties _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), // Appearance @@ -6009,7 +6029,7 @@ var calculateXRange = function() { this.min = null; this.max = null; - + helpers.each(self.data.datasets, function(dataset) { // Only set the scale range for datasets that actually use this axis if (dataset.xAxisID === this.id) { @@ -6019,7 +6039,7 @@ } else if (value.x < this.min) { this.min = value.x; } - + if (this.max === null) { this.max = value.x; } else if (value.x > this.max) { @@ -6033,7 +6053,7 @@ var calculateYRange = function() { this.min = null; this.max = null; - + helpers.each(self.data.datasets, function(dataset) { if (dataset.yAxisID === this.id) { helpers.each(dataset.data, function(value) { @@ -6042,7 +6062,7 @@ } else if (value.y < this.min) { this.min = value.y; } - + if (this.max === null) { this.max = value.y; } else if (value.y > this.max) { @@ -6141,7 +6161,7 @@ this.options.hover.onHover.call(this, this.active); } - var dataset; + var dataset; var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { @@ -6180,20 +6200,20 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.35).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': diff --git a/Chart.min.js b/Chart.min.js index 1783a879a49..2248e875aa9 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,8 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:6,hoverRadius:4,hoverBorderWidth:2},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},p=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,h=p(t),l=g(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(Math.log10(t)),s=t/Math.pow(10,o);return i=e?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,h=function(){n++;var i=n/e,l=r(i);t.call(a,l,i,n),o.call(a,l,i),e>n?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},I=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),S=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},R=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return S(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,I(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,h=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=h(i,this._active[0]),-1===o);r--);var l=function(t){var e,i,r,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=g(u),r=p(u),h=g(d),i=p(d),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=p([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}R(t,r,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+a/2)}break;case"label":R(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing; -},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(), -this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,n=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:this.scale.getPointPosition(0)}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sC?y=C/u:C=y*u)}var w=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t});e&&t.fit(e.minSize.width,C)},k=function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:P,right:I,top:0,bottom:0};e&&t.fit(y,e.minSize.height,o)},P=s,I=s,S=a,W=a;i.each(n,w),i.each(r,w),i.each(n,function(t){P+=t.width}),i.each(r,function(t){I+=t.width}),i.each(h,k),i.each(l,k),i.each(h,function(t){S+=t.height}),i.each(l,function(t){W+=t.height}),i.each(n,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)}),i.each(r,function(t){var e=i.findNextWhere(b,function(e){return e.scale===t}),o={left:0,right:0,top:S,bottom:W};e&&t.fit(e.minSize.width,C,o)});var D=s,R=a,O=function(t){t.left=D,t.right=D+t.width,t.top=S,t.bottom=S+C,D=t.right},V=function(t){t.left=P,t.right=P+y,t.top=R,t.bottom=R+t.height,R=t.bottom};i.each(n,O),i.each(h,V),D+=y,R+=C,i.each(r,O),i.each(l,V),t.chartArea={left:P,top:S,right:P+y,bottom:S+C}}}},e.scales={constructors:{},registerScaleType:function(t,e){this.constructors[t]=e},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}};var o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,a=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,!1),l=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),o=(r+h)/2,i=h==r?0:.5>=o?l/(h+r):l/(2-h-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),h=Math.max(s,a,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(a-n)/l:a==h?e=2+(n-s)/l:n==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=l(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=n+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function v(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return h(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,n];case 1:return[r,o,n];case 2:return[n,o,h];case 3:return[n,r,o];case 4:return[h,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return h(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function I(t){return n(w(t))}function S(t){return h(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function R(t){return s(W(t))}function O(t){return a(W(t))}function V(t){return h(W(t))}function M(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function B(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(B(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return M(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return l(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:v,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:I,hwb2keyword:S,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:R,cmyk2hwb:O,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:M,xyz2lab:B,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new l};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments)); -var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return v(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function v(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:v,hslString:m,hslaString:p,hwbString:g,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},p=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,h=g(t),l=p(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(s.log10(t)),a=t/Math.pow(10,o);return i=e?1.5>a?1:3>a?2:7>a?5:10:1>=a?1:2>=a?2:5>=a?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,h=function(){n++;var i=n/e,l=r(i);t.call(a,l,i,n),o.call(a,l,i),e>n?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},S=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),I=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},O=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return I(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,S(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius||i.defaults.global.elements.point.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.elements.point.borderWidth,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,h=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=h(i,this._active[0]),-1===o);r--);var l=function(t){var e,i,r,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(this._options.stacked?c.reverse():c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=p(u),r=g(u),h=p(d),i=g(d),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=g([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}O(t,r,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+a/2)}break;case"label":O(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id, +calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(null,e,!0),y:n.getPointPixelForValue(this.data.datasets[s].data[e],e,s),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){this.lastActive=this.lastActive||[],"mouseout"==t.type?this.active=[]:this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.radius:i.getValueAtIndexOrDefault(e.radius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2; +i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,n=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){var o;o=this.scale.min<0&&this.scale.max<0?this.scale.getPointPosition(0,this.scale.max):this.scale.min>0&&this.scale.max>0?this.scale.getPointPosition(0,this.scale.min):this.scale.getPointPosition(0,0),i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sn&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,a=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,!1),l=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,g=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a; +if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(this.data.datasets[s].data[e].x),y:n.getPixelForValue(this.data.datasets[s].data[e].y),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),o=(r+h)/2,i=h==r?0:.5>=o?l/(h+r):l/(2-h-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),h=Math.max(s,a,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(a-n)/l:a==h?e=2+(n-s)/l:n==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=l(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=n+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function v(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return h(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,n];case 1:return[r,o,n];case 2:return[n,o,h];case 3:return[n,r,o];case 4:return[h,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return h(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function S(t){return n(w(t))}function I(t){return h(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function O(t){return s(W(t))}function M(t){return a(W(t))}function V(t){return h(W(t))}function B(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function R(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(R(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return B(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return l(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:v,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:S,hwb2keyword:I,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:O,cmyk2hwb:M,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:B,xyz2lab:R,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new l};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments)); +var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return v(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function v(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?g(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:v,hslString:m,hslaString:g,hwbString:p,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From 187163763e2ae36d8f58d6404881dfabe6ec0f38 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 11 Jun 2015 10:04:08 -0600 Subject: [PATCH 119/424] Line element custom override support --- Chart.js | 10 +++++----- Chart.min.js | 10 +++++----- src/Chart.Line.js | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Chart.js b/Chart.js index cdcdb7f9770..55be0663ac8 100644 --- a/Chart.js +++ b/Chart.js @@ -3176,11 +3176,11 @@ // Model _model: { // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, // Scale diff --git a/Chart.min.js b/Chart.min.js index 2248e875aa9..8bea7c5a1a3 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,8 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},v=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},p=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,h=g(t),l=p(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=f(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=u-v,b=Math.pow(10,d),x=Math.round(m/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=a,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(s.log10(t)),a=t/Math.pow(10,o);return i=e?1.5>a?1:3>a?2:7>a?5:10:1>=a?1:2>=a?2:5>=a?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,h=function(){n++;var i=n/e,l=r(i);t.call(a,l,i,n),o.call(a,l,i),e>n?a.animationFrame=A(h):s.apply(a)};A(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},S=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),I=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},O=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return I(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,S(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius||i.defaults.global.elements.point.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.elements.point.borderWidth,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,h=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=h(i,this._active[0]),-1===o);r--);var l=function(t){var e,i,r,h,l,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(this._options.stacked?c.reverse():c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=p(u),r=g(u),h=p(d),i=g(d),{x:h>this._chart.width/2?h:i,y:(l+r)/2}}.call(this,o);s.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=g([d,c]);this._model.width=u+2*this._model.xPadding;var v=this._model.height/2;this._model.y-v<0?this._model.y=v:this._model.y+v>this._chart.height&&(this._model.y=this._chart.height-v),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}O(t,r,h,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+a/2)}break;case"label":O(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),v?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id, -calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,h=t;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(null,e,!0),y:n.getPointPixelForValue(this.data.datasets[s].data[e],e,s),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){this.lastActive=this.lastActive||[],"mouseout"==t.type?this.active=[]:this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.radius:i.getValueAtIndexOrDefault(e.radius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2; -i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,n=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){var o;o=this.scale.min<0&&this.scale.max<0?this.scale.getPointPosition(0,this.scale.max):this.scale.min>0&&this.scale.max>0?this.scale.getPointPosition(0,this.scale.min):this.scale.getPointPosition(0,0),i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sn&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,a=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,!1),l=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,h,l,c,d,u,v=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,g=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,a=e),t.x-sm&&(m=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a; -if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>a-r,l=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(this.data.datasets[s].data[e].x),y:n.getPixelForValue(this.data.datasets[s].data[e].y),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),o=(r+h)/2,i=h==r?0:.5>=o?l/(h+r):l/(2-h-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),h=Math.max(s,a,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(a-n)/l:a==h?e=2+(n-s)/l:n==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=l(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return a=255*h,[a,a,a];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=n+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function v(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return h(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,n];case 1:return[r,o,n];case 2:return[n,o,h];case 3:return[n,r,o];case 4:return[h,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return h(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function S(t){return n(w(t))}function I(t){return h(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function O(t){return s(W(t))}function M(t){return a(W(t))}function V(t){return h(W(t))}function B(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function R(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(R(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return B(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return l(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:v,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:S,hwb2keyword:I,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:O,cmyk2hwb:M,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:B,xyz2lab:R,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new l};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments)); -var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return v(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function v(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?g(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:v,hslString:m,hslaString:g,hwbString:p,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=h,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},m=s.amd="function"==typeof define&&define.amd,v=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},p=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},s.cap=function(t,e,i){if(v(e)){if(t>e)return e}else if(v(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&v(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,l=g(t),h=p(t);l===h&&(l+=.5,h>=.5&&!o?h-=.5:l+=.5);for(var c=Math.abs(l-h),d=f(c),u=Math.ceil(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=o?0:Math.floor(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=u-m,b=Math.pow(10,d),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=a,b=v/x),{steps:x,stepValue:b,min:m,max:m+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(s.log10(t)),a=t/Math.pow(10,o);return i=e?1.5>a?1:3>a?2:7>a?5:10:1>=a?1:2>=a?2:5>=a?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,l=function(){n++;var i=n/e,h=r(i);t.call(a,h,i,n),o.call(a,h,i),e>n?a.animationFrame=A(l):s.apply(a)};A(l)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},S=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),I=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},O=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return I(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,S(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius||i.defaults.global.elements.point.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.elements.point.borderWidth,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,l=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&l},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=l(i,this._active[0]),-1===o);r--);var h=function(t){var e,i,r,l,h,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(this._options.stacked?c.reverse():c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=p(u),r=g(u),l=p(d),i=g(d),{x:l>this._chart.width/2?l:i,y:(h+r)/2}}.call(this,o);s.extend(this._model,{x:h.x,y:h.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=g([d,c]);this._model.width=u+2*this._model.xPadding;var m=this._model.height/2;this._model.y-m<0?this._model.y=m:this._model.y+m>this._chart.height&&(this._model.y=this._chart.height-m),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,l=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":l=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}O(t,r,l,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,l+a/2)}break;case"label":O(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),m?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id, +calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,l=t;l0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.metaDataset.custom&&t.metaDataset.custom.tension?t.metaDataset.custom.tension:t.tension||this.options.elements.line.tension,backgroundColor:t.metaDataset.custom&&t.metaDataset.custom.backgroundColor?t.metaDataset.custom.backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.metaDataset.custom&&t.metaDataset.custom.borderWidth?t.metaDataset.custom.borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.metaDataset.custom&&t.metaDataset.custom.borderColor?t.metaDataset.custom.borderColor:t.borderColor||this.options.elements.line.borderColor,fill:t.metaDataset.custom&&t.metaDataset.custom.fill?t.metaDataset.custom.fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(null,e,!0),y:n.getPointPixelForValue(this.data.datasets[s].data[e],e,s),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){this.lastActive=this.lastActive||[],"mouseout"==t.type?this.active=[]:this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.radius:i.getValueAtIndexOrDefault(e.radius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor), +label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,n=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){var o;o=this.scale.min<0&&this.scale.max<0?this.scale.getPointPosition(0,this.scale.max):this.scale.min>0&&this.scale.max>0?this.scale.getPointPosition(0,this.scale.min):this.scale.getPointPosition(0,0),i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sn&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var l=i.niceNum(this.max-this.min,!1),h=i.niceNum(l/(a-1),!0),c=Math.floor(this.min/h)*h,d=Math.ceil(this.max/h)*h,u=c;d>=u;u+=h)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var l=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,s),this.ctx.lineTo(l,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,l="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(l,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var h;"left"==this.options.position?(h=this.right-10,this.ctx.textAlign="right"):(h=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,h,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var l,h,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(l=Math.cos(i.toRadians(this.labelRotation)),h=Math.sin(i.toRadians(this.labelRotation)),s=l*n,a=l*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,h*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=l*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var l=this.getPixelForValue(n,r,!1),h=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,o),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(h,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),l=Math.floor(this.min/r)*r,h=Math.ceil(this.max/r)*r,c=l;h>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,l,h,c,d,u,m=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),v=this.width,g=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ev&&(v=t.x+s,a=e),t.x-sv&&(v=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,l=r>e||e>a-r,h=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",h?t.textBaseline="middle":l?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(this.data.datasets[s].data[e].x),y:n.getPixelForValue(this.data.datasets[s].data[e].y),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),l=0;le&&(e+=360),o=(r+l)/2,i=l==r?0:.5>=o?h/(l+r):h/(2-l-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),l=Math.max(s,a,n),h=l-r;return i=0==l?0:h/l*1e3/10,l==r?e=0:s==l?e=(a-n)/h:a==l?e=2+(n-s)/h:n==l&&(e=4+(s-a)/h),e=Math.min(60*e,360),0>e&&(e+=360),o=l/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function l(t){return $[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=h(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,l=t[2]/100;if(0==r)return a=255*l,[a,a,a];i=.5>l?l*(1+r):l+r-l*r,e=2*l-i,s=[0,0,0];for(var h=0;3>h;h++)o=n+1/3*-(h-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[h]=255*a;return s}function m(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function v(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return l(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),l=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,l,n];case 1:return[r,o,n];case 2:return[n,o,l];case 3:return[n,r,o];case 4:return[l,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return l(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,l=t[2]/100,h=n+l;switch(h>1&&(n/=h,l/=h),e=Math.floor(6*a),i=1-l,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function S(t){return n(w(t))}function I(t){return l(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function O(t){return s(W(t))}function M(t){return a(W(t))}function V(t){return l(W(t))}function B(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function R(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(R(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return B(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return h(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:l,rgb2xyz:h,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:m,hsl2hwb:v,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:S,hwb2keyword:I,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:O,cmyk2hwb:M,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:B,xyz2lab:R,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50] +},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new h};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],l=n[2];s[r]=s[r]||{},s[r][l]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return m(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function m(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function v(t,e){return 1>e||t[3]&&t[3]<1?g(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:l,hexString:h,rgbString:c,rgbaString:d,percentString:u,percentaString:m,hslString:v,hslaString:g,hwbString:p,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/src/Chart.Line.js b/src/Chart.Line.js index 7fe9ef340ca..b967b254181 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -251,11 +251,11 @@ // Model _model: { // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, // Scale From 5732e0d72a5aa0f84132c5b45ecef2b489df1a95 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 12 Jun 2015 14:00:48 -0600 Subject: [PATCH 120/424] More maintainable file structure --- Chart.js | 6815 ++++++++++++++++--------------- Chart.min.js | 63 +- gulpfile.js | 205 +- samples/line-multi-axis.html | 17 +- samples/line.html | 16 +- src/Chart.Animation.js | 127 + src/Chart.Bar.js | 2 + src/Chart.Core.Arc.js | 93 + src/Chart.Core.Line.js | 190 + src/Chart.Core.Point.js | 84 + src/Chart.Core.Rectangle.js | 95 + src/Chart.Core.js | 812 +--- src/Chart.Line.js | 10 +- src/Chart.Scale.Category.js | 211 + src/Chart.Scale.Linear.js | 357 ++ src/Chart.Scale.RadialLinear.js | 361 ++ src/Chart.Scale.js | 900 ---- src/Chart.Tooltip.js | 344 ++ 18 files changed, 5548 insertions(+), 5154 deletions(-) create mode 100644 src/Chart.Animation.js create mode 100644 src/Chart.Core.Arc.js create mode 100644 src/Chart.Core.Line.js create mode 100644 src/Chart.Core.Point.js create mode 100644 src/Chart.Core.Rectangle.js create mode 100644 src/Chart.Scale.Category.js create mode 100644 src/Chart.Scale.Linear.js create mode 100644 src/Chart.Scale.RadialLinear.js create mode 100644 src/Chart.Tooltip.js diff --git a/Chart.js b/Chart.js index 55be0663ac8..3c61a8d0d2e 100644 --- a/Chart.js +++ b/Chart.js @@ -54,12 +54,6 @@ //Globally expose the defaults to allow for user updating/changing Chart.defaults = { global: { - animation: { - duration: 1000, - easing: "easeOutQuart", - onProgress: function() {}, - onComplete: function() {}, - }, responsive: true, maintainAspectRatio: true, events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], @@ -69,74 +63,10 @@ animationDuration: 400, }, onClick: null, - tooltips: { - enabled: true, - custom: null, - backgroundColor: "rgba(0,0,0,0.8)", - fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - fontSize: 10, - fontStyle: "normal", - fontColor: "#fff", - titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - titleFontSize: 12, - titleFontStyle: "bold", - titleFontColor: "#fff", - yPadding: 6, - xPadding: 6, - caretSize: 8, - cornerRadius: 6, - xOffset: 10, - template: [ - '<% if(label){ %>', - '<%=label %>:', - '<% } %>', - '<%=value %>', - ].join(''), - multiTemplate: [ - '<%if (datasetLabel){ %>', - '<%=datasetLabel %>:', - '<% } %>', - '<%=value %>' - ].join(''), - multiKeyBackground: '#fff', - - }, defaultColor: defaultColor, - // Element defaults - elements: { - line: { - tension: 0.4, - backgroundColor: defaultColor, - borderWidth: 3, - borderColor: defaultColor, - fill: true, // do we fill in the area between the line and the x axis - skipNull: true, - drawNull: false, - }, - point: { - radius: 3, - backgroundColor: defaultColor, - borderWidth: 1, - borderColor: defaultColor, - // Hover - hitRadius: 1, - hoverRadius: 4, - hoverBorderWidth: 1, - }, - bar: { - backgroundColor: defaultColor, - borderWidth: 0, - borderColor: defaultColor, - valueSpacing: 5, - datasetSpacing: 1, - }, - slice: { - backgroundColor: defaultColor, - borderColor: "#fff", - borderWidth: 2, - }, - } + // Element defaults defined in element extensions + elements: {} }, }; @@ -1219,58 +1149,168 @@ Chart.Element.extend = inherits; - Chart.Point = Chart.Element.extend({ - inRange: function(mouseX, mouseY) { - var vm = this._view; - var hoverRange = vm.hitRadius + vm.radius; - return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); - }, + // Attach global event to resize each chart instance when the browser resizes + helpers.addEvent(window, "resize", (function() { + // Basic debounce of resize function so it doesn't hurt performance when resizing browser. + var timeout; + return function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + each(Chart.instances, function(instance) { + // If the responsive flag is set in the chart instance config + // Cascade the resize event down to the chart. + if (instance.options.responsive) { + instance.resize(); + instance.update(); + instance.render(); + } + }); + }, 50); + }; + })()); + + + if (amd) { + define(function() { + return Chart; + }); + } else if (typeof module === 'object' && module.exports) { + module.exports = Chart; + } + + root.Chart = Chart; + + Chart.noConflict = function() { + root.Chart = previous; + return Chart; + }; + +}).call(this); + +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ + + +(function() { + + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.arc = { + backgroundColor: Chart.defaults.global.defaultColor, + borderColor: "#fff", + borderWidth: 2 + }; + + Chart.Arc = Chart.Element.extend({ inGroupRange: function(mouseX) { var vm = this._view; if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); } else { return false; } }, + inRange: function(chartX, chartY) { + + var vm = this._view; + + var pointRelativePosition = helpers.getAngleFromPoint(vm, { + x: chartX, + y: chartY + }); + + // Put into the range of (-PI/2, 3PI/2] + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle + + //Check if within the range of the open/close angle + var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), + withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); + + return (betweenAngles && withinRadius); + //Ensure within the outside of the arc centre, but inside arc outer + }, tooltipPosition: function() { var vm = this._view; + + var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), + rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; return { - x: vm.x, - y: vm.y, - padding: vm.radius + vm.borderWidth + x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), + y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) }; }, draw: function() { - var vm = this._view; var ctx = this._chart.ctx; + var vm = this._view; + ctx.beginPath(); - if (vm.skip) { - return; - } - - if (vm.radius > 0 || vm.borderWidth > 0) { + ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); - ctx.beginPath(); + ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); - ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); - ctx.closePath(); + ctx.closePath(); + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; + ctx.fillStyle = vm.backgroundColor; - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; + ctx.fill(); + ctx.lineJoin = 'bevel'; - ctx.fill(); + if (vm.borderWidth) { ctx.stroke(); } } }); +}).call(this); + +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ + + +(function() { + + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.line = { + tension: 0.4, + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 3, + borderColor: Chart.defaults.global.defaultColor, + fill: true, // do we fill in the area between the line and its base axis + skipNull: true, + drawNull: false, + }; + + Chart.Line = Chart.Element.extend({ draw: function() { @@ -1430,89 +1470,135 @@ }, }); - Chart.Arc = Chart.Element.extend({ +}).call(this); + +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ + + +(function() { + + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.point = { + radius: 3, + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + // Hover + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1, + }; + + + Chart.Point = Chart.Element.extend({ + inRange: function(mouseX, mouseY) { + var vm = this._view; + var hoverRange = vm.hitRadius + vm.radius; + return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + }, inGroupRange: function(mouseX) { var vm = this._view; if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); } else { return false; } }, - inRange: function(chartX, chartY) { - - var vm = this._view; - - var pointRelativePosition = helpers.getAngleFromPoint(vm, { - x: chartX, - y: chartY - }); - - // Put into the range of (-PI/2, 3PI/2] - var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; - var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle - - //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), - withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); - - return (betweenAngles && withinRadius); - //Ensure within the outside of the arc centre, but inside arc outer - }, tooltipPosition: function() { var vm = this._view; - - var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), - rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; return { - x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), - y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) + x: vm.x, + y: vm.y, + padding: vm.radius + vm.borderWidth }; }, draw: function() { - var ctx = this._chart.ctx; var vm = this._view; + var ctx = this._chart.ctx; - ctx.beginPath(); - ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); + if (vm.skip) { + return; + } - ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); + if (vm.radius > 0 || vm.borderWidth > 0) { - ctx.closePath(); - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; + ctx.beginPath(); - ctx.fillStyle = vm.backgroundColor; + ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); + ctx.closePath(); - ctx.fill(); - ctx.lineJoin = 'bevel'; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; - if (vm.borderWidth) { + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; + + ctx.fill(); ctx.stroke(); } } }); - Chart.Rectangle = Chart.Element.extend({ - draw: function() { - - var ctx = this._chart.ctx; - var vm = this._view; - var halfWidth = vm.width / 2, - leftX = vm.x - halfWidth, - rightX = vm.x + halfWidth, - top = vm.base - (vm.base - vm.y), - halfStroke = vm.borderWidth / 2; +}).call(this); - // Canvas doesn't allow us to stroke inside the width so we can - // adjust the sizes to fit if we're setting a stroke on the line - if (vm.borderWidth) { - leftX += halfStroke; - rightX -= halfStroke; +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ + + +(function() { + + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.rectangle = { + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 0, + borderColor: Chart.defaults.global.defaultColor, + }; + + Chart.Rectangle = Chart.Element.extend({ + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._view; + + var halfWidth = vm.width / 2, + leftX = vm.x - halfWidth, + rightX = vm.x + halfWidth, + top = vm.base - (vm.base - vm.y), + halfStroke = vm.borderWidth / 2; + + // Canvas doesn't allow us to stroke inside the width so we can + // adjust the sizes to fit if we're setting a stroke on the line + if (vm.borderWidth) { + leftX += halfStroke; + rightX -= halfStroke; top += halfStroke; } @@ -1565,994 +1651,877 @@ }, }); - Chart.Animation = Chart.Element.extend({ - currentStep: null, // the current animation step - numSteps: 60, // default number of steps - easing: "", // the easing to use for this animation - render: null, // render function used by the animation service +}).call(this); - onAnimationProgress: null, // user specified callback to fire on each step of the animation - onAnimationComplete: null, // user specified callback to fire when the animation finishes - }); +(function() { + "use strict"; - Chart.Tooltip = Chart.Element.extend({ - initialize: function() { - var options = this._options; - extend(this, { - _model: { - // Positioning - xPadding: options.tooltips.xPadding, - yPadding: options.tooltips.yPadding, - xOffset: options.tooltips.xOffset, + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - // Labels - textColor: options.tooltips.fontColor, - _fontFamily: options.tooltips.fontFamily, - _fontStyle: options.tooltips.fontStyle, - fontSize: options.tooltips.fontSize, + // The scale service is used to resize charts along with all of their axes. We make this as + // a service where scales are registered with their respective charts so that changing the + // scales does not require + Chart.scaleService = { + // The interesting function + fitScalesForChart: function(chartInstance, width, height) { + var xPadding = 5; + var yPadding = 5; - // Title - titleTextColor: options.tooltips.titleFontColor, - _titleFontFamily: options.tooltips.titleFontFamily, - _titleFontStyle: options.tooltips.titleFontStyle, - titleFontSize: options.tooltips.titleFontSize, + if (chartInstance) { + var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "left"; + }); + var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "right"; + }); + var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "top"; + }); + var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "bottom"; + }); - // Appearance - caretHeight: options.tooltips.caretSize, - cornerRadius: options.tooltips.cornerRadius, - backgroundColor: options.tooltips.backgroundColor, - opacity: 0, - legendColorBackground: options.tooltips.multiKeyBackground, - }, - }); - }, - update: function() { + // Adjust the padding to take into account displaying labels + if (topScales.length === 0 || bottomScales.length === 0) { + var maxFontHeight = 0; - var ctx = this._chart.ctx; + var maxFontHeightFunction = function(scaleInstance) { + if (scaleInstance.options.labels.show) { + // Only consider font sizes for axes that actually show labels + maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); + } + }; - switch (this._options.hover.mode) { - case 'single': - helpers.extend(this._model, { - text: template(this._options.tooltips.template, { - // These variables are available in the template function. Add others here - element: this._active[0], - value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], - label: this._data.labels ? this._data.labels[this._active[0]._index] : '', - }), - }); + helpers.each(leftScales, maxFontHeightFunction); + helpers.each(rightScales, maxFontHeightFunction); - var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this._model, { - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - caretPadding: tooltipPosition.padding - }); + if (topScales.length === 0) { + // Add padding so that we can handle drawing the top nicely + yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides + } - break; + if (bottomScales.length === 0) { + // Add padding so that we can handle drawing the bottom nicely + yPadding += 1.5 * maxFontHeight; + } + } - case 'label': + // Essentially we now have any number of scales on each of the 4 sides. + // Our canvas looks like the following. + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and + // B1 is the bottom axis + // |------------------------------------------------------| + // | | T1 | | + // |----|-----|-------------------------------------|-----| + // | | | | | + // | L1 | L2 | Chart area | R1 | + // | | | | | + // | | | | | + // |----|-----|-------------------------------------|-----| + // | | B1 | | + // | | | | + // |------------------------------------------------------| - // Tooltip Content + // What we do to find the best sizing, we do the following + // 1. Determine the minimum size of the chart area. + // 2. Split the remaining width equally between each vertical axis + // 3. Split the remaining height equally between each horizontal axis + // 4. Give each scale the maximum size it can be. The scale will return it's minimum size + // 5. Adjust the sizes of each axis based on it's minimum reported size. + // 6. Refit each axis + // 7. Position each axis in the final location + // 8. Tell the chart the final location of the chart area - var dataArray, - dataIndex; + // Step 1 + var chartWidth = width / 2; // min 50% + var chartHeight = height / 2; // min 50% + var aspectRatio = chartHeight / chartWidth; + var screenAspectRatio; - var labels = [], - colors = []; + if (chartInstance.options.maintainAspectRatio) { + screenAspectRatio = height / width; - for (var i = this._data.datasets.length - 1; i >= 0; i--) { - dataArray = this._data.datasets[i].metaData; - dataIndex = indexOf(dataArray, this._active[0]); - if (dataIndex !== -1) { - break; - } + if (aspectRatio != screenAspectRatio) { + chartHeight = chartWidth * screenAspectRatio; + aspectRatio = screenAspectRatio; } + } - var medianPosition = (function(index) { - // Get all the points at that particular index - var elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this._data.datasets, function(dataset) { - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { - elements.push(dataCollection[dataIndex]); - } - }, this); + chartWidth -= (2 * xPadding); + chartHeight -= (2 * yPadding); - // Reverse labels if stacked - helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { - xPositions.push(element._view.x); - yPositions.push(element._view.y); + // Step 2 + var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); - //Include any colour information about the element - labels.push(helpers.template(this._options.tooltips.multiTemplate, { - // These variables are available in the template function. Add others here - element: element, - datasetLabel: this._data.datasets[element._datasetIndex].label, - value: this._data.datasets[element._datasetIndex].data[element._index], - })); - colors.push({ - fill: element._view.backgroundColor, - stroke: element._view.borderColor - }); + // Step 3 + var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); - }, this); + // Step 4; + var minimumScaleSizes = []; - yMin = min(yPositions); - yMax = max(yPositions); + var verticalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); + minimumScaleSizes.push({ + horizontal: false, + minSize: minSize, + scale: scaleInstance, + }); + }; - xMin = min(xPositions); - xMax = max(xPositions); + var horizontalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); + minimumScaleSizes.push({ + horizontal: true, + minSize: minSize, + scale: scaleInstance, + }); + }; - return { - x: (xMin > this._chart.width / 2) ? xMin : xMax, - y: (yMin + yMax) / 2, - }; - }).call(this, dataIndex); + // vertical scales + helpers.each(leftScales, verticalScaleMinSizeFunction); + helpers.each(rightScales, verticalScaleMinSizeFunction); - // Apply for now - helpers.extend(this._model, { - x: medianPosition.x, - y: medianPosition.y, - labels: labels, - title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', - legendColors: colors, - legendBackgroundColor: this._options.tooltips.multiKeyBackground, - }); + // horizontal scales + helpers.each(topScales, horizontalScaleMinSizeFunction); + helpers.each(bottomScales, horizontalScaleMinSizeFunction); + // Step 5 + var maxChartHeight = height - (2 * yPadding); + var maxChartWidth = width - (2 * xPadding); - // Calculate Appearance Tweaks + helpers.each(minimumScaleSizes, function(wrapper) { + if (wrapper.horizontal) { + maxChartHeight -= wrapper.minSize.height; + } else { + maxChartWidth -= wrapper.minSize.width; + } + }); - this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; + // At this point, maxChartHeight and maxChartWidth are the size the chart area could + // be if the axes are drawn at their minimum sizes. - var titleWidth = ctx.measureText(this.title).width, - //Label has a legend square as well so account for this. - labelWidth = longestText(ctx, this.font, labels) + this._model.fontSize + 3, - longestTextWidth = max([labelWidth, titleWidth]); + // Step 6 + var verticalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); - this._model.width = longestTextWidth + (this._model.xPadding * 2); + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight); + } + }; + var horizontalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); - var halfHeight = this._model.height / 2; + var scaleMargin = { + left: totalLeftWidth, + right: totalRightWidth, + top: 0, + bottom: 0, + }; - //Check to ensure the height will fit on the canvas - if (this._model.y - halfHeight < 0) { - this._model.y = halfHeight; - } else if (this._model.y + halfHeight > this._chart.height) { - this._model.y = this._chart.height - halfHeight; + if (wrapper) { + scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); } + }; - //Decide whether to align left or right based on position on canvas - if (this._model.x > this._chart.width / 2) { - this._model.x -= this._model.xOffset + this._model.width; - } else { - this._model.x += this._model.xOffset; - } - break; - } + var totalLeftWidth = xPadding; + var totalRightWidth = xPadding; + var totalTopHeight = yPadding; + var totalBottomHeight = yPadding; - return this; - }, - draw: function() { + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); - var ctx = this._chart.ctx; - var vm = this._view; + // Figure out how much margin is on the left and right of the horizontal axes + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); - switch (this._options.hover.mode) { - case 'single': + helpers.each(rightScales, function(scaleInstance) { + totalRightWidth += scaleInstance.width; + }); - ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); - vm.xAlign = "center"; - vm.yAlign = "above"; + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; + }); + helpers.each(bottomScales, function(scaleInstance) { + totalBottomHeight += scaleInstance.height; + }); - //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding || 2; + // Let the left scale know the final margin + helpers.each(leftScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); - var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, - tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, - tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; - if (vm.x + tooltipWidth / 2 > this._chart.width) { - vm.xAlign = "left"; - } else if (vm.x - tooltipWidth / 2 < 0) { - vm.xAlign = "right"; + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); } + }); - if (vm.y - tooltipHeight < 0) { - vm.yAlign = "below"; - } + helpers.each(rightScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); - var tooltipX = vm.x - tooltipWidth / 2, - tooltipY = vm.y - tooltipHeight; + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); - // Custom Tooltips - if (this._custom) { - this._custom(this._view); - } else { - switch (vm.yAlign) { - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } + // Step 7 + // Position the scales + var left = xPadding; + var top = yPadding; + var right = 0; + var bottom = 0; - switch (vm.xAlign) { - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } + var verticalScalePlacer = function(scaleInstance) { + scaleInstance.left = left; + scaleInstance.right = left + scaleInstance.width; + scaleInstance.top = totalTopHeight; + scaleInstance.bottom = totalTopHeight + maxChartHeight; - drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); + // Move to next point + left = scaleInstance.right; + }; - ctx.fill(); + var horizontalScalePlacer = function(scaleInstance) { + scaleInstance.left = totalLeftWidth; + scaleInstance.right = totalLeftWidth + maxChartWidth; + scaleInstance.top = top; + scaleInstance.bottom = top + scaleInstance.height; - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); + // Move to next point + top = scaleInstance.bottom; + }; - } - break; - case 'label': + helpers.each(leftScales, verticalScalePlacer); + helpers.each(topScales, horizontalScalePlacer); - drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - ctx.fill(); - ctx.closePath(); + // Account for chart width and height + left += maxChartWidth; + top += maxChartHeight; - ctx.textAlign = "left"; - ctx.textBaseline = "middle"; - ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); - ctx.font = fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); - ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); + helpers.each(rightScales, verticalScalePlacer); + helpers.each(bottomScales, horizontalScalePlacer); - ctx.font = fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - helpers.each(vm.labels, function(label, index) { - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); + // Step 8 + chartInstance.chartArea = { + left: totalLeftWidth, + top: totalTopHeight, + right: totalLeftWidth + maxChartWidth, + bottom: totalTopHeight + maxChartHeight, + }; + } + } + }; - //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) - //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); - //Instead we'll make a white filled block to put the legendColour palette over. + // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then + // use the new chart options to grab the correct scale + Chart.scales = { + constructors: {}, + // Use a registration function so that we can move to an ES6 map when we no longer need to support + // old browsers + registerScaleType: function(scaleType, scaleConstructor) { + this.constructors[scaleType] = scaleConstructor; + }, + getScaleConstructor: function(scaleType) { + return this.constructors.hasOwnProperty(scaleType) ? this.constructors[scaleType] : undefined; + } + }; - ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); +}).call(this); - ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); +(function() { + "use strict"; + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - }, this); - break; - } + var DatasetScale = Chart.Element.extend({ + // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset + calculateRange: helpers.noop, + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; }, - getLineHeight: function(index) { - var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, - afterTitleIndex = index - 1; + getPixelForValue: function(value, index, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; - //If the index is zero, we're getting the title - if (index === 0) { - return baseLineHeight + this._view.titleFontSize / 2; + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + + return this.left + Math.round(valueOffset); } else { - return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; + return this.top + (index * (this.height / this.max)); } - }, - }); + calculateLabelRotation: function(maxHeight, margins) { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; - Chart.animationService = { - frameDuration: 17, - animations: [], - dropFrames: 0, - addAnimation: function(chartInstance, animationObject, duration) { + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + var firstRotated; + var lastRotated; - if (!duration) { - chartInstance.animating = true; - } + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; - for (var index = 0; index < this.animations.length; ++index) { - if (this.animations[index].chartInstance === chartInstance) { - // replacing an in progress animation - this.animations[index].animationObject = animationObject; - return; - } - } + this.labelRotation = 0; - this.animations.push({ - chartInstance: chartInstance, - animationObject: animationObject - }); + if (this.options.display) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; - // If there are no animations queued, manually kickstart a digest, for lack of a better word - if (this.animations.length == 1) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - }, - // Cancel the animation for a given chart instance - cancelAnimation: function(chartInstance) { - var index = helpers.findNextWhere(this.animations, function(animationWrapper) { - return animationWrapper.chartInstance === chartInstance; - }); + this.labelWidth = originalLabelWidth; - if (index) { - this.animations.splice(index, 1); - chartInstance.animating = false; - } - }, - // calls startDigest with the proper context - digestWrapper: function() { - Chart.animationService.startDigest.call(Chart.animationService); - }, - startDigest: function() { + //Allow 3 pixels x2 padding either side for label readability + // only the index matters for a dataset scale, but we want a consistent interface between scales + var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; - var startTime = Date.now(); - var framesToDrop = 0; + //Max label rotate should be 90 - also act as a loop counter + while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); - if (this.dropFrames > 1) { - framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; - } + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; - for (var i = 0; i < this.animations.length; i++) { + // We're right aligning the text now. + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; + } - if (this.animations[i].animationObject.currentStep === null) { - this.animations[i].animationObject.currentStep = 0; - } + this.paddingRight = this.options.labels.fontSize / 2; - this.animations[i].animationObject.currentStep += 1 + framesToDrop; - if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { - this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; - } + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } - this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; - if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { - // executed the last frame. Remove the animation. - this.animations[i].chartInstance.animating = false; - this.animations.splice(i, 1); - // Keep the index in place to offset the splice - i--; } + } else { + this.labelWidth = 0; + this.paddingRight = 0; + this.paddingLeft = 0; } - var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; - if (frameDelay > 1) { - this.dropFrames += frameDelay; + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); } - // Do we have more stuff to animate? - if (this.animations.length > 0) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - } - }; + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight, margins) { + this.calculateRange(); + this.calculateLabelRotation(maxHeight, margins); - // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function() { - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function() { - clearTimeout(timeout); - timeout = setTimeout(function() { - each(Chart.instances, function(instance) { - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive) { - instance.resize(); - instance.update(); - instance.render(); - } - }); - }, 50); - }; - })()); + var minSize = { + width: 0, + height: 0, + }; + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - if (amd) { - define(function() { - return Chart; - }); - } else if (typeof module === 'object' && module.exports) { - module.exports = Chart; - } + if (this.isHorizontal()) { + minSize.width = maxWidth; + this.width = maxWidth; - root.Chart = Chart; + var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else { + minSize.height = maxHeight; + this.height = maxHeight; - Chart.noConflict = function() { - root.Chart = previous; - return Chart; - }; + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } -}).call(this); + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { -(function() { - "use strict"; + var setContextLineSettings; - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; - var defaultConfig = { + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; - stacked: false, + helpers.each(this.labels, function(label, index) { + var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) - hover: { - mode: "label" - }, + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } - scales: { - xAxes: [{ - scaleType: "dataset", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: true, - }, + // Draw the label area + this.ctx.beginPath(); - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } - // scale numbers - beginAtZero: false, - override: null, + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) {} + + if (this.options.labels.show) { + // Draw the labels + } } - }], - }, + } + } + }); + Chart.scales.registerScaleType("dataset", DatasetScale); - }; - Chart.Type.extend({ - name: "Bar", - defaults: defaultConfig, - initialize: function() { +}).call(this); - var _this = this; +(function() { + "use strict"; - // Events - helpers.bindEvents(this, this.options.events, this.events); + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Rectangle({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - })); - }, this); + var LinearScale = Chart.Element.extend({ + calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + generateTicks: function(width, height) { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw - // The bar chart only supports a single x axis because the x axis is always a dataset axis - dataset.xAxisID = this.options.scales.xAxes[0].id; + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); } - }, this); + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); + var maxTicks; - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); + if (this.isHorizontal()) { + maxTicks = Math.min(11, Math.ceil(width / 50)); + } else { + // The factor of 2 used to scale the font size has been experimentally determined. + maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); + } - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); - // So that we animate from the baseline - this.resetElements(); + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. - // Update the chart with the latest data. - this.update(); - }, - resetElements: function() { - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); - var yScalePoint; + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); } + } - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScalePoint, + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + this.labels = []; - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), + helpers.each(this.ticks, function(tick, index, ticks) { + var label; - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.lables.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.labels.push(label ? label : ""); // empty string will not render so we're good }, this); }, - update: function(animationDuration) { - // Update the scale sizes - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScale.calculateBarY(datasetIndex, index), - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), - - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); - }, this); + getPixelForValue: function(value) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + var pixel; + var range = this.max - this.min; + if (this.isHorizontal()) { + pixel = this.left + (this.width / range * (value - this.min)); + } else { + // Bottom - top since pixels increase downard on a screen + pixel = this.bottom - (this.height / range * (value - this.min)); + } - this.render(animationDuration); + return pixel; }, - buildScale: function(labels) { - var self = this; + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.generateTicks(maxWidth, maxHeight); + this.buildLabels(); - // Function to determine the range of all the - var calculateYRange = function() { - this.min = null; - this.max = null; + var minSize = { + width: 0, + height: 0, + }; - var positiveValues = []; - var negativeValues = []; + if (this.isHorizontal()) { + minSize.width = maxWidth; // fill all the width - if (self.options.stacked) { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - positiveValues[index] = positiveValues[index] || 0; - negativeValues[index] = negativeValues[index] || 0; + // In a horizontal axis, we need some room for the scale to be drawn + // + // ----------------------------------------------------- + // | | | | | + // + minSize.height = this.options.gridLines.show ? 10 : 0; + } else { + minSize.height = maxHeight; // fill all the height - if (self.options.relativePoints) { - positiveValues[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - positiveValues[index] += value; - } - } - }, this); - } - }, this); + // In a vertical axis, we need some room for the scale to be drawn. + // The actual grid lines will be drawn on the chart area, however, we need to show + // ticks where the axis actually is. + // We will allocate 25px for this width + // | + // -| + // | + // | + // -| + // | + // | + // -| + minSize.width = this.options.gridLines.show ? 10 : 0; + } - var values = positiveValues.concat(negativeValues); - this.min = helpers.min(values); - this.max = helpers.max(values); + if (this.options.labels.show) { + // Don't bother fitting the labels if we are not showing them + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + if (this.isHorizontal()) { + // A horizontal axis is more constrained by the height. + var maxLabelHeight = maxHeight - minSize.height; + var labelHeight = 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(maxHeight, minSize.height + labelHeight); } else { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } + // A vertical axis is more constrained by the width. Labels are the dominant factor + // here, so get that length first + var maxLabelWidth = maxWidth - minSize.width; + var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); + if (largestTextWidth < maxLabelWidth) { + // We don't need all the room + minSize.width += largestTextWidth; + } else { + // Expand to max size + minSize.width = maxWidth; + } } - }; + } - // Map of scale ID to scale object so we can lookup later - this.scales = {}; + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - id: this.options.scales.xAxes[0].id, - calculateRange: function() { - this.labels = self.data.labels; - this.min = 0; - this.max = this.labels.length; - }, - calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.elements.bar.valueSpacing); - }, - calculateBarWidth: function(datasetCount) { - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.elements.bar.datasetSpacing); + var setContextLineSettings; + var hasZero; - if (self.options.stacked) { - return baseWidth; - } - return (baseWidth / datasetCount); - }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; - if (self.options.stacked) { - return xAbsolute + barWidth / 2; - } + if (this.isHorizontal()) { + if (this.options.gridLines.show) { + // Draw the horizontal line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; + var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.elements.bar.datasetSpacing) + barWidth / 2; - }, - }); - this.scales[xScale.id] = xScale; + helpers.each(this.ticks, function(tick, index) { + // Grid lines are vertical + var xValue = this.getPixelForValue(tick); - // Build up all the y scales - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - calculateRange: calculateYRange, - calculateBarBase: function(datasetIndex, index) { - var base = 0; + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the left if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } - if (self.options.stacked) { + xValue += helpers.aliasPixel(this.ctx.lineWidth); - var value = self.data.datasets[datasetIndex].data[index]; + // Draw the label area + this.ctx.beginPath(); - if (value < 0) { - for (var i = 0; i < datasetIndex; i++) { - if (self.data.datasets[i].yAxisID === this.id) { - base += self.data.datasets[i].data[index] < 0 ? self.data.datasets[i].data[index] : 0; - } - } - } else { - for (var j = 0; j < datasetIndex; j++) { - if (self.data.datasets[j].yAxisID === this.id) { - base += self.data.datasets[j].data[index] > 0 ? self.data.datasets[j].data[index] : 0; - } - } + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); } - return this.getPixelForValue(base); - } - - base = this.getPixelForValue(this.min); + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xValue, chartArea.top); + this.ctx.lineTo(xValue, chartArea.bottom); + } - if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { - base = this.getPixelForValue(0); - base += this.options.gridLines.lineWidth; - } else if (this.min < 0 && this.max < 0) { - // All values are negative. Use the top as the base - base = this.getPixelForValue(this.max); - } + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + }, this); + } - return base; + if (this.options.labels.show) { + // Draw the labels - }, - calculateBarY: function(datasetIndex, index) { + var labelStartY; - var value = self.data.datasets[datasetIndex].data[index]; - - if (self.options.stacked) { - - var sumPos = 0, - sumNeg = 0; - - for (var i = 0; i < datasetIndex; i++) { - if (self.data.datasets[i].data[index] < 0) { - sumNeg += self.data.datasets[i].data[index] || 0; - } else { - sumPos += self.data.datasets[i].data[index] || 0; - } - } - - if (value < 0) { - return this.getPixelForValue(sumNeg + value); - } else { - return this.getPixelForValue(sumPos + value); - } - - return this.getPixelForValue(value); - } - - var offset = 0; - - for (var j = datasetIndex; j < self.data.datasets.length; j++) { - if (j === datasetIndex && value) { - offset += value; - } else { - offset = offset + value; - } + if (this.options.position == "top") { + labelStartY = this.bottom - 10; + this.ctx.textBaseline = "bottom"; + } else { + // bottom side + labelStartY = this.top + 10; + this.ctx.textBaseline = "top"; } - return this.getPixelForValue(value); - }, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - //Draw all the bars for each dataset - this.eachElement(function(bar, index, datasetIndex) { - bar.transition(easingDecimal).draw(); - }, this); - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { + this.ctx.textAlign = "center"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + helpers.each(this.labels, function(label, index) { + var xValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, xValue, labelStartY); + }, this); + } + } else { + // Vertical + if (this.options.gridLines.show) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } + // Draw the vertical line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var xTickStart = this.options.position == "right" ? this.left : this.right - 5; + var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; - this.lastActive = this.lastActive || []; + helpers.each(this.ticks, function(tick, index) { + // Grid lines are horizontal + var yValue = this.getPixelForValue(tick); - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the bottom if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; // use boolean to indicate that we only want to do this once + } - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } + yValue += helpers.aliasPixel(this.ctx.lineWidth); - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } + // Draw the label area + this.ctx.beginPath(); - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + } - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(chartArea.left, yValue); + this.ctx.lineTo(chartArea.right, yValue); + } - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } + this.ctx.stroke(); + }, this); + } - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; + if (this.options.labels.show) { + // Draw the labels - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; + var labelStartX; - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); + if (this.options.position == "left") { + labelStartX = this.right - 10; + this.ctx.textAlign = "right"; + } else { + // right side + labelStartX = this.left + 5; + this.ctx.textAlign = "left"; } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } + this.ctx.textBaseline = "middle"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - this.tooltip.pivot(); - - // Hover animations - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; + helpers.each(this.labels, function(label, index) { + var yValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, labelStartX, yValue); + }, this); } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); } } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, + } }); + Chart.scales.registerScaleType("linear", LinearScale); }).call(this); @@ -2562,994 +2531,834 @@ var root = this, Chart = root.Chart, - //Cache a local reference to Chart.helpers helpers = Chart.helpers; - var defaultConfig = { - - animation: { - //Boolean - Whether we animate the rotation of the Doughnut - animateRotate: true, - - //Boolean - Whether we animate scaling the Doughnut from the centre - animateScale: false, - }, - - hover: { - mode: 'single' - }, - - //The percentage of the chart that we cut out of the middle. - - cutoutPercentage: 50, - - }; - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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 + var LinearRadialScale = Chart.Element.extend({ initialize: function() { - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - + this.size = helpers.min([this.height, this.width]); + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, - - calculateCircumference: function(dataset, value) { - if (dataset.total > 0) { - return (Math.PI * 2) * (value / dataset.total); + calculateCenterOffset: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + return (value - this.min) * scalingFactor; + }, + update: function() { + if (!this.options.lineArc) { + this.setScaleSize(); } else { - return 0; + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); } - }, - resetElements: function() { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // So that calculateCircumference works - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(slice, index) { - helpers.extend(slice, { - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, - innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); - slice.pivot(); - }, this); - - }, this); + this.buildYLabels(); }, - update: function(animationDuration) { - - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + calculateRange: helpers.noop, // overridden in chart + generateTicks: function() { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw - dataset.innerRadius = dataset.outerRadius - this.radiusLength; + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; - helpers.each(dataset.metaData, function(slice, index) { + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph - helpers.extend(slice, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, + var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); - // Desired view properties - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - circumference: this.calculateCircumference(dataset, dataset.data[index]), - outerRadius: dataset.outerRadius, - innerRadius: dataset.innerRadius, + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); - if (index === 0) { - slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - } else { - slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; } + } - slice._model.endAngle = slice._model.startAngle + slice._model.circumference; + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } - //Check to see if it's the last slice, if not get the next and update its start angle - if (index < dataset.data.length - 1) { - dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; - } + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } - slice.pivot(); - }, this); + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildYLabels: function() { + this.yLabels = []; - }, this); + helpers.each(this.ticks, function(tick, index, ticks) { + var label; - this.render(animationDuration); - }, - draw: function(easeDecimal) { - easeDecimal = easeDecimal || 1; - this.clear(); + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } - this.eachElement(function(slice) { - slice.transition(easeDecimal).draw(); + this.yLabels.push(label ? label : ""); }, this); - - this.tooltip.transition(easeDecimal).draw(); }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; -} else { - - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } + getCircumference: function() { + return ((Math.PI * 2) / this.valuesCount); + }, + setScaleSize: function() { + /* + * Right, this is really confusing and there is a lot of maths going on here + * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 + * + * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif + * + * Solution: + * + * We assume the radius of the polygon is half the size of the canvas at first + * at each index we check if the text overlaps. + * + * Where it does, we store that angle and that index. + * + * After finding the largest index and angle we calculate how much we need to remove + * from the shape radius to move the point inwards by that x. + * + * We average the left and right distances to get the maximum shape radius that can fit in the box + * along with labels. + * + * Once we have that, we can find the centre point for the chart, by taking the x text protrusion + * on each side, removing that from the size, halving it and adding the left x protrusion width. + * + * This will mean we have a shape fitted to the canvas, as large as it can be with the labels + * and position it in the most space efficient manner + * + * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif + */ - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); + // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. + // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points + var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), + pointPosition, + i, + textWidth, + halfTextWidth, + furthestRight = this.width, + furthestRightIndex, + furthestRightAngle, + furthestLeft = 0, + furthestLeftIndex, + furthestLeftAngle, + xProtrusionLeft, + xProtrusionRight, + radiusReductionRight, + radiusReductionLeft, + maxWidthRadius; + this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + for (i = 0; i < this.valuesCount; i++) { + // 5px to space the text slightly out - similar to what we do in the draw function. + pointPosition = this.getPointPosition(i, largestPossibleRadius); + textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { + value: this.labels[i] + })).width + 5; + if (i === 0 || i === this.valuesCount / 2) { + // If we're at index zero, or exactly the middle, we're at exactly the top/bottom + // of the radar chart, so text will be aligned centrally, so we'll half it and compare + // w/left and right text sizes + halfTextWidth = textWidth / 2; + if (pointPosition.x + halfTextWidth > furthestRight) { + furthestRight = pointPosition.x + halfTextWidth; + furthestRightIndex = i; + } + if (pointPosition.x - halfTextWidth < furthestLeft) { + furthestLeft = pointPosition.x - halfTextWidth; + furthestLeftIndex = i; + } + } else if (i < this.valuesCount / 2) { + // Less than half the values means we'll left align the text + if (pointPosition.x + textWidth > furthestRight) { + furthestRight = pointPosition.x + textWidth; + furthestRightIndex = i; + } + } else if (i > this.valuesCount / 2) { + // More than half the values means we'll right align the text + if (pointPosition.x - textWidth < furthestLeft) { + furthestLeft = pointPosition.x - textWidth; + furthestLeftIndex = i; + } } } - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; + xProtrusionLeft = furthestLeft; - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; + xProtrusionRight = Math.ceil(furthestRight - this.width); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } + furthestRightAngle = this.getIndexAngle(furthestRightIndex); - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; + furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; + radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } + radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + // Ensure we actually need to reduce the size of the chart + radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; + radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; - // Built in Tooltips - if (this.options.tooltips.enabled) { + this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; - // The usual updates - this.tooltip.initialize(); + //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) + this.setCenterPoint(radiusReductionLeft, radiusReductionRight); - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; + }, + setCenterPoint: function(leftMovement, rightMovement) { - helpers.extend(this.tooltip, { - _active: this.active, - }); + var maxRight = this.width - rightMovement - this.drawingArea, + maxLeft = leftMovement + this.drawingArea; - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } + this.xCenter = (maxLeft + maxRight) / 2; + // Always vertically in the centre as the text height doesn't change + this.yCenter = (this.height / 2); + }, + getIndexAngle: function(index) { + var angleMultiplier = (Math.PI * 2) / this.valuesCount; + // Start from the top instead of right, so remove a quarter of the circle - // Hover animations - this.tooltip.pivot(); + return index * angleMultiplier - (Math.PI / 2); + }, + getPointPosition: function(index, distanceFromCenter) { + var thisAngle = this.getIndexAngle(index); + return { + x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, + y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter + }; + }, + draw: function() { + if (this.options.display) { + var ctx = this.ctx; + helpers.each(this.yLabels, function(label, index) { + // Don't draw a centre value + if (index > 0) { + var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), + yHeight = this.yCenter - yCenterOffset, + pointPosition; - if (!this.animating) { - var changed; + // Draw circular lines around the scale + if (this.options.gridLines.show) { + ctx.strokeStyle = this.options.gridLines.color; + ctx.lineWidth = this.options.gridLines.lineWidth; - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; + if (this.options.lineArc) { + ctx.beginPath(); + ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); + ctx.closePath(); + ctx.stroke(); + } else { + ctx.beginPath(); + for (var i = 0; i < this.valuesCount; i++) { + pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); + if (i === 0) { + ctx.moveTo(pointPosition.x, pointPosition.y); + } else { + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + } + } + + if (this.options.labels.show) { + ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.showLabelBackdrop) { + var labelWidth = ctx.measureText(label).width; + ctx.fillStyle = this.options.labels.backdropColor; + ctx.fillRect( + this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, + yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, + labelWidth + this.options.labels.backdropPaddingX * 2, + this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 + ); + } + + ctx.textAlign = 'center'; + ctx.textBaseline = "middle"; + ctx.fillStyle = this.options.labels.fontColor; + ctx.fillText(label, this.xCenter, yHeight); + } } }, this); - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; + if (!this.options.lineArc) { + ctx.lineWidth = this.options.angleLines.lineWidth; + ctx.strokeStyle = this.options.angleLines.color; - var location = helpers.getRelativePosition(e); + for (var i = this.valuesCount - 1; i >= 0; i--) { + if (this.options.angleLines.show) { + var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); + ctx.beginPath(); + ctx.moveTo(this.xCenter, this.yCenter); + ctx.lineTo(outerPosition.x, outerPosition.y); + ctx.stroke(); + ctx.closePath(); + } + // Extra 3px out for some label spacing + var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); + ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + ctx.fillStyle = this.options.pointLabels.fontColor; - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; + var labelsCount = this.labels.length, + halfLabelsCount = this.labels.length / 2, + quarterLabelsCount = halfLabelsCount / 2, + upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), + exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); + if (i === 0) { + ctx.textAlign = 'center'; + } else if (i === halfLabelsCount) { + ctx.textAlign = 'center'; + } else if (i < halfLabelsCount) { + ctx.textAlign = 'left'; + } else { + ctx.textAlign = 'right'; + } - var location = helpers.getRelativePosition(e); + // Set the correct text baseline based on outer positioning + if (exactQuarter) { + ctx.textBaseline = 'middle'; + } else if (upperHalf) { + ctx.textBaseline = 'bottom'; + } else { + ctx.textBaseline = 'top'; + } - this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { - elements.push(slice); + ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + } } - }, this); - return elements; - },*/ + } + } }); + Chart.scales.registerScaleType("radialLinear", LinearRadialScale); - Chart.types.Doughnut.extend({ - name: "Pie", - defaults: helpers.merge(defaultConfig, { - cutoutPercentage: 0 - }) - }); }).call(this); +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ + + (function() { + "use strict"; var root = this, Chart = root.Chart, helpers = Chart.helpers; - var defaultConfig = { + Chart.defaults.global.animation = { + duration: 1000, + easing: "easeOutQuart", + onProgress: function() {}, + onComplete: function() {}, + }; - stacked: false, + Chart.Animation = Chart.Element.extend({ + currentStep: null, // the current animation step + numSteps: 60, // default number of steps + easing: "", // the easing to use for this animation + render: null, // render function used by the animation service - hover: { - mode: "label" - }, + onAnimationProgress: null, // user specified callback to fire on each step of the animation + onAnimationComplete: null, // user specified callback to fire when the animation finishes + }); - scales: { - xAxes: [{ - scaleType: "dataset", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale + Chart.animationService = { + frameDuration: 17, + animations: [], + dropFrames: 0, + addAnimation: function(chartInstance, animationObject, duration) { - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: false, - }, + if (!duration) { + chartInstance.animating = true; + } - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", + for (var index = 0; index < this.animations.length; ++index) { + if (this.animations[index].chartInstance === chartInstance) { + // replacing an in progress animation + this.animations[index].animationObject = animationObject; + return; + } + } - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, + this.animations.push({ + chartInstance: chartInstance, + animationObject: animationObject + }); - // scale numbers - beginAtZero: false, - override: null, + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (this.animations.length == 1) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + }, + // Cancel the animation for a given chart instance + cancelAnimation: function(chartInstance) { + var index = helpers.findNextWhere(this.animations, function(animationWrapper) { + return animationWrapper.chartInstance === chartInstance; + }); - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } - }], + if (index) { + this.animations.splice(index, 1); + chartInstance.animating = false; + } }, - }; + // calls startDigest with the proper context + digestWrapper: function() { + Chart.animationService.startDigest.call(Chart.animationService); + }, + startDigest: function() { + var startTime = Date.now(); + var framesToDrop = 0; - Chart.Type.extend({ - name: "Line", - defaults: defaultConfig, - initialize: function() { + if (this.dropFrames > 1) { + framesToDrop = Math.floor(this.dropFrames); + this.dropFrames -= framesToDrop; + } - var _this = this; + for (var i = 0; i < this.animations.length; i++) { - // Events - helpers.bindEvents(this, this.options.events, this.events); + if (this.animations[i].animationObject.currentStep === null) { + this.animations[i].animationObject.currentStep = 0; + } - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { + this.animations[i].animationObject.currentStep += 1 + framesToDrop; + if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { + this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; + } - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); + this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); - dataset.metaData = []; + if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { + // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; + this.animations.splice(i, 1); + // Keep the index in place to offset the splice + i--; + } + } - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); + var endTime = Date.now(); + var delay = endTime - startTime - this.frameDuration; + var frameDelay = delay / this.frameDuration; - }, this); + if (frameDelay > 1) { + this.dropFrames += frameDelay; + } - // The line chart onlty supports a single x axis because the x axis is always a dataset axis - dataset.xAxisID = this.options.scales.xAxes[0].id; + // Do we have more stuff to animate? + if (this.animations.length > 0) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + } + }; - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } +}).call(this); - }, this); +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); +(function() { - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + "use strict"; - // Reset so that we animation from the baseline - this.resetElements(); + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[index]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[index]; - }, - resetElements: function() { - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + Chart.defaults.global.tooltips = { + enabled: true, + custom: null, + backgroundColor: "rgba(0,0,0,0.8)", + fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + fontSize: 10, + fontStyle: "normal", + fontColor: "#fff", + titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + titleFontSize: 12, + titleFontStyle: "bold", + titleFontColor: "#fff", + yPadding: 6, + xPadding: 6, + caretSize: 8, + cornerRadius: 6, + xOffset: 10, + template: [ + '<% if(label){ %>', + '<%=label %>: ', + '<% } %>', + '<%=value %>', + ].join(''), + multiTemplate: [ + '<%if (datasetLabel){ %>', + '<%=datasetLabel %>: ', + '<% } %>', + '<%=value %>' + ].join(''), + multiKeyBackground: '#fff', + }; - var yScalePoint; + Chart.Tooltip = Chart.Element.extend({ + initialize: function() { + var options = this._options; + helpers.extend(this, { + _model: { + // Positioning + xPadding: options.tooltips.xPadding, + yPadding: options.tooltips.yPadding, + xOffset: options.tooltips.xOffset, - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } + // Labels + textColor: options.tooltips.fontColor, + _fontFamily: options.tooltips.fontFamily, + _fontStyle: options.tooltips.fontStyle, + fontSize: options.tooltips.fontSize, - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, + // Title + titleTextColor: options.tooltips.titleFontColor, + _titleFontFamily: options.tooltips.titleFontFamily, + _titleFontStyle: options.tooltips.titleFontStyle, + titleFontSize: options.tooltips.titleFontSize, - // Desired view properties - _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales - y: yScalePoint, + // Appearance + caretHeight: options.tooltips.caretSize, + cornerRadius: options.tooltips.cornerRadius, + backgroundColor: options.tooltips.backgroundColor, + opacity: 0, + legendColorBackground: options.tooltips.multiKeyBackground, + }, + }); + }, + update: function() { - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, + var ctx = this._chart.ctx; - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); + switch (this._options.hover.mode) { + case 'single': + helpers.extend(this._model, { + text: template(this._options.tooltips.template, { + // These variables are available in the template function. Add others here + element: this._active[0], + value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], + label: this._data.labels ? this._data.labels[this._active[0]._index] : '', + }), + }); - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); + var tooltipPosition = this._active[0].tooltipPosition(); + helpers.extend(this._model, { + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + caretPadding: tooltipPosition.padding + }); - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; + break; - // Prevent the bezier going outside of the bounds of the graph + case 'label': - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } + // Tooltip Content - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } + var dataArray, + dataIndex; - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function(animationDuration) { + var labels = [], + colors = []; - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + for (var i = this._data.datasets.length - 1; i >= 0; i--) { + dataArray = this._data.datasets[i].metaData; + dataIndex = indexOf(dataArray, this._active[0]); + if (dataIndex !== -1) { + break; + } + } - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var yScale = this.scales[dataset.yAxisID]; - var scaleBase; + var medianPosition = (function(index) { + // Get all the points at that particular index + var elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this._data.datasets, function(dataset) { + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { + elements.push(dataCollection[dataIndex]); + } + }, this); - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } + // Reverse labels if stacked + helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { + xPositions.push(element._view.x); + yPositions.push(element._view.y); - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); + //Include any colour information about the element + labels.push(helpers.template(this._options.tooltips.multiTemplate, { + // These variables are available in the template function. Add others here + element: element, + datasetLabel: this._data.datasets[element._datasetIndex].label, + value: this._data.datasets[element._datasetIndex].data[element._index], + })); + colors.push({ + fill: element._view.backgroundColor, + stroke: element._view.borderColor + }); - dataset.metaDataset.pivot(); - }); + }, this); - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + yMin = min(yPositions); + yMax = max(yPositions); - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, + xMin = min(xPositions); + xMax = max(xPositions); - // Desired view properties - _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales - y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), + return { + x: (xMin > this._chart.width / 2) ? xMin : xMax, + y: (yMin + yMax) / 2, + }; + }).call(this, dataIndex); - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, + // Apply for now + helpers.extend(this._model, { + x: medianPosition.x, + y: medianPosition.y, + labels: labels, + title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', + legendColors: colors, + legendBackgroundColor: this._options.tooltips.multiKeyBackground, + }); - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); + // Calculate Appearance Tweaks - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); + this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; + var titleWidth = ctx.measureText(this.title).width, + //Label has a legend square as well so account for this. + labelWidth = longestText(ctx, this.font, labels) + this._model.fontSize + 3, + longestTextWidth = max([labelWidth, titleWidth]); - // Prevent the bezier going outside of the bounds of the graph + this._model.width = longestTextWidth + (this._model.xPadding * 2); - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } + var halfHeight = this._model.height / 2; - // Now pivot the point for animation - point.pivot(); - }, this); + //Check to ensure the height will fit on the canvas + if (this._model.y - halfHeight < 0) { + this._model.y = halfHeight; + } else if (this._model.y + halfHeight > this._chart.height) { + this._model.y = this._chart.height - halfHeight; + } - this.render(animationDuration); + //Decide whether to align left or right based on position on canvas + if (this._model.x > this._chart.width / 2) { + this._model.x -= this._model.xOffset + this._model.width; + } else { + this._model.x += this._model.xOffset; + } + break; + } + + return this; }, - buildScale: function() { - var self = this; + draw: function() { - // Function to determine the range of all the - var calculateYRange = function() { - this.min = null; - this.max = null; + var ctx = this._chart.ctx; + var vm = this._view; - var positiveValues = []; - var negativeValues = []; + switch (this._options.hover.mode) { + case 'single': - if (self.options.stacked) { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - positiveValues[index] = positiveValues[index] || 0; - negativeValues[index] = negativeValues[index] || 0; + ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - if (self.options.relativePoints) { - positiveValues[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - positiveValues[index] += value; - } - } - }, this); - } - }, this); + vm.xAlign = "center"; + vm.yAlign = "above"; - var values = positiveValues.concat(negativeValues); - this.min = helpers.min(values); - this.max = helpers.max(values); - } else { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } + //Distance between the actual element.y position and the start of the tooltip caret + var caretPadding = vm.caretPadding || 2; - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }; + var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, + tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - // Map of scale ID to scale object so we can lookup later - this.scales = {}; + if (vm.x + tooltipWidth / 2 > this._chart.width) { + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth / 2 < 0) { + vm.xAlign = "right"; + } - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - calculateRange: function() { - this.labels = self.data.labels; - this.min = 0; - this.max = this.labels.length; - }, - id: this.options.scales.xAxes[0].id, - }); - this.scales[xScale.id] = xScale; + if (vm.y - tooltipHeight < 0) { + vm.yAlign = "below"; + } - // Build up all the y scales - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - calculateRange: calculateYRange, - getPointPixelForValue: function(value, index, datasetIndex) { - if (self.options.stacked) { - var offsetPos = 0; - var offsetNeg = 0; + var tooltipX = vm.x - tooltipWidth / 2, + tooltipY = vm.y - tooltipHeight; - for (var i = 0; i < datasetIndex; ++i) { - if (self.data.datasets[i].data[index] < 0) { - offsetNeg += self.data.datasets[i].data[index]; - } else { - offsetPos += self.data.datasets[i].data[index]; - } - } + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - if (value < 0) { - return this.getPixelForValue(offsetNeg + value); - } else { - return this.getPixelForValue(offsetPos + value); - } - } else { - return this.getPixelForValue(value); + // Custom Tooltips + if (this._custom) { + this._custom(this._view); + } else { + switch (vm.yAlign) { + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; } - }, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - this.clear(); + switch (vm.xAlign) { + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); + helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { + ctx.fill(); - var dataset = this.data.datasets[i]; + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); + } + break; + case 'label': - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; + helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + ctx.fill(); + ctx.closePath(); - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); + ctx.font = helpers.fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); + ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); + ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + helpers.each(vm.labels, function(label, index) { + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); - // Built in Tooltips - if (this.options.tooltips.enabled) { + //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) + //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + //Instead we'll make a white filled block to put the legendColour palette over. - // The usual updates - this.tooltip.initialize(); + ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; + ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); - helpers.extend(this.tooltip, { - _active: this.active, - }); - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } + }, this); + break; } + }, + getLineHeight: function(index) { + var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, + afterTitleIndex = index - 1; - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } + //If the index is zero, we're getting the title + if (index === 0) { + return baseLineHeight + this._view.titleFontSize / 2; + } else { + return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; } - // Remember Last Active - this.lastActive = this.active; - return this; }, }); - }).call(this); (function() { @@ -3557,117 +3366,115 @@ var root = this, Chart = root.Chart, - //Cache a local reference to Chart.helpers helpers = Chart.helpers; var defaultConfig = { - scale: { - scaleType: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - - lineArc: true, + stacked: false, + valueSpacing: 5, + datasetSpacing: 1, - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, + hover: { + mode: "label" + }, - // scale numbers - beginAtZero: true, + scales: { + xAxes: [{ + scaleType: "dataset", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: true, + }, - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, + // scale numbers + beginAtZero: false, + override: null, - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - } + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], }, - //Boolean - Whether to animate the rotation of the chart - animateRotate: true, }; Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "PolarArea", - //Providing a defaults will also register the deafults in the chart namespace + name: "Bar", defaults: defaultConfig, - //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() { - // Scale setup - var self = this; - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.scaleType); - this.scale = new ScaleClass({ - options: this.options.scale, - lineArc: true, - width: this.chart.width, - height: this.chart.height, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - valuesCount: this.data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets[0].data, function(value) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }); - - helpers.bindEvents(this, this.options.events, this.events); + var _this = this; - //Set up tooltip events on the chart + // Events helpers.bindEvents(this, this.options.events, this.events); //Create a new bar for each piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.metaData = []; helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ + dataset.metaData.push(new Chart.Rectangle({ _chart: this.chart, _datasetIndex: datasetIndex, _index: index, - _model: {} })); }, this); + + // The bar chart only supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; + + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } }, this); + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ _chart: this.chart, @@ -3675,135 +3482,325 @@ _options: this.options, }, this); - // Fit the scale before we animate - this.updateScaleRange(); - this.scale.calculateRange(); + // Need to fit scales before we reset elements. Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - // so that we animate nicely + // So that we animate from the baseline this.resetElements(); // Update the chart with the latest data. this.update(); - - }, - updateScaleRange: function() { - helpers.extend(this.scale, { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2 - }); }, resetElements: function() { - var circumference = 1 / this.data.datasets[0].data.length * 2; + // Update the points + this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { + var yScalePoint; - var value = this.data.datasets[0].data[index]; + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } - helpers.extend(slice, { + helpers.extend(bar, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, _index: index, + + // Desired view properties _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScalePoint, - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, }, }); - - slice.pivot(); + bar.pivot(); }, this); }, update: function(animationDuration) { - - this.updateScaleRange(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - + // Update the scale sizes Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - var circumference = 1 / this.data.datasets[0].data.length * 2; - - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - - var value = this.data.datasets[0].data[index]; - - var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); + // Update the points + this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - helpers.extend(slice, { + helpers.extend(bar, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, _index: index, + + // Desired view properties _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: this.scale.calculateCenterOffset(value), - startAngle: startAngle, - endAngle: endAngle, + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScale.calculateBarY(datasetIndex, index), - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.bar.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.bar.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.bar.borderWidth), - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, }, }); - slice.pivot(); - - console.log(slice); - + bar.pivot(); }, this); + this.render(animationDuration); }, - draw: function(ease) { - var easingDecimal = ease || 1; - - this.clear(); + buildScale: function(labels) { + var self = this; - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - slice.transition(easingDecimal).draw(); - }, this); + // Function to determine the range of all the + var calculateYRange = function() { + this.min = null; + this.max = null; - this.scale.draw(); + var positiveValues = []; + var negativeValues = []; - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { + if (self.options.stacked) { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; - // If exiting chart - if (e.type == 'mouseout') { - return this; - } + if (self.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); + } + }, this); - this.lastActive = this.lastActive || []; + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + } else { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }; + + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); + var xScale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scales.xAxes[0], + id: this.options.scales.xAxes[0].id, + calculateRange: function() { + this.labels = self.data.labels; + this.min = 0; + this.max = this.labels.length; + }, + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.elements.bar.valueSpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.elements.bar.datasetSpacing); + + if (self.options.stacked) { + return baseWidth; + } + return (baseWidth / datasetCount); + }, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); + + if (self.options.stacked) { + return xAbsolute + barWidth / 2; + } + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.elements.bar.datasetSpacing) + barWidth / 2; + }, + }); + this.scales[xScale.id] = xScale; + + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + calculateRange: calculateYRange, + calculateBarBase: function(datasetIndex, index) { + var base = 0; + + if (self.options.stacked) { + + var value = self.data.datasets[datasetIndex].data[index]; + + if (value < 0) { + for (var i = 0; i < datasetIndex; i++) { + if (self.data.datasets[i].yAxisID === this.id) { + base += self.data.datasets[i].data[index] < 0 ? self.data.datasets[i].data[index] : 0; + } + } + } else { + for (var j = 0; j < datasetIndex; j++) { + if (self.data.datasets[j].yAxisID === this.id) { + base += self.data.datasets[j].data[index] > 0 ? self.data.datasets[j].data[index] : 0; + } + } + } + + return this.getPixelForValue(base); + } + + base = this.getPixelForValue(this.min); + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.getPixelForValue(0); + base += this.options.gridLines.lineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.getPixelForValue(this.max); + } + + return base; + + }, + calculateBarY: function(datasetIndex, index) { + + var value = self.data.datasets[datasetIndex].data[index]; + + if (self.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (self.data.datasets[i].data[index] < 0) { + sumNeg += self.data.datasets[i].data[index] || 0; + } else { + sumPos += self.data.datasets[i].data[index] || 0; + } + } + + if (value < 0) { + return this.getPixelForValue(sumNeg + value); + } else { + return this.getPixelForValue(sumPos + value); + } + + return this.getPixelForValue(value); + } + + var offset = 0; + + for (var j = datasetIndex; j < self.data.datasets.length; j++) { + if (j === datasetIndex && value) { + offset += value; + } else { + offset = offset + value; + } + } + + return this.getPixelForValue(value); + }, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + //Draw all the bars for each dataset + this.eachElement(function(bar, index, datasetIndex) { + bar.transition(easingDecimal).draw(); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); // On Hover hook if (this.options.hover.onHover) { @@ -3825,18 +3822,18 @@ dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; index = this.lastActive[0]._index; - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; index = this.lastActive[i]._index; - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.bar.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.bar.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.bar.borderWidth); } break; case 'dataset': @@ -3853,20 +3850,18 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': @@ -3899,9 +3894,9 @@ } - // Hover animations this.tooltip.pivot(); + // Hover animations if (!this.animating) { var changed; @@ -3917,7 +3912,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hover.animationDuration); + this.render(this.options.hoverAnimationDuration); } } @@ -3925,32 +3920,9 @@ this.lastActive = this.active; return this; }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ }); + }).call(this); (function() { @@ -3958,120 +3930,54 @@ var root = this, Chart = root.Chart, + //Cache a local reference to Chart.helpers helpers = Chart.helpers; + var defaultConfig = { + animation: { + //Boolean - Whether we animate the rotation of the Doughnut + animateRotate: true, - Chart.Type.extend({ - name: "Radar", - defaults: { + //Boolean - Whether we animate scaling the Doughnut from the centre + animateScale: false, + }, - scale: { - scaleType: "radialLinear", - display: true, + hover: { + mode: 'single' + }, - //Boolean - Whether to animate scaling the chart from the centre - animate: false, + //The percentage of the chart that we cut out of the middle. - lineArc: false, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, - - angleLines: { - show: true, - color: "rgba(0,0,0,.1)", - lineWidth: 1 - }, - - // scale numbers - beginAtZero: true, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - }, - - pointLabels: { - //String - Point label font declaration - fontFamily: "'Arial'", - - //String - Point label font weight - fontStyle: "normal", - - //Number - Point label font size in pixels - fontSize: 10, - - //String - Point label font colour - fontColor: "#666", - }, - }, - - elements: { - line: { - tension: 0, // no bezier in radar - } - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + cutoutPercentage: 50, - }, + }; + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "Doughnut", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { - // Events + + //Set up tooltip events on the chart helpers.bindEvents(this, this.options.events, this.events); - // Create a new line and its points for each dataset and piece of data + //Create a new bar for each piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - _loop: true - }); - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, _datasetIndex: datasetIndex, _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, + _model: {} })); - }, this); }, this); - // Build the scale. - this.buildScale(); - // Create tooltip instance exclusively for this chart with some defaults. this.tooltip = new Chart.Tooltip({ _chart: this.chart, @@ -4079,273 +3985,158 @@ _options: this.options, }, this); - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline this.resetElements(); - // Update that shiz + // Update the chart with the latest data. this.update(); + }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[0]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[collection.length - 1]; + + calculateCircumference: function(dataset, value) { + if (dataset.total > 0) { + return (Math.PI * 2) * (value / dataset.total); + } else { + return 0; + } }, resetElements: function() { + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _scale: this.scale, + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + // So that calculateCircumference works + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); - // Desired view properties - _model: { - x: this.scale.xCenter, - y: this.scale.yCenter, + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + dataset.innerRadius = dataset.outerRadius - this.radiusLength; - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, + helpers.each(dataset.metaData, function(slice, index) { + helpers.extend(slice, { + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, + innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, - // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); - point._model.controlPointPreviousX = this.scale.xCenter; - point._model.controlPointPreviousY = this.scale.yCenter; - point._model.controlPointNextX = this.scale.xCenter; - point._model.controlPointNextY = this.scale.yCenter; + slice.pivot(); + }, this); - // Now pivot the point for animation - point.pivot(); }, this); }, update: function(animationDuration) { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var scaleBase; + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.slice.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - if (this.scale.min < 0 && this.scale.max < 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.max); - } else if (this.scale.min > 0 && this.scale.max > 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.min); - } else { - scaleBase = this.scale.getPointPosition(0, 0); - } - helpers.extend(dataset.metaDataset, { - // Utility - _datasetIndex: datasetIndex, + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // Data - _children: dataset.metaData, + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); - // Model - _model: { - // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: this.scale.top, - scaleBottom: this.scale.bottom, - scaleZero: scaleBase, - }, - }); + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - dataset.metaDataset.pivot(); - }); + dataset.innerRadius = dataset.outerRadius - this.radiusLength; - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); + helpers.each(dataset.metaData, function(slice, index) { - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, + helpers.extend(slice, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, - // Desired view properties - _model: { - x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: pointPosition.y, + // Desired view properties + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + circumference: this.calculateCircumference(dataset, dataset.data[index]), + outerRadius: dataset.outerRadius, + innerRadius: dataset.innerRadius, - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor), + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); + if (index === 0) { + slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + } else { + slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; + } - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; + slice._model.endAngle = slice._model.startAngle + slice._model.circumference; - // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } + //Check to see if it's the last slice, if not get the next and update its start angle + if (index < dataset.data.length - 1) { + dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; + } - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } + slice.pivot(); + }, this); - // Now pivot the point for animation - point.pivot(); }, this); this.render(animationDuration); }, - buildScale: function() { - var self = this; - - var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); - this.scale = new ScaleConstructor({ - options: this.options.scale, - height: this.chart.height, - width: this.chart.width, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - labels: this.data.labels, - valuesCount: this.data.datasets[0].data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }); - - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - }, - draw: function(ease) { - var easingDecimal = ease || 1; + draw: function(easeDecimal) { + easeDecimal = easeDecimal || 1; this.clear(); - // Draw all the scales - this.scale.draw(this.chartArea); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } + this.eachElement(function(slice) { + slice.transition(easeDecimal).draw(); + }, this); - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); + this.tooltip.transition(easeDecimal).draw(); }, events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (e.type == 'mouseout') { + this.active = []; +} else { + + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } // On Hover hook if (this.options.hover.onHover) { @@ -4367,20 +4158,18 @@ dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; index = this.lastActive[0]._index; - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; index = this.lastActive[i]._index; - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); } break; case 'dataset': @@ -4397,20 +4186,18 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); break; case 'label': for (var i = 0; i < this.active.length; i++) { dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); } break; case 'dataset': @@ -4420,6 +4207,7 @@ } } + // Built in Tooltips if (this.options.tooltips.enabled) { @@ -4441,6 +4229,7 @@ } } + // Hover animations this.tooltip.pivot(); @@ -4467,7 +4256,39 @@ this.lastActive = this.active; return this; }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); + + Chart.types.Doughnut.extend({ + name: "Pie", + defaults: helpers.merge(defaultConfig, { + cutoutPercentage: 0 + }) }); + }).call(this); (function() { @@ -4477,1200 +4298,1544 @@ Chart = root.Chart, helpers = Chart.helpers; - // The scale service is used to resize charts along with all of their axes. We make this as - // a service where scales are registered with their respective charts so that changing the - // scales does not require - Chart.scaleService = { - // The interesting function - fitScalesForChart: function(chartInstance, width, height) { - var xPadding = 5; - var yPadding = 5; - - if (chartInstance) { - var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "left"; - }); - var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "right"; - }); - var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "top"; - }); - var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "bottom"; - }); + var defaultConfig = { - // Adjust the padding to take into account displaying labels - if (topScales.length === 0 || bottomScales.length === 0) { - var maxFontHeight = 0; + stacked: false, - var maxFontHeightFunction = function(scaleInstance) { - if (scaleInstance.options.labels.show) { - // Only consider font sizes for axes that actually show labels - maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); - } - }; - - helpers.each(leftScales, maxFontHeightFunction); - helpers.each(rightScales, maxFontHeightFunction); - - if (topScales.length === 0) { - // Add padding so that we can handle drawing the top nicely - yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides - } + hover: { + mode: "label" + }, - if (bottomScales.length === 0) { - // Add padding so that we can handle drawing the bottom nicely - yPadding += 1.5 * maxFontHeight; - } - } + scales: { + xAxes: [{ + scaleType: "dataset", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale - // Essentially we now have any number of scales on each of the 4 sides. - // Our canvas looks like the following. - // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and - // B1 is the bottom axis - // |------------------------------------------------------| - // | | T1 | | - // |----|-----|-------------------------------------|-----| - // | | | | | - // | L1 | L2 | Chart area | R1 | - // | | | | | - // | | | | | - // |----|-----|-------------------------------------|-----| - // | | B1 | | - // | | | | - // |------------------------------------------------------| + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, - // What we do to find the best sizing, we do the following - // 1. Determine the minimum size of the chart area. - // 2. Split the remaining width equally between each vertical axis - // 3. Split the remaining height equally between each horizontal axis - // 4. Give each scale the maximum size it can be. The scale will return it's minimum size - // 5. Adjust the sizes of each axis based on it's minimum reported size. - // 6. Refit each axis - // 7. Position each axis in the final location - // 8. Tell the chart the final location of the chart area + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + scaleType: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", - // Step 1 - var chartWidth = width / 2; // min 50% - var chartHeight = height / 2; // min 50% - var aspectRatio = chartHeight / chartWidth; - var screenAspectRatio; + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, - if (chartInstance.options.maintainAspectRatio) { - screenAspectRatio = height / width; + // scale numbers + beginAtZero: false, + override: null, - if (aspectRatio != screenAspectRatio) { - chartHeight = chartWidth * screenAspectRatio; - aspectRatio = screenAspectRatio; - } + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", } + }], + }, + }; - chartWidth -= (2 * xPadding); - chartHeight -= (2 * yPadding); - // Step 2 - var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); + Chart.Type.extend({ + name: "Line", + defaults: defaultConfig, + initialize: function() { - // Step 3 - var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); + var _this = this; - // Step 4; - var minimumScaleSizes = []; + // Events + helpers.bindEvents(this, this.options.events, this.events); - var verticalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); - minimumScaleSizes.push({ - horizontal: false, - minSize: minSize, - scale: scaleInstance, - }); - }; + // Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { - var horizontalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); - minimumScaleSizes.push({ - horizontal: true, - minSize: minSize, - scale: scaleInstance, - }); - }; + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); - // vertical scales - helpers.each(leftScales, verticalScaleMinSizeFunction); - helpers.each(rightScales, verticalScaleMinSizeFunction); + dataset.metaData = []; - // horizontal scales - helpers.each(topScales, horizontalScaleMinSizeFunction); - helpers.each(bottomScales, horizontalScaleMinSizeFunction); + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); - // Step 5 - var maxChartHeight = height - (2 * yPadding); - var maxChartWidth = width - (2 * xPadding); + }, this); - helpers.each(minimumScaleSizes, function(wrapper) { - if (wrapper.horizontal) { - maxChartHeight -= wrapper.minSize.height; - } else { - maxChartWidth -= wrapper.minSize.width; - } - }); + // The line chart onlty supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; - // At this point, maxChartHeight and maxChartWidth are the size the chart area could - // be if the axes are drawn at their minimum sizes. + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } - // Step 6 - var verticalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); + }, this); - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight); - } - }; + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); - var horizontalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); - var scaleMargin = { - left: totalLeftWidth, - right: totalRightWidth, - top: 0, - bottom: 0, - }; + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - if (wrapper) { - scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); - } - }; + // Reset so that we animation from the baseline + this.resetElements(); - var totalLeftWidth = xPadding; - var totalRightWidth = xPadding; - var totalTopHeight = yPadding; - var totalBottomHeight = yPadding; + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[index]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[index]; + }, + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - helpers.each(leftScales, verticalScaleFitFunction); - helpers.each(rightScales, verticalScaleFitFunction); + var yScalePoint; - // Figure out how much margin is on the left and right of the horizontal axes - helpers.each(leftScales, function(scaleInstance) { - totalLeftWidth += scaleInstance.width; - }); + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } - helpers.each(rightScales, function(scaleInstance) { - totalRightWidth += scaleInstance.width; - }); + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, - helpers.each(topScales, horizontalScaleFitFunction); - helpers.each(bottomScales, horizontalScaleFitFunction); + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScalePoint, - helpers.each(topScales, function(scaleInstance) { - totalTopHeight += scaleInstance.height; - }); - helpers.each(bottomScales, function(scaleInstance) { - totalBottomHeight += scaleInstance.height; + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + }, }); + }, this); - // Let the left scale know the final margin - helpers.each(leftScales, function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); - var scaleMargin = { - left: 0, - right: 0, - top: totalTopHeight, - bottom: totalBottomHeight - }; + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); - } - }); + // Prevent the bezier going outside of the bounds of the graph - helpers.each(rightScales, function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } - var scaleMargin = { - left: 0, - right: 0, - top: totalTopHeight, - bottom: totalBottomHeight - }; + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); - } - }); + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function(animationDuration) { - // Step 7 - // Position the scales - var left = xPadding; - var top = yPadding; - var right = 0; - var bottom = 0; + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - var verticalScalePlacer = function(scaleInstance) { - scaleInstance.left = left; - scaleInstance.right = left + scaleInstance.width; - scaleInstance.top = totalTopHeight; - scaleInstance.bottom = totalTopHeight + maxChartHeight; + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + var yScale = this.scales[dataset.yAxisID]; + var scaleBase; - // Move to next point - left = scaleInstance.right; - }; + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } - var horizontalScalePlacer = function(scaleInstance) { - scaleInstance.left = totalLeftWidth; - scaleInstance.right = totalLeftWidth + maxChartWidth; - scaleInstance.top = top; - scaleInstance.bottom = top + scaleInstance.height; + helpers.extend(dataset.metaDataset, { + // Utility + _scale: yScale, + _datasetIndex: datasetIndex, + // Data + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.options.elements.line.tension), + backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.options.elements.line.backgroundColor), + borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.options.elements.line.borderWidth), + borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.options.elements.line.borderColor), + fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill), + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: scaleBase, + }, + }); - // Move to next point - top = scaleInstance.bottom; - }; + dataset.metaDataset.pivot(); + }); - helpers.each(leftScales, verticalScalePlacer); - helpers.each(topScales, horizontalScalePlacer); + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - // Account for chart width and height - left += maxChartWidth; - top += maxChartHeight; + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, - helpers.each(rightScales, verticalScalePlacer); - helpers.each(bottomScales, horizontalScalePlacer); + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - // Step 8 - chartInstance.chartArea = { - left: totalLeftWidth, - top: totalTopHeight, - right: totalLeftWidth + maxChartWidth, - bottom: totalTopHeight + maxChartHeight, - }; - } - } - }; + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, - // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then - // use the new chart options to grab the correct scale - Chart.scales = { - constructors: {}, - // Use a registration function so that we can move to an ES6 map when we no longer need to support - // old browsers - registerScaleType: function(scaleType, scaleConstructor) { - this.constructors[scaleType] = scaleConstructor; - }, - getScaleConstructor: function(scaleType) { - return this.constructors.hasOwnProperty(scaleType) ? this.constructors[scaleType] : undefined; - } - }; + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); - var LinearScale = Chart.Element.extend({ - calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - generateTicks: function(width, height) { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); - } - } else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; - var maxTicks; + // Prevent the bezier going outside of the bounds of the graph - if (this.isHorizontal()) { - maxTicks = Math.min(11, Math.ceil(width / 50)); + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; } else { - // The factor of 2 used to scale the font size has been experimentally determined. - maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); + point._model.controlPointNextY = controlPoints.next.y; } - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); + // Now pivot the point for animation + point.pivot(); + }, this); - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } + this.render(animationDuration); + }, + buildScale: function() { + var self = this; - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; + // Function to determine the range of all the + var calculateYRange = function() { + this.min = null; + this.max = null; - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - } - } + var positiveValues = []; + var negativeValues = []; - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } + if (self.options.stacked) { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, - buildLabels: function() { - // We assume that this has been run after ticks have been generated. We try to figure out - // a label for each tick. - this.labels = []; + if (self.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); + } + }, this); - helpers.each(this.ticks, function(tick, index, ticks) { - var label; + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); + } else { + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.lables.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick - }); + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); } + }; - this.labels.push(label ? label : ""); // empty string will not render so we're good - }, this); - }, - getPixelForValue: function(value) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - var pixel; - var range = this.max - this.min; + // Map of scale ID to scale object so we can lookup later + this.scales = {}; - if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.min)); - } else { - // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.min)); - } + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType); + var xScale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scales.xAxes[0], + calculateRange: function() { + this.labels = self.data.labels; + this.min = 0; + this.max = this.labels.length; + }, + id: this.options.scales.xAxes[0].id, + }); + this.scales[xScale.id] = xScale; - return pixel; + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.scaleType); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + calculateRange: calculateYRange, + getPointPixelForValue: function(value, index, datasetIndex) { + if (self.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + + for (var i = 0; i < datasetIndex; ++i) { + if (self.data.datasets[i].data[index] < 0) { + offsetNeg += self.data.datasets[i].data[index]; + } else { + offsetPos += self.data.datasets[i].data[index]; + } + } + + if (value < 0) { + return this.getPixelForValue(offsetNeg + value); + } else { + return this.getPixelForValue(offsetPos + value); + } + } else { + return this.getPixelForValue(value); + } + }, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { - this.calculateRange(); - this.generateTicks(maxWidth, maxHeight); - this.buildLabels(); + draw: function(ease) { - var minSize = { - width: 0, - height: 0, - }; + var easingDecimal = ease || 1; + this.clear(); - if (this.isHorizontal()) { - minSize.width = maxWidth; // fill all the width + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); - // In a horizontal axis, we need some room for the scale to be drawn - // - // ----------------------------------------------------- - // | | | | | - // - minSize.height = this.options.gridLines.show ? 10 : 0; - } else { - minSize.height = maxHeight; // fill all the height + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { - // In a vertical axis, we need some room for the scale to be drawn. - // The actual grid lines will be drawn on the chart area, however, we need to show - // ticks where the axis actually is. - // We will allocate 25px for this width - // | - // -| - // | - // | - // -| - // | - // | - // -| - minSize.width = this.options.gridLines.show ? 10 : 0; - } + var dataset = this.data.datasets[i]; - if (this.options.labels.show) { - // Don't bother fitting the labels if we are not showing them - var labelFont = helpers.fontString(this.options.labels.fontSize, - this.options.labels.fontStyle, this.options.labels.fontFamily); + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); - if (this.isHorizontal()) { - // A horizontal axis is more constrained by the height. - var maxLabelHeight = maxHeight - minSize.height; - var labelHeight = 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(maxHeight, minSize.height + labelHeight); - } else { - // A vertical axis is more constrained by the width. Labels are the dominant factor - // here, so get that length first - var maxLabelWidth = maxWidth - minSize.width; - var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); - if (largestTextWidth < maxLabelWidth) { - // We don't need all the room - minSize.width += largestTextWidth; - } else { - // Expand to max size - minSize.width = maxWidth; - } - } + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); } - this.width = minSize.width; - this.height = minSize.height; - return minSize; + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - var hasZero; + events: function(e) { - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; + this.lastActive = this.lastActive || []; - if (this.isHorizontal()) { - if (this.options.gridLines.show) { - // Draw the horizontal line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { - return tick === 0; - }) !== undefined; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; - var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; - - helpers.each(this.ticks, function(tick, index) { - // Grid lines are vertical - var xValue = this.getPixelForValue(tick); - - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the left if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } - xValue += helpers.aliasPixel(this.ctx.lineWidth); + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } - // Draw the label area - this.ctx.beginPath(); + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xValue, yTickStart); - this.ctx.lineTo(xValue, yTickEnd); - } + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xValue, chartArea.top); - this.ctx.lineTo(xValue, chartArea.bottom); - } + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - }, this); - } + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } - if (this.options.labels.show) { - // Draw the labels + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; - var labelStartY; + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; - if (this.options.position == "top") { - labelStartY = this.bottom - 10; - this.ctx.textBaseline = "bottom"; - } else { - // bottom side - labelStartY = this.top + 10; - this.ctx.textBaseline = "top"; + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } - this.ctx.textAlign = "center"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - helpers.each(this.labels, function(label, index) { - var xValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, xValue, labelStartY); - }, this); - } - } else { - // Vertical - if (this.options.gridLines.show) { + // Built in Tooltips + if (this.options.tooltips.enabled) { - // Draw the vertical line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { - return tick === 0; - }) !== undefined; - var xTickStart = this.options.position == "right" ? this.left : this.right - 5; - var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; + // The usual updates + this.tooltip.initialize(); - helpers.each(this.ticks, function(tick, index) { - // Grid lines are horizontal - var yValue = this.getPixelForValue(tick); + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the bottom if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; // use boolean to indicate that we only want to do this once - } + helpers.extend(this.tooltip, { + _active: this.active, + }); - yValue += helpers.aliasPixel(this.ctx.lineWidth); + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } - // Draw the label area - this.ctx.beginPath(); - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xTickStart, yValue); - this.ctx.lineTo(xTickEnd, yValue); - } + // Hover animations + this.tooltip.pivot(); - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(chartArea.left, yValue); - this.ctx.lineTo(chartArea.right, yValue); - } + if (!this.animating) { + var changed; - this.ctx.stroke(); - }, this); + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; } + }, this); - if (this.options.labels.show) { - // Draw the labels - - var labelStartX; - - if (this.options.position == "left") { - labelStartX = this.right - 10; - this.ctx.textAlign = "right"; - } else { - // right side - labelStartX = this.left + 5; - this.ctx.textAlign = "left"; - } - - this.ctx.textBaseline = "middle"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { - helpers.each(this.labels, function(label, index) { - var yValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, labelStartX, yValue); - }, this); - } + this.stop(); + this.render(this.options.hover.animationDuration); } } - } - }); - Chart.scales.registerScaleType("linear", LinearScale); - var DatasetScale = Chart.Element.extend({ - // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset - calculateRange: helpers.noop, - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; + // Remember Last Active + this.lastActive = this.active; + return this; }, - getPixelForValue: function(value, index, includeOffset) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - if (this.isHorizontal()) { - var isRotated = (this.labelRotation > 0); - var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; + }); - if (this.options.gridLines.offsetGridLines && includeOffset) { - valueOffset += (valueWidth / 2); - } - return this.left + Math.round(valueOffset); - } else { - return this.top + (index * (this.height / this.max)); - } - }, - calculateLabelRotation: function(maxHeight, margins) { - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - this.ctx.font = labelFont; +}).call(this); - var firstWidth = this.ctx.measureText(this.labels[0]).width; - var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; - var firstRotated; - var lastRotated; +(function() { + "use strict"; - this.paddingRight = lastWidth / 2 + 3; - this.paddingLeft = firstWidth / 2 + 3; + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; - this.labelRotation = 0; + var defaultConfig = { - if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - var cosRotation; - var sinRotation; - var firstRotatedWidth; + scale: { + scaleType: "radialLinear", + display: true, - this.labelWidth = originalLabelWidth; + //Boolean - Whether to animate scaling the chart from the centre + animate: false, - //Allow 3 pixels x2 padding either side for label readability - // only the index matters for a dataset scale, but we want a consistent interface between scales - var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + lineArc: true, - //Max label rotate should be 90 - also act as a loop counter - while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { - cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); - sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; + // scale numbers + beginAtZero: true, - // We're right aligning the text now. - if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { - this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; - } + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", - this.paddingRight = this.options.labels.fontSize / 2; + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, - if (sinRotation * originalLabelWidth > maxHeight) { - // go back one step - this.labelRotation--; - break; - } + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", - this.labelRotation++; - this.labelWidth = cosRotation * originalLabelWidth; + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, - } - } else { - this.labelWidth = 0; - this.paddingRight = 0; - this.paddingLeft = 0; + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, } + }, - if (margins) { - this.paddingLeft -= margins.left; - this.paddingRight -= margins.right; + //Boolean - Whether to animate the rotation of the chart + animateRotate: true, + }; - this.paddingLeft = Math.max(this.paddingLeft, 0); - this.paddingRight = Math.max(this.paddingRight, 0); - } - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight, margins) { - this.calculateRange(); - this.calculateLabelRotation(maxHeight, margins); + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "PolarArea", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { - var minSize = { - width: 0, - height: 0, - }; + // Scale setup + var self = this; + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleClass({ + options: this.options.scale, + lineArc: true, + width: this.chart.width, + height: this.chart.height, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + valuesCount: this.data.length, + calculateRange: function() { + this.min = null; + this.max = null; - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + helpers.each(self.data.datasets[0].data, function(value) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } - if (this.isHorizontal()) { - minSize.width = maxWidth; - this.width = maxWidth; + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }); - var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); - } else { - minSize.height = maxHeight; - this.height = maxHeight; + helpers.bindEvents(this, this.options.events, this.events); - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } + //Set up tooltip events on the chart + helpers.bindEvents(this, this.options.events, this.events); - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); + }, this); - var setContextLineSettings; + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; + // Fit the scale before we animate + this.updateScaleRange(); + this.scale.calculateRange(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - if (this.isHorizontal()) { - setContextLineSettings = true; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; - var isRotated = this.labelRotation !== 0; + // so that we animate nicely + this.resetElements(); - helpers.each(this.labels, function(label, index) { - var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines - var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) + // Update the chart with the latest data. + this.update(); - if (this.options.gridLines.show) { - if (index === 0) { - // Draw the first index specially - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } + }, + updateScaleRange: function() { + helpers.extend(this.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2 + }); + }, + resetElements: function() { + var circumference = 1 / this.data.datasets[0].data.length * 2; - xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { - // Draw the label area - this.ctx.beginPath(); + var value = this.data.datasets[0].data[index]; - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xLineValue, yTickStart); - this.ctx.lineTo(xLineValue, yTickEnd); - } + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: 0, + startAngle: Math.PI * -0.5, + endAngle: Math.PI * -0.5, - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xLineValue, chartArea.top); - this.ctx.lineTo(xLineValue, chartArea.bottom); - } + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - } + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); - if (this.options.labels.show) { - this.ctx.save(); - this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); - this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); - this.ctx.font = this.font; - this.ctx.textAlign = (isRotated) ? "right" : "center"; - this.ctx.textBaseline = (isRotated) ? "middle" : "top"; - this.ctx.fillText(label, 0, 0); - this.ctx.restore(); - } - }, this); - } else { - // Vertical - if (this.options.gridLines.show) {} + slice.pivot(); + }, this); + }, + update: function(animationDuration) { - if (this.options.labels.show) { - // Draw the labels - } - } - } - } - }); - Chart.scales.registerScaleType("dataset", DatasetScale); + this.updateScaleRange(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); - var LinearRadialScale = Chart.Element.extend({ - initialize: function() { - this.size = helpers.min([this.height, this.width]); - this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); - }, - calculateCenterOffset: function(value) { - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); - return (value - this.min) * scalingFactor; + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: this.scale.calculateCenterOffset(value), + startAngle: startAngle, + endAngle: endAngle, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.slice.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.slice.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.slice.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.slice.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + slice.pivot(); + + console.log(slice); + + }, this); + + this.render(animationDuration); }, - update: function() { - if (!this.options.lineArc) { - this.setScaleSize(); - } else { - this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); - } + draw: function(ease) { + var easingDecimal = ease || 1; - this.buildYLabels(); + this.clear(); + + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + slice.transition(easingDecimal).draw(); + }, this); + + this.scale.draw(); + + this.tooltip.transition(easingDecimal).draw(); }, - calculateRange: helpers.noop, // overridden in chart - generateTicks: function() { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw + events: function(e) { - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; + // If exiting chart + if (e.type == 'mouseout') { + return this; + } - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; } - } else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph + }.call(this); - var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.slice.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.slice.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.slice.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything } + } - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything } } - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, - buildYLabels: function() { - this.yLabels = []; + // Built in Tooltips + if (this.options.tooltips.enabled) { - helpers.each(this.ticks, function(tick, index, ticks) { - var label; + // The usual updates + this.tooltip.initialize(); - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.labels.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; } + } - this.yLabels.push(label ? label : ""); - }, this); - }, - getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); - }, - setScaleSize: function() { - /* - * Right, this is really confusing and there is a lot of maths going on here - * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 - * - * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif - * - * Solution: - * - * We assume the radius of the polygon is half the size of the canvas at first - * at each index we check if the text overlaps. - * - * Where it does, we store that angle and that index. - * - * After finding the largest index and angle we calculate how much we need to remove - * from the shape radius to move the point inwards by that x. - * - * We average the left and right distances to get the maximum shape radius that can fit in the box - * along with labels. - * - * Once we have that, we can find the centre point for the chart, by taking the x text protrusion - * on each side, removing that from the size, halving it and adding the left x protrusion width. - * - * This will mean we have a shape fitted to the canvas, as large as it can be with the labels - * and position it in the most space efficient manner - * - * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - */ + // Hover animations + this.tooltip.pivot(); - // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points - var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), - pointPosition, - i, - textWidth, - halfTextWidth, - furthestRight = this.width, - furthestRightIndex, - furthestRightAngle, - furthestLeft = 0, - furthestLeftIndex, - furthestLeftAngle, - xProtrusionLeft, - xProtrusionRight, - radiusReductionRight, - radiusReductionLeft, - maxWidthRadius; - this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - for (i = 0; i < this.valuesCount; i++) { - // 5px to space the text slightly out - similar to what we do in the draw function. - pointPosition = this.getPointPosition(i, largestPossibleRadius); - textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { - value: this.labels[i] - })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { - // If we're at index zero, or exactly the middle, we're at exactly the top/bottom - // of the radar chart, so text will be aligned centrally, so we'll half it and compare - // w/left and right text sizes - halfTextWidth = textWidth / 2; - if (pointPosition.x + halfTextWidth > furthestRight) { - furthestRight = pointPosition.x + halfTextWidth; - furthestRightIndex = i; - } - if (pointPosition.x - halfTextWidth < furthestLeft) { - furthestLeft = pointPosition.x - halfTextWidth; - furthestLeftIndex = i; - } - } else if (i < this.valuesCount / 2) { - // Less than half the values means we'll left align the text - if (pointPosition.x + textWidth > furthestRight) { - furthestRight = pointPosition.x + textWidth; - furthestRightIndex = i; - } - } else if (i > this.valuesCount / 2) { - // More than half the values means we'll right align the text - if (pointPosition.x - textWidth < furthestLeft) { - furthestLeft = pointPosition.x - textWidth; - furthestLeftIndex = i; + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); } } - xProtrusionLeft = furthestLeft; + // Remember Last Active + this.lastActive = this.active; + return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); + +}).call(this); + +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + + + Chart.Type.extend({ + name: "Radar", + defaults: { + + scale: { + scaleType: "radialLinear", + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate: false, + + lineArc: false, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, + + angleLines: { + show: true, + color: "rgba(0,0,0,.1)", + lineWidth: 1 + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, + + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + }, + + pointLabels: { + //String - Point label font declaration + fontFamily: "'Arial'", + + //String - Point label font weight + fontStyle: "normal", + + //Number - Point label font size in pixels + fontSize: 10, + + //String - Point label font colour + fontColor: "#666", + }, + }, + + elements: { + line: { + tension: 0, // no bezier in radar + } + }, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + + }, + + initialize: function() { + // Events + helpers.bindEvents(this, this.options.events, this.events); + + // Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + _loop: true + }); + + dataset.metaData = []; + + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + + }, this); + }, this); + + // Build the scale. + this.buildScale(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[0]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[collection.length - 1]; + }, + resetElements: function() { + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _scale: this.scale, + + // Desired view properties + _model: { + x: this.scale.xCenter, + y: this.scale.yCenter, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = this.scale.xCenter; + point._model.controlPointPreviousY = this.scale.yCenter; + point._model.controlPointNextX = this.scale.xCenter; + point._model.controlPointNextY = this.scale.yCenter; + + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function(animationDuration) { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + var scaleBase; + + if (this.scale.min < 0 && this.scale.max < 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.max); + } else if (this.scale.min > 0 && this.scale.max > 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.min); + } else { + scaleBase = this.scale.getPointPosition(0, 0); + } + + helpers.extend(dataset.metaDataset, { + // Utility + _datasetIndex: datasetIndex, + + // Data + _children: dataset.metaData, + + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + + // Scale + scaleTop: this.scale.top, + scaleBottom: this.scale.bottom, + scaleZero: scaleBase, + }, + }); + + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); + + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: pointPosition.y, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(animationDuration); + }, + buildScale: function() { + var self = this; + + var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.scaleType); + this.scale = new ScaleConstructor({ + options: this.options.scale, + height: this.chart.height, + width: this.chart.width, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + labels: this.data.labels, + valuesCount: this.data.datasets[0].data.length, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(self.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }); + + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + this.scale.draw(this.chartArea); + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; - xProtrusionRight = Math.ceil(furthestRight - this.width); + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); - furthestRightAngle = this.getIndexAngle(furthestRightIndex); + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); - furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } - radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { - radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + // If exiting chart + if (e.type == 'mouseout') { + return this; + } - // Ensure we actually need to reduce the size of the chart - radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; - radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; + this.lastActive = this.lastActive || []; - this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); - //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) - this.setCenterPoint(radiusReductionLeft, radiusReductionRight); + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } - }, - setCenterPoint: function(leftMovement, rightMovement) { + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } - var maxRight = this.width - rightMovement - this.drawingArea, - maxLeft = leftMovement + this.drawingArea; + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; - this.xCenter = (maxLeft + maxRight) / 2; - // Always vertically in the centre as the text height doesn't change - this.yCenter = (this.height / 2); - }, + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; - getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; - // Start from the top instead of right, so remove a quarter of the circle + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } - return index * angleMultiplier - (Math.PI / 2); - }, - getPointPosition: function(index, distanceFromCenter) { - var thisAngle = this.getIndexAngle(index); - return { - x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, - y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter - }; - }, - draw: function() { - if (this.options.display) { - var ctx = this.ctx; - helpers.each(this.yLabels, function(label, index) { - // Don't draw a centre value - if (index > 0) { - var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), - yHeight = this.yCenter - yCenterOffset, - pointPosition; + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; - // Draw circular lines around the scale - if (this.options.gridLines.show) { - ctx.strokeStyle = this.options.gridLines.color; - ctx.lineWidth = this.options.gridLines.lineWidth; + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; - if (this.options.lineArc) { - ctx.beginPath(); - ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); - ctx.closePath(); - ctx.stroke(); - } else { - ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { - pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); - if (i === 0) { - ctx.moveTo(pointPosition.x, pointPosition.y); - } else { - ctx.lineTo(pointPosition.x, pointPosition.y); - } - } - ctx.closePath(); - ctx.stroke(); - } + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } - if (this.options.labels.show) { - ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + // Built in Tooltips + if (this.options.tooltips.enabled) { - if (this.showLabelBackdrop) { - var labelWidth = ctx.measureText(label).width; - ctx.fillStyle = this.options.labels.backdropColor; - ctx.fillRect( - this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, - yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, - labelWidth + this.options.labels.backdropPaddingX * 2, - this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 - ); - } + // The usual updates + this.tooltip.initialize(); - ctx.textAlign = 'center'; - ctx.textBaseline = "middle"; - ctx.fillStyle = this.options.labels.fontColor; - ctx.fillText(label, this.xCenter, yHeight); - } - } - }, this); + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; - if (!this.options.lineArc) { - ctx.lineWidth = this.options.angleLines.lineWidth; - ctx.strokeStyle = this.options.angleLines.color; + helpers.extend(this.tooltip, { + _active: this.active, + }); - for (var i = this.valuesCount - 1; i >= 0; i--) { - if (this.options.angleLines.show) { - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); - ctx.beginPath(); - ctx.moveTo(this.xCenter, this.yCenter); - ctx.lineTo(outerPosition.x, outerPosition.y); - ctx.stroke(); - ctx.closePath(); - } - // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); - ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - ctx.fillStyle = this.options.pointLabels.fontColor; + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } - var labelsCount = this.labels.length, - halfLabelsCount = this.labels.length / 2, - quarterLabelsCount = halfLabelsCount / 2, - upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), - exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); - if (i === 0) { - ctx.textAlign = 'center'; - } else if (i === halfLabelsCount) { - ctx.textAlign = 'center'; - } else if (i < halfLabelsCount) { - ctx.textAlign = 'left'; - } else { - ctx.textAlign = 'right'; - } + // Hover animations + this.tooltip.pivot(); - // Set the correct text baseline based on outer positioning - if (exactQuarter) { - ctx.textBaseline = 'middle'; - } else if (upperHalf) { - ctx.textBaseline = 'bottom'; - } else { - ctx.textBaseline = 'top'; - } + if (!this.animating) { + var changed; - ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); } } - } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, }); - Chart.scales.registerScaleType("radialLinear", LinearRadialScale); }).call(this); (function() { diff --git a/Chart.min.js b/Chart.min.js index 8bea7c5a1a3..6139127e6a4 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,61 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{animation:{duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,tooltips:{enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>:","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>:","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},defaultColor:o,elements:{line:{tension:.4,backgroundColor:o,borderWidth:3,borderColor:o,fill:!0,skipNull:!0,drawNull:!1},point:{radius:3,backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},bar:{backgroundColor:o,borderWidth:0,borderColor:o,valueSpacing:5,datasetSpacing:1},slice:{backgroundColor:o,borderColor:"#fff",borderWidth:2}}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=h,t&&r(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},m=s.amd="function"==typeof define&&define.amd,v=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},p=s.min=function(t){return Math.min.apply(Math,t)},f=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},s.cap=function(t,e,i){if(v(e)){if(t>e)return e}else if(v(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&v(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),b=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,l=g(t),h=p(t);l===h&&(l+=.5,h>=.5&&!o?h-=.5:l+=.5);for(var c=Math.abs(l-h),d=f(c),u=Math.ceil(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=o?0:Math.floor(h/(1*Math.pow(10,d)))*Math.pow(10,d),v=u-m,b=Math.pow(10,d),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=a,b=v/x),{steps:x,stepValue:b,min:m,max:m+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(s.log10(t)),a=t/Math.pow(10,o);return i=e?1.5>a?1:3>a?2:7>a?5:10:1>=a?1:2>=a?2:5>=a?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),x=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=b(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-x.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*x.easeInBounce(2*t):.5*x.easeOutBounce(2*t-1)+.5}}),A=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),C=(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,e,i,o,s,a){var n=0,r=x[i]||x.linear,l=function(){n++;var i=n/e,h=r(i);t.call(a,h,i,n),o.call(a,h,i),e>n?a.animationFrame=A(l):s.apply(a)};A(l)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),y=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=c},_=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},C(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){y(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-left"))+parseInt(P(e,"padding-right"));return e.clientWidth-i},k=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(P(e,"padding-bottom"))+parseInt(P(e,"padding-top"));return e.clientHeight-i},P=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},S=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),I=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,e,i){return e+" "+t+"px "+i},D=s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},O=s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=d(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return I(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:k(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,S(this.chart),this},redraw:c,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n0||t.borderWidth>0)&&(e.beginPath(),e.arc(t.x,t.y,t.radius||i.defaults.global.elements.point.radius,0,2*Math.PI),e.closePath(),e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.lineWidth=t.borderWidth||i.defaults.global.elements.point.borderWidth,e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.fill(),e.stroke())}}),i.Line=i.Element.extend({draw:function(){var t=this._view,e=this._chart.ctx,o=this._children[0],a=this._children[this._children.length-1];s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):(i._view.skip&&t.skipNull&&!this._loop?(e.lineTo(s._view.x,i._view.y),e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(e.moveTo(i._view.x,s._view.y),e.lineTo(i._view.x,i._view.y)),void(s._view.skip&&t.skipNull?e.moveTo(i._view.x,i._view.y):t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(e.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),e.lineTo(this._children[0]._view.x,t.scaleZero),e.fillStyle=t.backgroundColor||i.defaults.global.defaultColor,e.closePath(),e.fill()),e.lineWidth=t.borderWidth||i.defaults.global.defaultColor,e.strokeStyle=t.borderColor||i.defaults.global.defaultColor,e.beginPath(),s.each(this._children,function(i,o){var s=this.previousPoint(i,this._children,o),a=this.nextPoint(i,this._children,o);return 0===o?void e.moveTo(i._view.x,i._view.y):i._view.skip&&t.skipNull&&!this._loop?(e.moveTo(s._view.x,i._view.y),void e.moveTo(a._view.x,i._view.y)):s._view.skip&&t.skipNull&&!this._loop?(e.moveTo(i._view.x,s._view.y),void e.moveTo(i._view.x,i._view.y)):s._view.skip&&t.skipNull?void e.moveTo(i._view.x,i._view.y):void(t.tension>0?e.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,i._view.controlPointPreviousX,i._view.controlPointPreviousY,i._view.x,i._view.y):e.lineTo(i._view.x,i._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?e.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):e.lineTo(o._view.x,o._view.y)),e.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}}),i.Arc=i.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?i.startAngle-2*Math.PI:i.startAngle,n=i.endAngle<-.5*Math.PI?i.endAngle+2*Math.PI:i.endAngle>1.5*Math.PI?i.endAngle-2*Math.PI:i.endAngle,r=o.angle>=a&&o.angle<=n,l=o.distance>=i.innerRadius&&o.distance<=i.outerRadius;return r&&l},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}}),i.Rectangle=i.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=0&&(i=this._data.datasets[r].metaData,o=l(i,this._active[0]),-1===o);r--);var h=function(t){var e,i,r,l,h,c=[],d=[],u=[];return s.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),s.each(this._options.stacked?c.reverse():c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(s.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=p(u),r=g(u),l=p(d),i=g(d),{x:l>this._chart.width/2?l:i,y:(h+r)/2}}.call(this,o);s.extend(this._model,{x:h.x,y:h.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var c=t.measureText(this.title).width,d=D(t,this.font,a)+this._model.fontSize+3,u=g([d,c]);this._model.width=u+2*this._model.xPadding;var m=this._model.height/2;this._model.y-m<0?this._model.y=m:this._model.y+m>this._chart.height&&(this._model.y=this._chart.height-m),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=W(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var i=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+i;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,l=e.y-n;if(t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-i),t.lineTo(e.x+e.caretHeight,e.y-(i+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(i+e.caretHeight)),t.closePath(),t.fill();break;case"below":l=e.y+i+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+i),t.lineTo(e.x+e.caretHeight,e.y+i+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+i+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}O(t,r,l,o,a,e.cornerRadius),t.fill(),t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,l+a/2)}break;case"label":O(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=s.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=W(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=W(e.fontSize,e._fontStyle,e._fontFamily),s.each(e.labels,function(i,o){t.fillStyle=s.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(i,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=s.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=s.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}}),i.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,i){i||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var i=0;ithis.animations[i].animationObject.numSteps&&(this.animations[i].animationObject.currentStep=this.animations[i].animationObject.numSteps),this.animations[i].animationObject.render(this.animations[i].chartInstance,this.animations[i].animationObject),this.animations[i].animationObject.currentStep==this.animations[i].animationObject.numSteps&&(this.animations[i].chartInstance.animating=!1,this.animations.splice(i,1),i--);var o=Date.now(),a=o-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&s.requestAnimFrame.call(window,this.digestWrapper)}},s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){a(i.instances,function(t){t.options.responsive&&(t.resize(),t.update(),t.render())})},50)}}()),m?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id, -calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,l=t;l0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.metaDataset.custom&&t.metaDataset.custom.tension?t.metaDataset.custom.tension:t.tension||this.options.elements.line.tension,backgroundColor:t.metaDataset.custom&&t.metaDataset.custom.backgroundColor?t.metaDataset.custom.backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.metaDataset.custom&&t.metaDataset.custom.borderWidth?t.metaDataset.custom.borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.metaDataset.custom&&t.metaDataset.custom.borderColor?t.metaDataset.custom.borderColor:t.borderColor||this.options.elements.line.borderColor,fill:t.metaDataset.custom&&t.metaDataset.custom.fill?t.metaDataset.custom.fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(null,e,!0),y:n.getPointPixelForValue(this.data.datasets[s].data[e],e,s),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){this.lastActive=this.lastActive||[],"mouseout"==t.type?this.active=[]:this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.radius:i.getValueAtIndexOrDefault(e.radius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor), -label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,n=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){var o;o=this.scale.min<0&&this.scale.max<0?this.scale.getPointPosition(0,this.scale.max):this.scale.min>0&&this.scale.max>0?this.scale.getPointPosition(0,this.scale.min):this.scale.getPointPosition(0,0),i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;sn&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var l=i.niceNum(this.max-this.min,!1),h=i.niceNum(l/(a-1),!0),c=Math.floor(this.min/h)*h,d=Math.ceil(this.max/h)*h,u=c;d>=u;u+=h)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var l=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,s),this.ctx.lineTo(l,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,l="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(l,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var h;"left"==this.options.position?(h=this.right-10,this.ctx.textAlign="right"):(h=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,h,i)},this)}}}}});e.scales.registerScaleType("linear",o);var s=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var l,h,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(l=Math.cos(i.toRadians(this.labelRotation)),h=Math.sin(i.toRadians(this.labelRotation)),s=l*n,a=l*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,h*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=l*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var l=this.getPixelForValue(n,r,!1),h=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,o),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(h,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",s);var a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),l=Math.floor(this.min/r)*r,h=Math.ceil(this.max/r)*r,c=l;h>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,l,h,c,d,u,m=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),v=this.width,g=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ev&&(v=t.x+s,a=e),t.x-sv&&(v=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,l=r>e||e>a-r,h=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",h?t.textBaseline="middle":l?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={hover:{mode:"single"},scales:{xAxes:[{scaleType:"linear",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(this.data.datasets[s].data[e].x),y:n.getPixelForValue(this.data.datasets[s].data[e].y),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),l=0;le&&(e+=360),o=(r+l)/2,i=l==r?0:.5>=o?h/(l+r):h/(2-l-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),l=Math.max(s,a,n),h=l-r;return i=0==l?0:h/l*1e3/10,l==r?e=0:s==l?e=(a-n)/h:a==l?e=2+(n-s)/h:n==l&&(e=4+(s-a)/h),e=Math.min(60*e,360),0>e&&(e+=360),o=l/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function l(t){return $[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=h(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,l=t[2]/100;if(0==r)return a=255*l,[a,a,a];i=.5>l?l*(1+r):l+r-l*r,e=2*l-i,s=[0,0,0];for(var h=0;3>h;h++)o=n+1/3*-(h-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[h]=255*a;return s}function m(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function v(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return l(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),l=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,l,n];case 1:return[r,o,n];case 2:return[n,o,l];case 3:return[n,r,o];case 4:return[l,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return l(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,l=t[2]/100,h=n+l;switch(h>1&&(n/=h,l/=h),e=Math.floor(6*a),i=1-l,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function S(t){return n(w(t))}function I(t){return l(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function O(t){return s(W(t))}function M(t){return a(W(t))}function V(t){return l(W(t))}function B(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function R(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(R(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return B(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return h(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:l,rgb2xyz:h,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:m,hsl2hwb:v,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:S,hwb2keyword:I,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:O,cmyk2hwb:M,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:B,xyz2lab:R,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50] -},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new h};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],l=n[2];s[r]=s[r]||{},s[r][l]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return m(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function m(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function v(t,e){return 1>e||t[3]&&t[3]<1?g(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:l,hexString:h,rgbString:c,rgbaString:d,percentString:u,percentaString:m,hslString:v,hslaString:g,hwbString:p,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:o,elements:{}}},i.types={};var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=l,t&&r(i.prototype,t),i.__super__=e.prototype,i}),h=s.noop=function(){},c=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)},u=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},v=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},p=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=o*s/(s+a),r=o*a/(s+a);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),f=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,n=Math.floor(e/(1.5*i)),r=a>=n,l=v(t),h=g(t);l===h&&(l+=.5,h>=.5&&!o?h-=.5:l+=.5);for(var c=Math.abs(l-h),d=p(c),u=Math.ceil(l/(1*Math.pow(10,d)))*Math.pow(10,d),m=o?0:Math.floor(h/(1*Math.pow(10,d)))*Math.pow(10,d),f=u-m,b=Math.pow(10,d),x=Math.round(f/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(f/b),x%1!==0&&(r=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(f/b)}else b/=2,x=Math.round(f/b);return r&&(x=a,b=f/x),{steps:x,stepValue:b,min:m,max:m+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(s.log10(t)),a=t/Math.pow(10,o);return i=e?1.5>a?1:3>a?2:7>a?5:10:1>=a?1:2>=a?2:5>=a?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),b=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=f(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+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}}),x=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),A=(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,e,i,o,s,a){var n=0,r=b[i]||b.linear,l=function(){n++;var i=n/e,h=r(i);t.call(a,h,i,n),o.call(a,h,i),e>n?a.animationFrame=x(l):s.apply(a)};x(l)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),C=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=h},y=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},A(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){C(t.chart.canvas,i,e)})}),_=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(k(e,"padding-left"))+parseInt(k(e,"padding-right"));return e.clientWidth-i},w=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(k(e,"padding-bottom"))+parseInt(k(e,"padding-top"));return e.clientHeight-i},k=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},P=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),S=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)};s.fontString=function(t,e,i){return e+" "+t+"px "+i},s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()},s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)};i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=c(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},r(i.Type.prototype,{initialize:function(){return this},clear:function(){return S(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=_(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:w(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,P(this.chart),this},redraw:h,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},n=0;n1.5*Math.PI?o.startAngle-2*Math.PI:o.startAngle,n=o.endAngle<-.5*Math.PI?o.endAngle+2*Math.PI:o.endAngle>1.5*Math.PI?o.endAngle-2*Math.PI:o.endAngle,r=s.angle>=a&&s.angle<=n,l=s.distance>=o.innerRadius&&s.distance<=o.outerRadius;return r&&l},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.Line=e.Element.extend({draw:function(){var t=this._view,o=this._chart.ctx,s=this._children[0],a=this._children[this._children.length-1];i.each(this._children,function(e,i){var s=this.previousPoint(e,this._children,i),a=this.nextPoint(e,this._children,i);return 0===i?void o.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(o.lineTo(s._view.x,e._view.y),o.moveTo(a._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(o.moveTo(e._view.x,s._view.y),o.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?o.moveTo(e._view.x,e._view.y):t.tension>0?o.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):o.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!s._view.skip?o.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):o.lineTo(s._view.x,s._view.y)),this._children.length>0&&t.fill&&(o.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),o.lineTo(this._children[0]._view.x,t.scaleZero),o.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,o.closePath(),o.fill()),o.lineWidth=t.borderWidth||e.defaults.global.defaultColor,o.strokeStyle=t.borderColor||e.defaults.global.defaultColor,o.beginPath(),i.each(this._children,function(e,i){var s=this.previousPoint(e,this._children,i),a=this.nextPoint(e,this._children,i);return 0===i?void o.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(o.moveTo(s._view.x,e._view.y),void o.moveTo(a._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(o.moveTo(e._view.x,s._view.y),void o.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void o.moveTo(e._view.x,e._view.y):void(t.tension>0?o.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):o.lineTo(e._view.x,e._view.y))},this),this._loop&&!s._view.skip&&(t.tension>0?o.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):o.lineTo(s._view.x,s._view.y)),o.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}})}.call(this),/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.Point=e.Element.extend({inRange:function(t,e){var i=this._view,o=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(o+=n,s-=n,a+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var l,h,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(l=Math.cos(i.toRadians(this.labelRotation)),h=Math.sin(i.toRadians(this.labelRotation)),s=l*n,a=l*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,h*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=l*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()){s.width=t,this.width=t;var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else s.height=e,this.height=e,s.width=Math.min(n+6,t);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(n,r){var l=this.getPixelForValue(n,r,!1),h=this.getPixelForValue(n,r,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,o),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(h,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("dataset",o)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var l=i.niceNum(this.max-this.min,!1),h=i.niceNum(l/(a-1),!0),c=Math.floor(this.min/h)*h,d=Math.ceil(this.max/h)*h,u=c;d>=u;u+=h)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(this.isHorizontal()?(o.width=t,o.height=this.options.gridLines.show?10:0):(o.height=e,o.width=this.options.gridLines.show?10:0),this.options.labels.show){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var n=t-o.width,r=i.longestText(this.ctx,s,this.labels);n>r?o.width+=r:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var l=this.getPixelForValue(n);0===n||!o&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,s),this.ctx.lineTo(l,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,l="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var n=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(l,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var h;"left"==this.options.position?(h=this.right-10,this.ctx.textAlign="right"):(h=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,h,i)},this)}}}}});e.scales.registerScaleType("linear",o)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(o-1),!0),l=Math.floor(this.min/r)*r,h=Math.ceil(this.max/r)*r,c=l;h>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,n,r,l,h,c,d,u,m=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),v=this.width,g=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ev&&(v=t.x+s,a=e),t.x-sv&&(v=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),n=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var r=0;r=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,n=this.labels.length/2,r=n/2,l=r>e||e>a-r,h=e===r||e===a-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",h?t.textBaseline="middle":l?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",o)}.call(this),/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,o){o||(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var o=0;othis.animations[o].animationObject.numSteps&&(this.animations[o].animationObject.currentStep=this.animations[o].animationObject.numSteps),this.animations[o].animationObject.render(this.animations[o].chartInstance,this.animations[o].animationObject),this.animations[o].animationObject.currentStep==this.animations[o].animationObject.numSteps&&(this.animations[o].chartInstance.animating=!1,this.animations.splice(o,1),o--);var s=Date.now(),a=s-t-this.frameDuration,n=a/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var o,s,a=[],n=[],r=this._data.datasets.length-1;r>=0&&(o=this._data.datasets[r].metaData,s=indexOf(o,this._active[0]),-1===s);r--);var l=function(t){var e,o,r,l,h,c=[],d=[],u=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){d.push(t._view.x),u.push(t._view.y),a.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=min(u),r=max(u),l=min(d),o=max(d),{x:l>this._chart.width/2?l:o,y:(h+r)/2}}.call(this,s);i.extend(this._model,{x:l.x,y:l.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var h=t.measureText(this.title).width,c=longestText(t,this.font,a)+this._model.fontSize+3,d=max([c,h]);this._model.width=d+2*this._model.xPadding;var u=this._model.height/2;this._model.y-u<0?this._model.y=u:this._model.y+u>this._chart.height&&(this._model.y=this._chart.height-u),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var o=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,n=a+e.caretHeight+o;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,l=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-o),t.lineTo(e.x+e.caretHeight,e.y-(o+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(o+e.caretHeight)),t.closePath(),t.fill();break;case"below":l=e.y+o+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+o),t.lineTo(e.x+e.caretHeight,e.y+o+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+o+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,l,s,a,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,l+a/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(o,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(o,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o={stacked:!1,valueSpacing:5,datasetSpacing:1,hover:{mode:"label"},scales:{xAxes:[{scaleType:"dataset",display:!0,position:"bottom",id:"x-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!0},labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.calculateBarX(this.data.datasets.length,s,e),y:a,base:r.calculateBarBase(s,e),width:n.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:n.calculateBarY(s,e),base:n.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.bar.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.bar.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.bar.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(t){var o=this,s=function(){this.min=null,this.max=null;var t=[],e=[];if(o.options.stacked){i.each(o.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){t[s]=t[s]||0,e[s]=e[s]||0,o.options.relativePoints?t[s]=100:0>i?e[s]+=i:t[s]+=i},this)},this);var s=t.concat(e);this.min=i.min(s),this.max=i.max(s)}else i.each(o.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var a=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),n=new a({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=o.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*o.options.elements.bar.valueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*o.options.elements.bar.datasetSpacing;return o.options.stacked?e:e/t},calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,!0)-s/2,n=this.calculateBarWidth(t);return o.options.stacked?a+n/2:a+n*e+e*o.options.elements.bar.datasetSpacing+n/2}});this.scales[n.id]=n,i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),a=new i({ctx:this.chart.ctx,options:t,calculateRange:s,calculateBarBase:function(t,e){var i=0;if(o.options.stacked){var s=o.data.datasets[t].data[e];if(0>s)for(var a=0;t>a;a++)o.data.datasets[a].yAxisID===this.id&&(i+=o.data.datasets[a].data[e]<0?o.data.datasets[a].data[e]:0);else for(var n=0;t>n;n++)o.data.datasets[n].yAxisID===this.id&&(i+=o.data.datasets[n].data[e]>0?o.data.datasets[n].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=o.data.datasets[t].data[e];if(o.options.stacked){for(var s=0,a=0,n=0;t>n;n++)o.data.datasets[n].data[e]<0?a+=o.data.datasets[n].data[e]||0:s+=o.data.datasets[n].data[e]||0;return this.getPixelForValue(0>i?a+i:s+i)}for(var r=0,l=t;l0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.slice.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.slice.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.slice.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.slice.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.slice.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.slice.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.slice.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),0===s?o._model.startAngle=Math.PI*-.5:o._model.startAngle=t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.metaDataset.custom&&t.metaDataset.custom.tension?t.metaDataset.custom.tension:t.tension||this.options.elements.line.tension,backgroundColor:t.metaDataset.custom&&t.metaDataset.custom.backgroundColor?t.metaDataset.custom.backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.metaDataset.custom&&t.metaDataset.custom.borderWidth?t.metaDataset.custom.borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.metaDataset.custom&&t.metaDataset.custom.borderColor?t.metaDataset.custom.borderColor:t.borderColor||this.options.elements.line.borderColor,fill:t.metaDataset.custom&&t.metaDataset.custom.fill?t.metaDataset.custom.fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(null,e,!0),y:n.getPointPixelForValue(this.data.datasets[s].data[e],e,s),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].scaleType),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.scaleType),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,n=0;o>n;++n)t.data.datasets[n].data[i]<0?a+=t.data.datasets[n].data[i]:s+=t.data.datasets[n].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){this.lastActive=this.lastActive||[],"mouseout"==t.type?this.active=[]:this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.radius:i.getValueAtIndexOrDefault(e.radius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.scaleType);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,n=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:n,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.slice.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.slice.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.slice.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.slice.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t,i){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.slice.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.slice.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.slice.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){var o;o=this.scale.min<0&&this.scale.max<0?this.scale.getPointPosition(0,this.scale.max):this.scale.min>0&&this.scale.max>0?this.scale.getPointPosition(0,this.scale.min):this.scale.getPointPosition(0,0),i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{scaleType:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,n=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];a=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart,_xScale:n,_yScale:r,_datasetIndex:s,_index:e,_model:{x:n.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius), +backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:n,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(this.data.datasets[s].data[e].x),y:n.getPixelForValue(this.data.datasets[s].data[e].y),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o,s){var a=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chartArea.bottom?t._model.controlPointNextY=this.chartArea.bottom:a.next.ythis.chartArea.bottom?t._model.controlPointPreviousY=this.chartArea.bottom:a.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.scaleType),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t,i){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,n=this.rgbArray(),r=t.rgbArray(),l=0;le&&(e+=360),o=(r+l)/2,i=l==r?0:.5>=o?h/(l+r):h/(2-l-r),[e,100*i,100*o]}function s(t){var e,i,o,s=t[0],a=t[1],n=t[2],r=Math.min(s,a,n),l=Math.max(s,a,n),h=l-r;return i=0==l?0:h/l*1e3/10,l==r?e=0:s==l?e=(a-n)/h:a==l?e=2+(n-s)/h:n==l&&(e=4+(s-a)/h),e=Math.min(60*e,360),0>e&&(e+=360),o=l/255*1e3/10,[e,i,o]}function a(t){var e=t[0],i=t[1],s=t[2],a=o(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[a,100*n,100*s]}function n(t){var e,i,o,s,a=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-a,1-n,1-r),e=(1-a-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,o=(1-r-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function l(t){return $[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,n=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*n]}function c(t){var e,i,o,s=h(t),a=s[0],n=s[1],r=s[2];return a/=95.047,n/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(a-n),o=200*(n-r),[e,i,o]}function d(t){return L(c(t))}function u(t){var e,i,o,s,a,n=t[0]/360,r=t[1]/100,l=t[2]/100;if(0==r)return a=255*l,[a,a,a];i=.5>l?l*(1+r):l+r-l*r,e=2*l-i,s=[0,0,0];for(var h=0;3>h;h++)o=n+1/3*-(h-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[h]=255*a;return s}function m(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function v(t){return a(u(t))}function p(t){return n(u(t))}function f(t){return l(u(t))}function x(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),n=255*o*(1-i),r=255*o*(1-i*a),l=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,l,n];case 1:return[r,o,n];case 2:return[n,o,l];case 3:return[n,r,o];case 4:return[l,n,o];case 5:return[o,n,r]}}function A(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function C(t){return a(x(t))}function y(t){return n(x(t))}function _(t){return l(x(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,l=t[2]/100,h=n+l;switch(h>1&&(n/=h,l/=h),e=Math.floor(6*a),i=1-l,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return o(w(t))}function P(t){return s(w(t))}function S(t){return n(w(t))}function I(t){return l(w(t))}function W(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,a*(1-r)+r),o=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*o]}function D(t){return o(W(t))}function O(t){return s(W(t))}function M(t){return a(W(t))}function V(t){return l(W(t))}function B(t){var e,i,o,s=t[0]/100,a=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*a+n*-.4986,i=s*-.9689+1.8758*a+.0415*n,o=.0557*s+a*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function R(t){var e,i,o,s=t[0],a=t[1],n=t[2];return s/=95.047,a/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*a-16,i=500*(s-a),o=200*(a-n),[e,i,o]}function T(t){return L(R(t))}function z(t){var e,i,o,s,a=t[0],n=t[1],r=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),o=.008859>=o/108.883?o=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],n=t[2];return e=Math.atan2(n,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+n*n),[s,o,i]}function F(t){return B(z(t))}function E(t){var e,i,o,s=t[0],a=t[1],n=t[2];return o=n/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function N(t){return z(E(t))}function H(t){return F(E(t))}function Y(t){return U[t]}function q(t){return o(Y(t))}function j(t){return s(Y(t))}function X(t){return a(Y(t))}function Z(t){return n(Y(t))}function Q(t){return c(Y(t))}function G(t){return h(Y(t))}e.exports={rgb2hsl:o,rgb2hsv:s,rgb2hwb:a,rgb2cmyk:n,rgb2keyword:l,rgb2xyz:h,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:m,hsl2hwb:v,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:x,hsv2hsl:A,hsv2hwb:C,hsv2cmyk:y,hsv2keyword:_,hwb2rgb:w,hwb2hsl:k,hwb2hsv:P,hwb2cmyk:S,hwb2keyword:I,cmyk2rgb:W,cmyk2hsl:D,cmyk2hsv:O,cmyk2hwb:M,cmyk2keyword:V,keyword2rgb:Y,keyword2hsl:q,keyword2hsv:j,keyword2hwb:X,keyword2cmyk:Z,keyword2lab:Q,keyword2xyz:G,xyz2rgb:B,xyz2lab:R,xyz2lch:T,lab2xyz:z,lab2rgb:F,lab2lch:L,lch2lab:E,lch2xyz:N,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var o=t("./conversions"),s=function(){return new h};for(var a in o){s[a+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),o[t](e)}}(a);var n=/(\w+)2(\w+)/.exec(a),r=n[1],l=n[2];s[r]=s[r]||{},s[r][l]=s[a]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=o[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return m(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function m(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function v(t,e){return 1>e||t[3]&&t[3]<1?g(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return C[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var A=t("color-name");e.exports={getRgba:o,getHsla:s,getRgb:n,getHsl:r,getHwb:a,getAlpha:l,hexString:h,rgbString:c,rgbaString:d,percentString:u,percentaString:m,hslString:v,hslaString:g,hwbString:p,keyword:f};var C={};for(var y in A)C[A[y]]=y},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105], +dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index f1e71472cb1..e442665cafc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,18 +1,18 @@ 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'), - replace = require('gulp-replace'), - htmlv = require('gulp-html-validator'), - inquirer = require('inquirer'), - semver = require('semver'), - exec = require('child_process').exec, - fs = require('fs'), - package = require('./package.json'), - bower = require('./bower.json'); + concat = require('gulp-concat'), + uglify = require('gulp-uglify'), + util = require('gulp-util'), + jshint = require('gulp-jshint'), + 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, + fs = require('fs'), + package = require('./package.json'), + bower = require('./bower.json'); var srcDir = './src/'; /* @@ -21,33 +21,46 @@ var srcDir = './src/'; * - 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+'*'); - } - srcFiles.push('./node_modules/color/dist/color.min.js'); - - return gulp.src(srcFiles) - .pipe(concat('Chart.js')) - .pipe(replace('{{ version }}', package.version)) - .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('build', function() { + + // Default to all of the chart types, with Chart.Core first + var srcFiles = [ + FileName('Core'), + FileName('Core.**'), + FileName('Scale'), + FileName('Scale.**'), + FileName('Animation'), + FileName('Tooltip'), + ], + 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 + '*'); + srcFiles.push(srcDir + '*'); + srcFiles.push(srcDir + '*'); + srcFiles.push(srcDir + '*'); + } + srcFiles.push('./node_modules/color/dist/color.min.js'); + + return gulp.src(srcFiles) + .pipe(concat('Chart.js')) + .pipe(replace('{{ version }}', package.version)) + .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'; + } }); /* @@ -56,65 +69,67 @@ gulp.task('build', function(){ * Output: - New version number written into package.json & bower.json */ -gulp.task('bump', function(complete){ - util.log('Current version:', util.colors.cyan(package.version)); - var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType){ - return versionType + ' (v' + semver.inc(package.version, versionType) + ')'; - }); - inquirer.prompt({ - type: 'list', - name: 'version', - message: 'What version update would you like?', - choices: choices - }, function(res){ - var increment = res.version.split(' ')[0], - newVersion = semver.inc(package.version, increment); - - // Set the new versions into the bower/package object - package.version = newVersion; - bower.version = newVersion; - - // Write these to their own files, then build the output - fs.writeFileSync('package.json', JSON.stringify(package, null, 2)); - fs.writeFileSync('bower.json', JSON.stringify(bower, null, 2)); - - complete(); - }); +gulp.task('bump', function(complete) { + util.log('Current version:', util.colors.cyan(package.version)); + var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType) { + return versionType + ' (v' + semver.inc(package.version, versionType) + ')'; + }); + inquirer.prompt({ + type: 'list', + name: 'version', + message: 'What version update would you like?', + choices: choices + }, function(res) { + var increment = res.version.split(' ')[0], + newVersion = semver.inc(package.version, increment); + + // Set the new versions into the bower/package object + package.version = newVersion; + bower.version = newVersion; + + // Write these to their own files, then build the output + fs.writeFileSync('package.json', JSON.stringify(package, null, 2)); + fs.writeFileSync('bower.json', JSON.stringify(bower, null, 2)); + + complete(); + }); }); -gulp.task('release', ['build'], function(){ - exec('git tag -a v' + package.version); +gulp.task('release', ['build'], function() { + exec('git tag -a v' + package.version); }); -gulp.task('jshint', function(){ - return gulp.src(srcDir + '*.js') - .pipe(jshint()) - .pipe(jshint.reporter('default')); +gulp.task('jshint', function() { + return gulp.src(srcDir + '*.js') + .pipe(jshint()) + .pipe(jshint.reporter('default')); }); -gulp.task('valid', function(){ - return gulp.src('samples/*.html') - .pipe(htmlv()); +gulp.task('valid', function() { + return gulp.src('samples/*.html') + .pipe(htmlv()); }); -gulp.task('library-size', function(){ - return gulp.src('Chart.min.js') - .pipe(size({ - gzip: true - })); +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('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('watch', function() { + gulp.watch('./src/*', ['build']); }); gulp.task('test', ['jshint', 'valid']); @@ -123,16 +138,16 @@ gulp.task('size', ['library-size', 'module-sizes']); gulp.task('default', ['build', 'watch']); -gulp.task('server', function(){ - connect.server({ - port: 8000 - }); +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('_open', function() { + exec('open http://localhost:8000'); + exec('subl .'); }); gulp.task('dev', ['server', 'default']); diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html index bb4b58a7791..227a04c6b70 100644 --- a/samples/line-multi-axis.html +++ b/samples/line-multi-axis.html @@ -8,10 +8,8 @@ -
    -
    - -
    +
    +
    +
    +
    +
    + + + + +
    + +
    + + + + + From ec7b87d69c6168d25166784796f8026b2cb5715e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 12 Jun 2015 20:50:26 -0400 Subject: [PATCH 131/424] Move some functions into the category scale. This cleans up the bar chart interface & allows for waterfall charts by settings `stacked` to false on the category axis but `stacked` to true on the y axis --- samples/line-multi-axis.html | 8 +- src/charts/chart.bar.js | 29 +-- src/charts/chart.line.js | 6 +- src/scales/scale.category.js | 440 ++++++++++++++++++----------------- 4 files changed, 237 insertions(+), 246 deletions(-) diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html index 87c5775d2f7..97833376e73 100644 --- a/samples/line-multi-axis.html +++ b/samples/line-multi-axis.html @@ -8,7 +8,7 @@ -
    +
    @@ -53,14 +53,14 @@ stacked: false, scales: { xAxes: [{ - display: false, + display: true, gridLines: { offsetGridLines: false } }], yAxes: [{ type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: false, + display: true, position: "left", id: "y-axis-1", @@ -91,7 +91,7 @@ } }, { type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: false, + display: true, position: "right", id: "y-axis-2", diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index cfada7c59b2..23af96b2a1a 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -281,34 +281,7 @@ ctx: this.chart.ctx, options: this.options.scales.xAxes[0], id: this.options.scales.xAxes[0].id, - calculateRange: function() { - this.labels = self.data.labels; - this.min = 0; - this.max = this.labels.length; - }, - calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * this.options.categorySpacing); - }, - calculateBarWidth: function(datasetCount) { - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); - - if (self.options.stacked) { - return baseWidth; - } - return (baseWidth / datasetCount); - }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); - - if (self.options.stacked) { - return xAbsolute + barWidth / 2; - } - - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; - }, + data: this.data, }); this.scales[xScale.id] = xScale; diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 20a5d495e62..b49789ead20 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -402,11 +402,7 @@ var xScale = new ScaleClass({ ctx: this.chart.ctx, options: this.options.scales.xAxes[0], - calculateRange: function() { - this.labels = self.data.labels; - this.min = 0; - this.max = this.labels.length; - }, + data: this.data, id: this.options.scales.xAxes[0].id, }); this.scales[xScale.id] = xScale; diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index a6d9ad77f0b..3d96f8e9b3d 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -1,213 +1,235 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var DatasetScale = Chart.Element.extend({ - // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset - calculateRange: helpers.noop, - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - getPixelForValue: function(value, index, includeOffset) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - if (this.isHorizontal()) { - var isRotated = (this.labelRotation > 0); - var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; - - if (this.options.gridLines.offsetGridLines && includeOffset) { - valueOffset += (valueWidth / 2); - } - - return this.left + Math.round(valueOffset); - } else { - return this.top + (index * (this.height / this.max)); - } - }, - calculateLabelRotation: function(maxHeight, margins) { - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - this.ctx.font = labelFont; - - var firstWidth = this.ctx.measureText(this.labels[0]).width; - var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; - var firstRotated; - var lastRotated; - - this.paddingRight = lastWidth / 2 + 3; - this.paddingLeft = firstWidth / 2 + 3; - - this.labelRotation = 0; - - if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - var cosRotation; - var sinRotation; - var firstRotatedWidth; - - this.labelWidth = originalLabelWidth; - - //Allow 3 pixels x2 padding either side for label readability - // only the index matters for a dataset scale, but we want a consistent interface between scales - var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; - - //Max label rotate should be 90 - also act as a loop counter - while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { - cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); - sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); - - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; - - // We're right aligning the text now. - if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { - this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; - } - - this.paddingRight = this.options.labels.fontSize / 2; - - if (sinRotation * originalLabelWidth > maxHeight) { - // go back one step - this.labelRotation--; - break; - } - - this.labelRotation++; - this.labelWidth = cosRotation * originalLabelWidth; - - } - } else { - this.labelWidth = 0; - this.paddingRight = 0; - this.paddingLeft = 0; - } - - if (margins) { - this.paddingLeft -= margins.left; - this.paddingRight -= margins.right; - - this.paddingLeft = Math.max(this.paddingLeft, 0); - this.paddingRight = Math.max(this.paddingRight, 0); - } - - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight, margins) { - this.calculateRange(); - this.calculateLabelRotation(maxHeight, margins); - - var minSize = { - width: 0, - height: 0, - }; - - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - // Width - if (this.isHorizontal()) { - minSize.width = maxWidth; - this.width = maxWidth; - } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } - - // Height - if (this.isHorizontal()) { - var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); - } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - setContextLineSettings = true; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; - var isRotated = this.labelRotation !== 0; - - helpers.each(this.labels, function(label, index) { - var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines - var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) - - if (this.options.gridLines.show) { - if (index === 0) { - // Draw the first index specially - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xLineValue, yTickStart); - this.ctx.lineTo(xLineValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xLineValue, chartArea.top); - this.ctx.lineTo(xLineValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - } - - if (this.options.labels.show) { - this.ctx.save(); - this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); - this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); - this.ctx.font = this.font; - this.ctx.textAlign = (isRotated) ? "right" : "center"; - this.ctx.textBaseline = (isRotated) ? "middle" : "top"; - this.ctx.fillText(label, 0, 0); - this.ctx.restore(); - } - }, this); - } else { - // Vertical - if (this.options.gridLines.show) {} - - if (this.options.labels.show) { - // Draw the labels - } - } - } - } - }); - Chart.scales.registerScaleType("category", DatasetScale); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var DatasetScale = Chart.Element.extend({ + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + getPixelForValue: function(value, index, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.data.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.data.labels.length)); + } + }, + // For bar charts + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * this.options.categorySpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); + + if (this.options.stacked) { + return baseWidth; + } + return (baseWidth / datasetCount); + }, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); + + if (this.options.stacked) { + return xAbsolute + barWidth / 2; + } + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; + }, + + calculateLabelRotation: function(maxHeight, margins) { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstWidth = this.ctx.measureText(this.data.labels[0]).width; + var lastWidth = this.ctx.measureText(this.data.labels[this.data.labels.length - 1]).width; + var firstRotated; + var lastRotated; + + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; + + this.labelRotation = 0; + + if (this.options.display) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; + + this.labelWidth = originalLabelWidth; + + //Allow 3 pixels x2 padding either side for label readability + // only the index matters for a dataset scale, but we want a consistent interface between scales + var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + + //Max label rotate should be 90 - also act as a loop counter + while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; + } + + this.paddingRight = this.options.labels.fontSize / 2; + + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } + + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; + + } + } else { + this.labelWidth = 0; + this.paddingRight = 0; + this.paddingLeft = 0; + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + } + + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight, margins) { + this.calculateLabelRotation(maxHeight, margins); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; + this.width = maxWidth; + } else if (this.options.display) { + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + // Height + if (this.isHorizontal()) { + var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else if (this.options.display) { + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + + helpers.each(this.data.labels, function(label, index) { + var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } + + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) {} + + if (this.options.labels.show) { + // Draw the labels + } + } + } + } + }); + Chart.scales.registerScaleType("category", DatasetScale); From d2ef4c983186241a72b6ee4b163f3022c6fe9741 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 12 Jun 2015 21:15:15 -0400 Subject: [PATCH 132/424] Move more data into the linear scale.This simplifies `buildScale` for line and bar charts --- samples/bar-stacked.html | 6 +- src/charts/chart.bar.js | 130 +----- src/charts/chart.line.js | 76 +--- src/scales/scale.linear.js | 875 ++++++++++++++++++++++--------------- 4 files changed, 521 insertions(+), 566 deletions(-) diff --git a/samples/bar-stacked.html b/samples/bar-stacked.html index da9e4fb5c47..1d7257f3de7 100644 --- a/samples/bar-stacked.html +++ b/samples/bar-stacked.html @@ -43,7 +43,11 @@ data: barChartData, options: { responsive: true, - stacked: true, + scales: { + yAxes: [{ + stacked: true + }] + } } }); }; diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index 23af96b2a1a..aa7f06a88fa 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -219,59 +219,6 @@ buildScale: function(labels) { var self = this; - // Function to determine the range of all the - var calculateYRange = function() { - this.min = null; - this.max = null; - - var positiveValues = []; - var negativeValues = []; - - if (self.options.stacked) { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - positiveValues[index] = positiveValues[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - - if (self.options.relativePoints) { - positiveValues[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - positiveValues[index] += value; - } - } - }, this); - } - }, this); - - var values = positiveValues.concat(negativeValues); - this.min = helpers.min(values); - this.max = helpers.max(values); - - } else { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }; - // Map of scale ID to scale object so we can lookup later this.scales = {}; @@ -291,82 +238,7 @@ var scale = new ScaleClass({ ctx: this.chart.ctx, options: yAxisOptions, - calculateRange: calculateYRange, - calculateBarBase: function(datasetIndex, index) { - var base = 0; - - if (self.options.stacked) { - - var value = self.data.datasets[datasetIndex].data[index]; - - if (value < 0) { - for (var i = 0; i < datasetIndex; i++) { - if (self.data.datasets[i].yAxisID === this.id) { - base += self.data.datasets[i].data[index] < 0 ? self.data.datasets[i].data[index] : 0; - } - } - } else { - for (var j = 0; j < datasetIndex; j++) { - if (self.data.datasets[j].yAxisID === this.id) { - base += self.data.datasets[j].data[index] > 0 ? self.data.datasets[j].data[index] : 0; - } - } - } - - return this.getPixelForValue(base); - } - - base = this.getPixelForValue(this.min); - - if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { - base = this.getPixelForValue(0); - base += this.options.gridLines.lineWidth; - } else if (this.min < 0 && this.max < 0) { - // All values are negative. Use the top as the base - base = this.getPixelForValue(this.max); - } - - return base; - - }, - calculateBarY: function(datasetIndex, index) { - - var value = self.data.datasets[datasetIndex].data[index]; - - if (self.options.stacked) { - - var sumPos = 0, - sumNeg = 0; - - for (var i = 0; i < datasetIndex; i++) { - if (self.data.datasets[i].data[index] < 0) { - sumNeg += self.data.datasets[i].data[index] || 0; - } else { - sumPos += self.data.datasets[i].data[index] || 0; - } - } - - if (value < 0) { - return this.getPixelForValue(sumNeg + value); - } else { - return this.getPixelForValue(sumPos + value); - } - - return this.getPixelForValue(value); - } - - var offset = 0; - - for (var j = datasetIndex; j < self.data.datasets.length; j++) { - if (j === datasetIndex && value) { - offset += value; - } else { - offset = offset + value; - } - } - - return this.getPixelForValue(value); - }, + data: this.data, id: yAxisOptions.id, }); diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index b49789ead20..60163ce08a8 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -342,58 +342,6 @@ buildScale: function() { var self = this; - // Function to determine the range of all the - var calculateYRange = function() { - this.min = null; - this.max = null; - - var positiveValues = []; - var negativeValues = []; - - if (self.options.stacked) { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - positiveValues[index] = positiveValues[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - - if (self.options.relativePoints) { - positiveValues[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - positiveValues[index] += value; - } - } - }, this); - } - }, this); - - var values = positiveValues.concat(negativeValues); - this.min = helpers.min(values); - this.max = helpers.max(values); - } else { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }; - // Map of scale ID to scale object so we can lookup later this.scales = {}; @@ -413,29 +361,7 @@ var scale = new ScaleClass({ ctx: this.chart.ctx, options: yAxisOptions, - calculateRange: calculateYRange, - getPointPixelForValue: function(value, index, datasetIndex) { - if (self.options.stacked) { - var offsetPos = 0; - var offsetNeg = 0; - - for (var i = 0; i < datasetIndex; ++i) { - if (self.data.datasets[i].data[index] < 0) { - offsetNeg += self.data.datasets[i].data[index]; - } else { - offsetPos += self.data.datasets[i].data[index]; - } - } - - if (value < 0) { - return this.getPixelForValue(offsetNeg + value); - } else { - return this.getPixelForValue(offsetPos + value); - } - } else { - return this.getPixelForValue(value); - } - }, + data: this.data, id: yAxisOptions.id, }); diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 021cd866087..b5da78e2bbe 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -1,365 +1,518 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var LinearScale = Chart.Element.extend({ - calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - generateTicks: function(width, height) { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw - - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; - - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); - } - } else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph - - var maxTicks; - - if (this.isHorizontal()) { - maxTicks = Math.min(11, Math.ceil(width / 50)); - } else { - // The factor of 2 used to scale the font size has been experimentally determined. - maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); - } - - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } - - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; - - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - } - } - - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } - - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, - buildLabels: function() { - // We assume that this has been run after ticks have been generated. We try to figure out - // a label for each tick. - this.labels = []; - - helpers.each(this.ticks, function(tick, index, ticks) { - var label; - - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.lables.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick - }); - } - - this.labels.push(label ? label : ""); // empty string will not render so we're good - }, this); - }, - getPixelForValue: function(value) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - var pixel; - var range = this.max - this.min; - - if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.min)); - } else { - // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.min)); - } - - return pixel; - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { - this.calculateRange(); - this.generateTicks(maxWidth, maxHeight); - this.buildLabels(); - - var minSize = { - width: 0, - height: 0, - }; - - // In a horizontal axis, we need some room for the scale to be drawn - // - // ----------------------------------------------------- - // | | | | | - // - // In a vertical axis, we need some room for the scale to be drawn. - // The actual grid lines will be drawn on the chart area, however, we need to show - // ticks where the axis actually is. - // We will allocate 25px for this width - // | - // -| - // | - // | - // -| - // | - // | - // -| - - - // Width - if (this.isHorizontal()) { - minSize.width = maxWidth; // fill all the width - } else { - minSize.width = this.options.gridLines.show && this.options.display ? 10 : 0; - } - - // height - if (this.isHorizontal()) { - minSize.height = this.options.gridLines.show && this.options.display ? 10 : 0; - } else { - minSize.height = maxHeight; // fill all the height - } - - - - if (this.options.labels.show && this.options.display) { - // Don't bother fitting the labels if we are not showing them - var labelFont = helpers.fontString(this.options.labels.fontSize, - this.options.labels.fontStyle, this.options.labels.fontFamily); - - if (this.isHorizontal()) { - // A horizontal axis is more constrained by the height. - var maxLabelHeight = maxHeight - minSize.height; - var labelHeight = 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(maxHeight, minSize.height + labelHeight); - } else { - // A vertical axis is more constrained by the width. Labels are the dominant factor - // here, so get that length first - var maxLabelWidth = maxWidth - minSize.width; - var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - if (largestTextWidth < maxLabelWidth) { - // We don't need all the room - minSize.width += largestTextWidth; - } else { - // Expand to max size - minSize.width = maxWidth; - } - } - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - var hasZero; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - if (this.options.gridLines.show) { - // Draw the horizontal line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { - return tick === 0; - }) !== undefined; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; - var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; - - helpers.each(this.ticks, function(tick, index) { - // Grid lines are vertical - var xValue = this.getPixelForValue(tick); - - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the left if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xValue, yTickStart); - this.ctx.lineTo(xValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xValue, chartArea.top); - this.ctx.lineTo(xValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - }, this); - } - - if (this.options.labels.show) { - // Draw the labels - - var labelStartY; - - if (this.options.position == "top") { - labelStartY = this.bottom - 10; - this.ctx.textBaseline = "bottom"; - } else { - // bottom side - labelStartY = this.top + 10; - this.ctx.textBaseline = "top"; - } - - this.ctx.textAlign = "center"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - helpers.each(this.labels, function(label, index) { - var xValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, xValue, labelStartY); - }, this); - } - } else { - // Vertical - if (this.options.gridLines.show) { - - // Draw the vertical line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { - return tick === 0; - }) !== undefined; - var xTickStart = this.options.position == "right" ? this.left : this.right - 5; - var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; - - helpers.each(this.ticks, function(tick, index) { - // Grid lines are horizontal - var yValue = this.getPixelForValue(tick); - - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the bottom if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; // use boolean to indicate that we only want to do this once - } - - yValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xTickStart, yValue); - this.ctx.lineTo(xTickEnd, yValue); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(chartArea.left, yValue); - this.ctx.lineTo(chartArea.right, yValue); - } - - this.ctx.stroke(); - }, this); - } - - if (this.options.labels.show) { - // Draw the labels - - var labelStartX; - - if (this.options.position == "left") { - labelStartX = this.right - 10; - this.ctx.textAlign = "right"; - } else { - // right side - labelStartX = this.left + 5; - this.ctx.textAlign = "left"; - } - - this.ctx.textBaseline = "middle"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - helpers.each(this.labels, function(label, index) { - var yValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, labelStartX, yValue); - }, this); - } - } - } - } - }); - Chart.scales.registerScaleType("linear", LinearScale); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var LinearScale = Chart.Element.extend({ + calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + generateTicks: function(width, height) { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks; + + if (this.isHorizontal()) { + maxTicks = Math.min(11, Math.ceil(width / 50)); + } else { + // The factor of 2 used to scale the font size has been experimentally determined. + maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); + } + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + this.labels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.lables.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.labels.push(label ? label : ""); // empty string will not render so we're good + }, this); + }, + getPixelForValue: function(value) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + var pixel; + var range = this.max - this.min; + + if (this.isHorizontal()) { + pixel = this.left + (this.width / range * (value - this.min)); + } else { + // Bottom - top since pixels increase downard on a screen + pixel = this.bottom - (this.height / range * (value - this.min)); + } + + return pixel; + }, + + // Functions needed for line charts + calculateRange: function() { + this.min = null; + this.max = null; + + var positiveValues = []; + var negativeValues = []; + + if (this.options.stacked) { + helpers.each(this.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + + if (this.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); + } + }, this); + + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); + + } else { + helpers.each(this.data.datasets, function(dataset) { + if (dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }, + + getPointPixelForValue: function(value, index, datasetIndex) { + if (this.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + + for (var i = 0; i < datasetIndex; ++i) { + if (this.data.datasets[i].data[index] < 0) { + offsetNeg += this.data.datasets[i].data[index]; + } else { + offsetPos += this.data.datasets[i].data[index]; + } + } + + if (value < 0) { + return this.getPixelForValue(offsetNeg + value); + } else { + return this.getPixelForValue(offsetPos + value); + } + } else { + return this.getPixelForValue(value); + } + }, + + // Functions needed for bar charts + calculateBarBase: function(datasetIndex, index) { + var base = 0; + + if (this.options.stacked) { + + var value = this.data.datasets[datasetIndex].data[index]; + + if (value < 0) { + for (var i = 0; i < datasetIndex; i++) { + if (this.data.datasets[i].yAxisID === this.id) { + base += this.data.datasets[i].data[index] < 0 ? this.data.datasets[i].data[index] : 0; + } + } + } else { + for (var j = 0; j < datasetIndex; j++) { + if (this.data.datasets[j].yAxisID === this.id) { + base += this.data.datasets[j].data[index] > 0 ? this.data.datasets[j].data[index] : 0; + } + } + } + + return this.getPixelForValue(base); + } + + base = this.getPixelForValue(this.min); + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.getPixelForValue(0); + base += this.options.gridLines.lineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.getPixelForValue(this.max); + } + + return base; + + }, + calculateBarY: function(datasetIndex, index) { + var value = this.data.datasets[datasetIndex].data[index]; + + if (this.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (this.data.datasets[i].data[index] < 0) { + sumNeg += this.data.datasets[i].data[index] || 0; + } else { + sumPos += this.data.datasets[i].data[index] || 0; + } + } + + if (value < 0) { + return this.getPixelForValue(sumNeg + value); + } else { + return this.getPixelForValue(sumPos + value); + } + + return this.getPixelForValue(value); + } + + var offset = 0; + + for (var j = datasetIndex; j < this.data.datasets.length; j++) { + if (j === datasetIndex && value) { + offset += value; + } else { + offset = offset + value; + } + } + + return this.getPixelForValue(value); + }, + + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.generateTicks(maxWidth, maxHeight); + this.buildLabels(); + + var minSize = { + width: 0, + height: 0, + }; + + // In a horizontal axis, we need some room for the scale to be drawn + // + // ----------------------------------------------------- + // | | | | | + // + // In a vertical axis, we need some room for the scale to be drawn. + // The actual grid lines will be drawn on the chart area, however, we need to show + // ticks where the axis actually is. + // We will allocate 25px for this width + // | + // -| + // | + // | + // -| + // | + // | + // -| + + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; // fill all the width + } else { + minSize.width = this.options.gridLines.show && this.options.display ? 10 : 0; + } + + // height + if (this.isHorizontal()) { + minSize.height = this.options.gridLines.show && this.options.display ? 10 : 0; + } else { + minSize.height = maxHeight; // fill all the height + } + + + + if (this.options.labels.show && this.options.display) { + // Don't bother fitting the labels if we are not showing them + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.isHorizontal()) { + // A horizontal axis is more constrained by the height. + var maxLabelHeight = maxHeight - minSize.height; + var labelHeight = 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + } else { + // A vertical axis is more constrained by the width. Labels are the dominant factor + // here, so get that length first + var maxLabelWidth = maxWidth - minSize.width; + var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (largestTextWidth < maxLabelWidth) { + // We don't need all the room + minSize.width += largestTextWidth; + } else { + // Expand to max size + minSize.width = maxWidth; + } + } + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + var hasZero; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + if (this.options.gridLines.show) { + // Draw the horizontal line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; + var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are vertical + var xValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the left if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xValue, chartArea.top); + this.ctx.lineTo(xValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartY; + + if (this.options.position == "top") { + labelStartY = this.bottom - 10; + this.ctx.textBaseline = "bottom"; + } else { + // bottom side + labelStartY = this.top + 10; + this.ctx.textBaseline = "top"; + } + + this.ctx.textAlign = "center"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var xValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, xValue, labelStartY); + }, this); + } + } else { + // Vertical + if (this.options.gridLines.show) { + + // Draw the vertical line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var xTickStart = this.options.position == "right" ? this.left : this.right - 5; + var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are horizontal + var yValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the bottom if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; // use boolean to indicate that we only want to do this once + } + + yValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(chartArea.left, yValue); + this.ctx.lineTo(chartArea.right, yValue); + } + + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartX; + + if (this.options.position == "left") { + labelStartX = this.right - 10; + this.ctx.textAlign = "right"; + } else { + // right side + labelStartX = this.left + 5; + this.ctx.textAlign = "left"; + } + + this.ctx.textBaseline = "middle"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var yValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, labelStartX, yValue); + }, this); + } + } + } + } + }); + Chart.scales.registerScaleType("linear", LinearScale); }).call(this); From 49fe78643ac3833d034502e1d16f0b8a76a6346a Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 12 Jun 2015 21:16:23 -0400 Subject: [PATCH 133/424] Removed unused options from the bar and line charts --- src/charts/chart.bar.js | 3 --- src/charts/chart.line.js | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index aa7f06a88fa..0cc3030a5dd 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -6,9 +6,6 @@ helpers = Chart.helpers; var defaultConfig = { - - stacked: false, - hover: { mode: "label" }, diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 60163ce08a8..c5aeadd7e43 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -6,9 +6,6 @@ helpers = Chart.helpers; var defaultConfig = { - - stacked: false, - hover: { mode: "label" }, From e55c0d494540336accb0abde3ed2920de73abb0a Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 12 Jun 2015 21:46:47 -0400 Subject: [PATCH 134/424] Push some of the scatter scale information down to the linear scale. --- src/charts/chart.scatter.js | 1144 ++++++++++++++++------------------ src/scales/scale.category.js | 4 +- src/scales/scale.linear.js | 21 +- 3 files changed, 565 insertions(+), 604 deletions(-) diff --git a/src/charts/chart.scatter.js b/src/charts/chart.scatter.js index 12d079a68d4..6932637923a 100644 --- a/src/charts/chart.scatter.js +++ b/src/charts/chart.scatter.js @@ -1,602 +1,550 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - hover: { - mode: 'single', - }, - - scales: { - xAxes: [{ - type: "linear", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } - }], - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - - tooltips: { - template: "(<%= value.x %>, <%= value.y %>)", - multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", - }, - - }; - - - Chart.Type.extend({ - name: "Scatter", - defaults: defaultConfig, - initialize: function() { - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - //Custom Point Defaults - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - - dataset.metaData = []; - - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); - - }, this); - - // The line chart onlty supports a single x axis because the x axis is always a dataset axis - if (!dataset.xAxisID) { - dataset.xAxisID = this.options.scales.xAxes[0].id; - } - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - - }, this); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[index]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[index]; - }, - resetElements: function() { - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), // value not used in dataset scale, but we want a consistent API between scales - y: yScalePoint, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), - - // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function() { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var yScale = this.scales[dataset.yAxisID]; - var scaleBase; - - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), - y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), - - // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(); - }, - buildScale: function() { - var self = this; - - var calculateXRange = function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { - // Only set the scale range for datasets that actually use this axis - if (dataset.xAxisID === this.id) { - helpers.each(dataset.data, function(value) { - if (this.min === null) { - this.min = value.x; - } else if (value.x < this.min) { - this.min = value.x; - } - - if (this.max === null) { - this.max = value.x; - } else if (value.x > this.max) { - this.max = value.x; - } - }, this); - } - }, this); - }; - - var calculateYRange = function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value) { - if (this.min === null) { - this.min = value.y; - } else if (value.y < this.min) { - this.min = value.y; - } - - if (this.max === null) { - this.max = value.y; - } else if (value.y > this.max) { - this.max = value.y; - } - }, this); - } - }, this); - }; - - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - calculateRange: calculateXRange, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - calculateRange: calculateYRange, - id: yAxisOptions.id, - getPointPixelForValue: function(value, index, datasetIndex) { - return this.getPixelForValue(value); - } - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + hover: { + mode: 'single', + }, + + scales: { + xAxes: [{ + type: "linear", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + beginAtZero: false, + integersOnly: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", + + tooltips: { + template: "(<%= value.x %>, <%= value.y %>)", + multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", + }, + + }; + + + Chart.Type.extend({ + name: "Scatter", + defaults: defaultConfig, + initialize: function() { + + // Events + helpers.bindEvents(this, this.options.events, this.events); + + //Custom Point Defaults + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); + + dataset.metaData = []; + + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + + }, this); + + // The line chart onlty supports a single x axis because the x axis is always a dataset axis + if (!dataset.xAxisID) { + dataset.xAxisID = this.options.scales.xAxes[0].id; + } + + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } + + }, this); + + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[index]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[index]; + }, + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), // value not used in dataset scale, but we want a consistent API between scales + y: yScalePoint, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function() { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + var yScale = this.scales[dataset.yAxisID]; + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + helpers.extend(dataset.metaDataset, { + // Utility + _scale: yScale, + _datasetIndex: datasetIndex, + // Data + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: scaleBase, + }, + }); + + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), + y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), + + // Tooltip + hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(); + }, + buildScale: function() { + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + + }, + }); }).call(this); diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 3d96f8e9b3d..f20457c4a74 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -27,7 +27,9 @@ return this.top + (index * (this.height / this.data.labels.length)); } }, - // For bar charts + + + // Functions needed for bar charts calculateBaseWidth: function() { return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * this.options.categorySpacing); }, diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index b5da78e2bbe..11e1bdfc247 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -113,6 +113,10 @@ this.labels.push(label ? label : ""); // empty string will not render so we're good }, this); }, + // Get the correct value. If the value type is object get the x or y based on whether we are horizontal or not + getRightValue: function(rawValue) { + return typeof rawValue === "object" ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; + }, getPixelForValue: function(value) { // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined @@ -139,8 +143,11 @@ if (this.options.stacked) { helpers.each(this.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { + if (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(rawValue, index) { + + var value = this.getRightValue(rawValue); + positiveValues[index] = positiveValues[index] || 0; negativeValues[index] = negativeValues[index] || 0; @@ -163,8 +170,10 @@ } else { helpers.each(this.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { + if (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(rawValue, index) { + var value = this.getRightValue(rawValue); + if (this.min === null) { this.min = value; } else if (value < this.min) { @@ -182,7 +191,9 @@ } }, - getPointPixelForValue: function(value, index, datasetIndex) { + getPointPixelForValue: function(rawValue, index, datasetIndex) { + var value = this.getRightValue(rawValue); + if (this.options.stacked) { var offsetPos = 0; var offsetNeg = 0; From d37e65c58cf4253e33d732c56f8862458de84597 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 12 Jun 2015 22:07:07 -0400 Subject: [PATCH 135/424] Convert line chart to tabs from spaces --- src/charts/chart.line.js | 1086 +++++++++++++++++++------------------- 1 file changed, 543 insertions(+), 543 deletions(-) diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index c5aeadd7e43..651820e6bc9 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -1,547 +1,547 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - hover: { - mode: "label" - }, - - scales: { - xAxes: [{ - type: "category", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: false, - }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } - }], - }, - }; - - - Chart.Type.extend({ - name: "Line", - defaults: defaultConfig, - initialize: function() { - - var _this = this; - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - - dataset.metaData = []; - - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); - - }, this); - - // The line chart onlty supports a single x axis because the x axis is always a dataset axis - dataset.xAxisID = this.options.scales.xAxes[0].id; - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - - }, this); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[index]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[index]; - }, - resetElements: function() { - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales - y: yScalePoint, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function(animationDuration) { - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var yScale = this.scales[dataset.yAxisID]; - var scaleBase; - - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.options.elements.line.tension), - backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.options.elements.line.backgroundColor), - borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.options.elements.line.borderWidth), - borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.options.elements.line.borderColor), - fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill), - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales - y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(animationDuration); - }, - buildScale: function() { - var self = this; - - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].type); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - data: this.data, - id: this.options.scales.xAxes[0].id, - }); - this.scales[xScale.id] = xScale; - - // Build up all the y scales - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + type: "category", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + beginAtZero: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, + }; + + + Chart.Type.extend({ + name: "Line", + defaults: defaultConfig, + initialize: function() { + + var _this = this; + + // Events + helpers.bindEvents(this, this.options.events, this.events); + + // Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); + + dataset.metaData = []; + + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + + }, this); + + // The line chart onlty supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; + + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } + + }, this); + + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[index]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[index]; + }, + resetElements: function() { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScalePoint, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function(animationDuration) { + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + var yScale = this.scales[dataset.yAxisID]; + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + helpers.extend(dataset.metaDataset, { + // Utility + _scale: yScale, + _datasetIndex: datasetIndex, + // Data + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.options.elements.line.tension), + backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.options.elements.line.backgroundColor), + borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.options.elements.line.borderWidth), + borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.options.elements.line.borderColor), + fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill), + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: scaleBase, + }, + }); + + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + helpers.extend(point, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(animationDuration); + }, + buildScale: function() { + var self = this; + + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].type); + var xScale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scales.xAxes[0], + data: this.data, + id: this.options.scales.xAxes[0].id, + }); + this.scales[xScale.id] = xScale; + + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + this.lastActive = this.lastActive || []; + + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + }); }).call(this); From 6185f156eab0ae946b75c9f9c769d79140c25e5a Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 12 Jun 2015 22:35:48 -0400 Subject: [PATCH 136/424] Make the line and scatter charts almost identical. Next step is to merge them --- src/charts/chart.line.js | 37 ++++++++------- src/charts/chart.scatter.js | 91 +++++++++++++++++++----------------- src/scales/scale.category.js | 14 +++--- 3 files changed, 76 insertions(+), 66 deletions(-) diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 651820e6bc9..d68a9964e16 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -101,15 +101,17 @@ _index: index, _chart: this.chart, _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, + x: 0, + y: 0, }, })); }, this); // The line chart onlty supports a single x axis because the x axis is always a dataset axis - dataset.xAxisID = this.options.scales.xAxes[0].id; + if (!dataset.xAxisID) { + dataset.xAxisID = this.options.scales.xAxes[0].id; + } if (!dataset.yAxisID) { dataset.yAxisID = this.options.scales.yAxes[0].id; @@ -169,7 +171,7 @@ // Desired view properties _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), y: yScalePoint, // Appearance @@ -280,7 +282,7 @@ // Desired view properties _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales + x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), // Appearance @@ -337,22 +339,23 @@ this.render(animationDuration); }, buildScale: function() { - var self = this; - // Map of scale ID to scale object so we can lookup later this.scales = {}; - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].type); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - data: this.data, - id: this.options.scales.xAxes[0].id, - }); - this.scales[xScale.id] = xScale; + // Build the x axes + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); - // Build up all the y scales + // Build the y axes helpers.each(this.options.scales.yAxes, function(yAxisOptions) { var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); var scale = new ScaleClass({ diff --git a/src/charts/chart.scatter.js b/src/charts/chart.scatter.js index 6932637923a..c1b0148bcf8 100644 --- a/src/charts/chart.scatter.js +++ b/src/charts/chart.scatter.js @@ -30,7 +30,6 @@ // scale numbers beginAtZero: false, - integersOnly: false, override: null, // label settings @@ -62,7 +61,6 @@ // scale numbers beginAtZero: false, - integersOnly: false, override: null, // label settings @@ -96,7 +94,7 @@ // Events helpers.bindEvents(this, this.options.events, this.events); - //Custom Point Defaults + // Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.metaDataset = new Chart.Line({ _chart: this.chart, @@ -112,8 +110,8 @@ _index: index, _chart: this.chart, _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, + x: 0, + y: 0, }, })); @@ -182,19 +180,19 @@ // Desired view properties _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), // value not used in dataset scale, but we want a consistent API between scales + x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), y: yScalePoint, // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), }, }); }, this); @@ -235,7 +233,7 @@ point.pivot(); }, this); }, - update: function() { + update: function(animationDuration) { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines @@ -260,11 +258,11 @@ // Model _model: { // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.options.elements.line.tension), + backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.options.elements.line.backgroundColor), + borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.options.elements.line.borderWidth), + borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.options.elements.line.borderColor), + fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill), skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, // Scale @@ -292,19 +290,19 @@ // Desired view properties _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), - y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), + x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), + y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), }, }); }, this); @@ -346,12 +344,13 @@ point.pivot(); }, this); - this.render(); + this.render(animationDuration); }, buildScale: function() { // Map of scale ID to scale object so we can lookup later this.scales = {}; + // Build the x axes helpers.each(this.options.scales.xAxes, function(xAxisOptions) { var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type); var scale = new ScaleClass({ @@ -364,6 +363,7 @@ this.scales[scale.id] = scale; }, this); + // Build the y axes helpers.each(this.options.scales.yAxes, function(yAxisOptions) { var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); var scale = new ScaleClass({ @@ -408,32 +408,37 @@ this.tooltip.transition(easingDecimal).draw(); }, events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } // On Hover hook if (this.options.hover.onHover) { this.options.hover.onHover.call(this, this.active); } + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + var dataset; var index; // Remove styling for last active (even if it may still be active) @@ -443,7 +448,7 @@ dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; index = this.lastActive[0]._index; - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); @@ -453,7 +458,7 @@ dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; index = this.lastActive[i]._index; - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); @@ -473,7 +478,7 @@ dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); @@ -483,7 +488,7 @@ dataset = this.data.datasets[this.active[i]._datasetIndex]; index = this.active[i]._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); @@ -535,7 +540,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hoverAnimationDuration); + this.render(this.options.hover.animationDuration); } } diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index f20457c4a74..a4e0df65435 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -9,7 +9,7 @@ isHorizontal: function() { return this.options.position == "top" || this.options.position == "bottom"; }, - getPixelForValue: function(value, index, includeOffset) { + getPixelForValue: function(value, index, datasetIndex, includeOffset) { // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined if (this.isHorizontal()) { @@ -27,11 +27,13 @@ return this.top + (index * (this.height / this.data.labels.length)); } }, - + getPointPixelForValue: function(value, index, datasetIndex) { + return this.getPixelForValue(value, index, datasetIndex, true); + }, // Functions needed for bar charts calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * this.options.categorySpacing); + return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); }, calculateBarWidth: function(datasetCount) { //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset @@ -44,7 +46,7 @@ }, calculateBarX: function(datasetCount, datasetIndex, elementIndex) { var xWidth = this.calculateBaseWidth(), - xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), + xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), barWidth = this.calculateBarWidth(datasetCount); if (this.options.stacked) { @@ -174,8 +176,8 @@ var isRotated = this.labelRotation !== 0; helpers.each(this.data.labels, function(label, index) { - var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines - var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) + var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) if (this.options.gridLines.show) { if (index === 0) { From 0486db1e74bb1bebeb5eb1b69d50df4b96cbc384 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sat, 13 Jun 2015 00:30:42 -0600 Subject: [PATCH 137/424] Category Scale display false fixes --- src/scales/scale.category.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index f20457c4a74..c0e9ada5f2b 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -146,7 +146,7 @@ } // Height - if (this.isHorizontal()) { + if (this.isHorizontal() && this.options.display) { var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; minSize.height = Math.min(labelHeight, maxHeight); } else if (this.options.display) { From 763bde9ed17ab2a828cf03ba707dba4eec4a9dd9 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sat, 13 Jun 2015 00:45:43 -0600 Subject: [PATCH 138/424] chart.bar - remove tooltip on mouseout --- src/charts/chart.bar.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index 0cc3030a5dd..358a5fe016a 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -263,26 +263,26 @@ events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } this.lastActive = this.lastActive || []; // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } // On Hover hook if (this.options.hover.onHover) { From 181a61f16a6726bc37fbcc73680ee6cdaceaf03b Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sat, 13 Jun 2015 02:08:55 -0600 Subject: [PATCH 139/424] Do not update involuntarily on resize. Only render. --- src/core/core.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/core.js b/src/core/core.js index 3628005311d..84d4c4db570 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -1161,7 +1161,6 @@ // Cascade the resize event down to the chart. if (instance.options.responsive) { instance.resize(); - instance.update(); instance.render(); } }); From 1a3bb25f5c91e2405e913e5091158e652405e5fe Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sat, 13 Jun 2015 02:13:38 -0600 Subject: [PATCH 140/424] Reverse that :) --- src/core/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.js b/src/core/core.js index 84d4c4db570..be5654ef767 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -1161,7 +1161,7 @@ // Cascade the resize event down to the chart. if (instance.options.responsive) { instance.resize(); - instance.render(); + instance.update(); } }); }, 50); From 31643ee5987ec1444e0cf2b2547f945a9b4d184f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sat, 13 Jun 2015 02:41:15 -0600 Subject: [PATCH 141/424] Support jQuery' or native canvas element as chart context --- src/core/core.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/core.js b/src/core/core.js index be5654ef767..6260c3a6905 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -20,6 +20,17 @@ //Occupy the global variable of Chart, and create a simple base class var Chart = function(context) { var chart = this; + + // Support a jQuery'd canvas element + if (context.length && context[0].getContext) { + context = context[0]; + } + + // Support a canvas domnode + if (context.getContext) { + context = context.getContext("2d"); + } + this.canvas = context.canvas; this.ctx = context; From 8cfe21f6aa6a0f885744b0c180c019c15ac6b7f7 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 08:46:49 -0400 Subject: [PATCH 142/424] Scatter chart now extends the line chart. --- src/charts/chart.scatter.js | 464 +----------------------------------- 1 file changed, 1 insertion(+), 463 deletions(-) diff --git a/src/charts/chart.scatter.js b/src/charts/chart.scatter.js index c1b0148bcf8..a3ae0306249 100644 --- a/src/charts/chart.scatter.js +++ b/src/charts/chart.scatter.js @@ -86,470 +86,8 @@ }; - Chart.Type.extend({ + Chart.types.Line.extend({ name: "Scatter", defaults: defaultConfig, - initialize: function() { - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - - dataset.metaData = []; - - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, - y: 0, - }, - })); - - }, this); - - // The line chart onlty supports a single x axis because the x axis is always a dataset axis - if (!dataset.xAxisID) { - dataset.xAxisID = this.options.scales.xAxes[0].id; - } - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - - }, this); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[index]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[index]; - }, - resetElements: function() { - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScalePoint, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function(animationDuration) { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var yScale = this.scales[dataset.yAxisID]; - var scaleBase; - - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.options.elements.line.tension), - backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.options.elements.line.backgroundColor), - borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.options.elements.line.borderWidth), - borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.options.elements.line.borderColor), - fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill), - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(animationDuration); - }, - buildScale: function() { - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axes - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - data: this.data, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - - // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - - }, }); - - }).call(this); From 6582e2ff06460e33339f157ae24b6536da7c1620 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 08:59:54 -0400 Subject: [PATCH 143/424] Handle nesting better in the clone method so that we don't wipe out the line defaults when the scatter chart extends --- src/core/core.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/core.js b/src/core/core.js index 6260c3a6905..b2dcc004598 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -108,7 +108,11 @@ var objClone = {}; each(obj, function(value, key) { if (obj.hasOwnProperty(key)) { - objClone[key] = value; + if (typeof value === 'object' && value !== null) { + objClone[key] = clone(value); + } else { + objClone[key] = value; + } } }); return objClone; From 30019dfddd123621d8ed77e8ce0277f3ff8d35e5 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 09:51:28 -0400 Subject: [PATCH 144/424] Move some of the radial linear scale functions into the radialLinear scale --- src/charts/chart.polarArea.js | 777 ++++++++++++------------ src/charts/chart.radar.js | 987 +++++++++++++++---------------- src/scales/scale.radialLinear.js | 733 ++++++++++++----------- 3 files changed, 1239 insertions(+), 1258 deletions(-) diff --git a/src/charts/chart.polarArea.js b/src/charts/chart.polarArea.js index 4c627748855..72f4b8f7668 100644 --- a/src/charts/chart.polarArea.js +++ b/src/charts/chart.polarArea.js @@ -1,400 +1,383 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; - - var defaultConfig = { - - scale: { - type: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - - lineArc: true, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, - - // scale numbers - beginAtZero: true, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - } - }, - - //Boolean - Whether to animate the rotation of the chart - animateRotate: true, - }; - - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "PolarArea", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { - - // Scale setup - var self = this; - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleClass({ - options: this.options.scale, - lineArc: true, - width: this.chart.width, - height: this.chart.height, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - valuesCount: this.data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets[0].data, function(value) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }); - - helpers.bindEvents(this, this.options.events, this.events); - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Fit the scale before we animate - this.updateScaleRange(); - this.scale.calculateRange(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // so that we animate nicely - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - - }, - updateScaleRange: function() { - helpers.extend(this.scale, { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2 - }); - }, - resetElements: function() { - var circumference = 1 / this.data.datasets[0].data.length * 2; - - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - - var value = this.data.datasets[0].data[index]; - - helpers.extend(slice, { - _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) - }, - }); - - slice.pivot(); - }, this); - }, - update: function(animationDuration) { - - this.updateScaleRange(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - var circumference = 1 / this.data.datasets[0].data.length * 2; - - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - - var value = this.data.datasets[0].data[index]; - - var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); - - helpers.extend(slice, { - _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: this.scale.calculateCenterOffset(value), - startAngle: startAngle, - endAngle: endAngle, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) - }, - }); - slice.pivot(); - - console.log(slice); - - }, this); - - this.render(animationDuration); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - - this.clear(); - - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - slice.transition(easingDecimal).draw(); - }, this); - - this.scale.draw(); - - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ - }); + "use strict"; + + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; + + var defaultConfig = { + + scale: { + type: "radialLinear", + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate: false, + + lineArc: true, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, + + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + } + }, + + //Boolean - Whether to animate the rotation of the chart + animateRotate: true, + }; + + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "PolarArea", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { + + // Scale setup + var self = this; + var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.type); + this.scale = new ScaleClass({ + options: this.options.scale, + lineArc: true, + width: this.chart.width, + height: this.chart.height, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + valuesCount: this.data.length, + data: this.data + }); + + helpers.bindEvents(this, this.options.events, this.events); + + //Set up tooltip events on the chart + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Fit the scale before we animate + this.updateScaleRange(); + this.scale.calculateRange(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // so that we animate nicely + this.resetElements(); + + // Update the chart with the latest data. + this.update(); + + }, + updateScaleRange: function() { + helpers.extend(this.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2 + }); + }, + resetElements: function() { + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: 0, + startAngle: Math.PI * -0.5, + endAngle: Math.PI * -0.5, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + + slice.pivot(); + }, this); + }, + update: function(animationDuration) { + + this.updateScaleRange(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: this.scale.calculateCenterOffset(value), + startAngle: startAngle, + endAngle: endAngle, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + slice.pivot(); + + console.log(slice); + + }, this); + + this.render(animationDuration); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + + this.clear(); + + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + slice.transition(easingDecimal).draw(); + }, this); + + this.scale.draw(); + + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); }).call(this); diff --git a/src/charts/chart.radar.js b/src/charts/chart.radar.js index 57c7351369b..2fcf88ba050 100644 --- a/src/charts/chart.radar.js +++ b/src/charts/chart.radar.js @@ -1,517 +1,496 @@ (function() { - "use strict"; + "use strict"; - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - Chart.Type.extend({ - name: "Radar", - defaults: { + Chart.Type.extend({ + name: "Radar", + defaults: { - scale: { - type: "radialLinear", - display: true, + scale: { + type: "radialLinear", + display: true, - //Boolean - Whether to animate scaling the chart from the centre - animate: false, + //Boolean - Whether to animate scaling the chart from the centre + animate: false, - lineArc: false, + lineArc: false, - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + }, - angleLines: { - show: true, - color: "rgba(0,0,0,.1)", - lineWidth: 1 - }, + angleLines: { + show: true, + color: "rgba(0,0,0,.1)", + lineWidth: 1 + }, - // scale numbers - beginAtZero: true, + // scale numbers + beginAtZero: true, - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - }, - - pointLabels: { - //String - Point label font declaration - fontFamily: "'Arial'", - - //String - Point label font weight - fontStyle: "normal", - - //Number - Point label font size in pixels - fontSize: 10, - - //String - Point label font colour - fontColor: "#666", - }, - }, - - elements: { - line: { - tension: 0, // no bezier in radar - } - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - - }, - - initialize: function() { - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - _loop: true - }); - - dataset.metaData = []; - - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); - - }, this); - }, this); - - // Build the scale. - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[0]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[collection.length - 1]; - }, - resetElements: function() { - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _scale: this.scale, - - // Desired view properties - _model: { - x: this.scale.xCenter, - y: this.scale.yCenter, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = this.scale.xCenter; - point._model.controlPointPreviousY = this.scale.yCenter; - point._model.controlPointNextX = this.scale.xCenter; - point._model.controlPointNextY = this.scale.yCenter; - - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function(animationDuration) { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var scaleBase; - - if (this.scale.min < 0 && this.scale.max < 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.max); - } else if (this.scale.min > 0 && this.scale.max > 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.min); - } else { - scaleBase = this.scale.getPointPosition(0, 0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _datasetIndex: datasetIndex, - - // Data - _children: dataset.metaData, - - // Model - _model: { - // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - - // Scale - scaleTop: this.scale.top, - scaleBottom: this.scale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); - - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: pointPosition.y, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(animationDuration); - }, - buildScale: function() { - var self = this; - - var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleConstructor({ - options: this.options.scale, - height: this.chart.height, - width: this.chart.width, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - labels: this.data.labels, - valuesCount: this.data.datasets[0].data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }); - - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - this.scale.draw(this.chartArea); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - // If exiting chart - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, + + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + }, + + pointLabels: { + //String - Point label font declaration + fontFamily: "'Arial'", + + //String - Point label font weight + fontStyle: "normal", + + //Number - Point label font size in pixels + fontSize: 10, + + //String - Point label font colour + fontColor: "#666", + }, + }, + + elements: { + line: { + tension: 0, // no bezier in radar + } + }, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + + }, + + initialize: function() { + + // Events + helpers.bindEvents(this, this.options.events, this.events); + + // Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + _loop: true + }); + + dataset.metaData = []; + + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + + }, this); + }, this); + + // Build the scale. + this.buildScale(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[0]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[collection.length - 1]; + }, + resetElements: function() { + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _scale: this.scale, + + // Desired view properties + _model: { + x: this.scale.xCenter, + y: this.scale.yCenter, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = this.scale.xCenter; + point._model.controlPointPreviousY = this.scale.yCenter; + point._model.controlPointNextX = this.scale.xCenter; + point._model.controlPointNextY = this.scale.yCenter; + + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function(animationDuration) { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + var scaleBase; + + if (this.scale.min < 0 && this.scale.max < 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.max); + } else if (this.scale.min > 0 && this.scale.max > 0) { + scaleBase = this.scale.getPointPosition(0, this.scale.min); + } else { + scaleBase = this.scale.getPointPosition(0, 0); + } + + helpers.extend(dataset.metaDataset, { + // Utility + _datasetIndex: datasetIndex, + + // Data + _children: dataset.metaData, + + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + + // Scale + scaleTop: this.scale.top, + scaleBottom: this.scale.bottom, + scaleZero: scaleBase, + }, + }); + + dataset.metaDataset.pivot(); + }); + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); + + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: pointPosition.y, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + this.render(animationDuration); + }, + buildScale: function() { + var self = this; + + var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.type); + this.scale = new ScaleConstructor({ + options: this.options.scale, + height: this.chart.height, + width: this.chart.width, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + labels: this.data.labels, + valuesCount: this.data.datasets[0].data.length, + data: this.data, + }); + + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + this.scale.draw(this.chartArea); + + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { + + var dataset = this.data.datasets[i]; + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + this.lastActive = this.lastActive || []; + + // Find Active Elements + // If exiting chart + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + }); }).call(this); diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 2372e270ef3..7bcda29c942 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -1,361 +1,380 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var LinearRadialScale = Chart.Element.extend({ - initialize: function() { - this.size = helpers.min([this.height, this.width]); - this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); - }, - calculateCenterOffset: function(value) { - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); - return (value - this.min) * scalingFactor; - }, - update: function() { - if (!this.options.lineArc) { - this.setScaleSize(); - } else { - this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); - } - - this.buildYLabels(); - }, - calculateRange: helpers.noop, // overridden in chart - generateTicks: function() { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw - - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; - - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); - } - } else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph - - var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); - - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } - - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; - - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - } - } - - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } - - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, - buildYLabels: function() { - this.yLabels = []; - - helpers.each(this.ticks, function(tick, index, ticks) { - var label; - - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.labels.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick - }); - } - - this.yLabels.push(label ? label : ""); - }, this); - }, - getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); - }, - setScaleSize: function() { - /* - * Right, this is really confusing and there is a lot of maths going on here - * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 - * - * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif - * - * Solution: - * - * We assume the radius of the polygon is half the size of the canvas at first - * at each index we check if the text overlaps. - * - * Where it does, we store that angle and that index. - * - * After finding the largest index and angle we calculate how much we need to remove - * from the shape radius to move the point inwards by that x. - * - * We average the left and right distances to get the maximum shape radius that can fit in the box - * along with labels. - * - * Once we have that, we can find the centre point for the chart, by taking the x text protrusion - * on each side, removing that from the size, halving it and adding the left x protrusion width. - * - * This will mean we have a shape fitted to the canvas, as large as it can be with the labels - * and position it in the most space efficient manner - * - * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - */ - - - // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points - var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), - pointPosition, - i, - textWidth, - halfTextWidth, - furthestRight = this.width, - furthestRightIndex, - furthestRightAngle, - furthestLeft = 0, - furthestLeftIndex, - furthestLeftAngle, - xProtrusionLeft, - xProtrusionRight, - radiusReductionRight, - radiusReductionLeft, - maxWidthRadius; - this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - for (i = 0; i < this.valuesCount; i++) { - // 5px to space the text slightly out - similar to what we do in the draw function. - pointPosition = this.getPointPosition(i, largestPossibleRadius); - textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { - value: this.labels[i] - })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { - // If we're at index zero, or exactly the middle, we're at exactly the top/bottom - // of the radar chart, so text will be aligned centrally, so we'll half it and compare - // w/left and right text sizes - halfTextWidth = textWidth / 2; - if (pointPosition.x + halfTextWidth > furthestRight) { - furthestRight = pointPosition.x + halfTextWidth; - furthestRightIndex = i; - } - if (pointPosition.x - halfTextWidth < furthestLeft) { - furthestLeft = pointPosition.x - halfTextWidth; - furthestLeftIndex = i; - } - } else if (i < this.valuesCount / 2) { - // Less than half the values means we'll left align the text - if (pointPosition.x + textWidth > furthestRight) { - furthestRight = pointPosition.x + textWidth; - furthestRightIndex = i; - } - } else if (i > this.valuesCount / 2) { - // More than half the values means we'll right align the text - if (pointPosition.x - textWidth < furthestLeft) { - furthestLeft = pointPosition.x - textWidth; - furthestLeftIndex = i; - } - } - } - - xProtrusionLeft = furthestLeft; - - xProtrusionRight = Math.ceil(furthestRight - this.width); - - furthestRightAngle = this.getIndexAngle(furthestRightIndex); - - furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); - - radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); - - radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); - - // Ensure we actually need to reduce the size of the chart - radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; - radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; - - this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; - - //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) - this.setCenterPoint(radiusReductionLeft, radiusReductionRight); - - }, - setCenterPoint: function(leftMovement, rightMovement) { - - var maxRight = this.width - rightMovement - this.drawingArea, - maxLeft = leftMovement + this.drawingArea; - - this.xCenter = (maxLeft + maxRight) / 2; - // Always vertically in the centre as the text height doesn't change - this.yCenter = (this.height / 2); - }, - - getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; - // Start from the top instead of right, so remove a quarter of the circle - - return index * angleMultiplier - (Math.PI / 2); - }, - getPointPosition: function(index, distanceFromCenter) { - var thisAngle = this.getIndexAngle(index); - return { - x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, - y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter - }; - }, - draw: function() { - if (this.options.display) { - var ctx = this.ctx; - helpers.each(this.yLabels, function(label, index) { - // Don't draw a centre value - if (index > 0) { - var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), - yHeight = this.yCenter - yCenterOffset, - pointPosition; - - // Draw circular lines around the scale - if (this.options.gridLines.show) { - ctx.strokeStyle = this.options.gridLines.color; - ctx.lineWidth = this.options.gridLines.lineWidth; - - if (this.options.lineArc) { - ctx.beginPath(); - ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); - ctx.closePath(); - ctx.stroke(); - } else { - ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { - pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); - if (i === 0) { - ctx.moveTo(pointPosition.x, pointPosition.y); - } else { - ctx.lineTo(pointPosition.x, pointPosition.y); - } - } - ctx.closePath(); - ctx.stroke(); - } - } - - if (this.options.labels.show) { - ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - if (this.showLabelBackdrop) { - var labelWidth = ctx.measureText(label).width; - ctx.fillStyle = this.options.labels.backdropColor; - ctx.fillRect( - this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, - yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, - labelWidth + this.options.labels.backdropPaddingX * 2, - this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 - ); - } - - ctx.textAlign = 'center'; - ctx.textBaseline = "middle"; - ctx.fillStyle = this.options.labels.fontColor; - ctx.fillText(label, this.xCenter, yHeight); - } - } - }, this); - - if (!this.options.lineArc) { - ctx.lineWidth = this.options.angleLines.lineWidth; - ctx.strokeStyle = this.options.angleLines.color; - - for (var i = this.valuesCount - 1; i >= 0; i--) { - if (this.options.angleLines.show) { - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); - ctx.beginPath(); - ctx.moveTo(this.xCenter, this.yCenter); - ctx.lineTo(outerPosition.x, outerPosition.y); - ctx.stroke(); - ctx.closePath(); - } - // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); - ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - ctx.fillStyle = this.options.pointLabels.fontColor; - - var labelsCount = this.labels.length, - halfLabelsCount = this.labels.length / 2, - quarterLabelsCount = halfLabelsCount / 2, - upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), - exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); - if (i === 0) { - ctx.textAlign = 'center'; - } else if (i === halfLabelsCount) { - ctx.textAlign = 'center'; - } else if (i < halfLabelsCount) { - ctx.textAlign = 'left'; - } else { - ctx.textAlign = 'right'; - } - - // Set the correct text baseline based on outer positioning - if (exactQuarter) { - ctx.textBaseline = 'middle'; - } else if (upperHalf) { - ctx.textBaseline = 'bottom'; - } else { - ctx.textBaseline = 'top'; - } - - ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); - } - } - } - } - }); - Chart.scales.registerScaleType("radialLinear", LinearRadialScale); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var LinearRadialScale = Chart.Element.extend({ + initialize: function() { + this.size = helpers.min([this.height, this.width]); + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); + }, + calculateCenterOffset: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + return (value - this.min) * scalingFactor; + }, + update: function() { + if (!this.options.lineArc) { + this.setScaleSize(); + } else { + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + } + + this.buildYLabels(); + }, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(this.data.datasets, function(dataset) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + }, this); + }, + generateTicks: function() { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildYLabels: function() { + this.yLabels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.yLabels.push(label ? label : ""); + }, this); + }, + getCircumference: function() { + return ((Math.PI * 2) / this.valuesCount); + }, + setScaleSize: function() { + /* + * Right, this is really confusing and there is a lot of maths going on here + * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 + * + * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif + * + * Solution: + * + * We assume the radius of the polygon is half the size of the canvas at first + * at each index we check if the text overlaps. + * + * Where it does, we store that angle and that index. + * + * After finding the largest index and angle we calculate how much we need to remove + * from the shape radius to move the point inwards by that x. + * + * We average the left and right distances to get the maximum shape radius that can fit in the box + * along with labels. + * + * Once we have that, we can find the centre point for the chart, by taking the x text protrusion + * on each side, removing that from the size, halving it and adding the left x protrusion width. + * + * This will mean we have a shape fitted to the canvas, as large as it can be with the labels + * and position it in the most space efficient manner + * + * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif + */ + + + // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. + // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points + var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), + pointPosition, + i, + textWidth, + halfTextWidth, + furthestRight = this.width, + furthestRightIndex, + furthestRightAngle, + furthestLeft = 0, + furthestLeftIndex, + furthestLeftAngle, + xProtrusionLeft, + xProtrusionRight, + radiusReductionRight, + radiusReductionLeft, + maxWidthRadius; + this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + for (i = 0; i < this.valuesCount; i++) { + // 5px to space the text slightly out - similar to what we do in the draw function. + pointPosition = this.getPointPosition(i, largestPossibleRadius); + textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { + value: this.labels[i] + })).width + 5; + if (i === 0 || i === this.valuesCount / 2) { + // If we're at index zero, or exactly the middle, we're at exactly the top/bottom + // of the radar chart, so text will be aligned centrally, so we'll half it and compare + // w/left and right text sizes + halfTextWidth = textWidth / 2; + if (pointPosition.x + halfTextWidth > furthestRight) { + furthestRight = pointPosition.x + halfTextWidth; + furthestRightIndex = i; + } + if (pointPosition.x - halfTextWidth < furthestLeft) { + furthestLeft = pointPosition.x - halfTextWidth; + furthestLeftIndex = i; + } + } else if (i < this.valuesCount / 2) { + // Less than half the values means we'll left align the text + if (pointPosition.x + textWidth > furthestRight) { + furthestRight = pointPosition.x + textWidth; + furthestRightIndex = i; + } + } else if (i > this.valuesCount / 2) { + // More than half the values means we'll right align the text + if (pointPosition.x - textWidth < furthestLeft) { + furthestLeft = pointPosition.x - textWidth; + furthestLeftIndex = i; + } + } + } + + xProtrusionLeft = furthestLeft; + + xProtrusionRight = Math.ceil(furthestRight - this.width); + + furthestRightAngle = this.getIndexAngle(furthestRightIndex); + + furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); + + radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); + + radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + + // Ensure we actually need to reduce the size of the chart + radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; + radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; + + this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; + + //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) + this.setCenterPoint(radiusReductionLeft, radiusReductionRight); + + }, + setCenterPoint: function(leftMovement, rightMovement) { + + var maxRight = this.width - rightMovement - this.drawingArea, + maxLeft = leftMovement + this.drawingArea; + + this.xCenter = (maxLeft + maxRight) / 2; + // Always vertically in the centre as the text height doesn't change + this.yCenter = (this.height / 2); + }, + + getIndexAngle: function(index) { + var angleMultiplier = (Math.PI * 2) / this.valuesCount; + // Start from the top instead of right, so remove a quarter of the circle + + return index * angleMultiplier - (Math.PI / 2); + }, + getPointPosition: function(index, distanceFromCenter) { + var thisAngle = this.getIndexAngle(index); + return { + x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, + y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter + }; + }, + draw: function() { + if (this.options.display) { + var ctx = this.ctx; + helpers.each(this.yLabels, function(label, index) { + // Don't draw a centre value + if (index > 0) { + var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), + yHeight = this.yCenter - yCenterOffset, + pointPosition; + + // Draw circular lines around the scale + if (this.options.gridLines.show) { + ctx.strokeStyle = this.options.gridLines.color; + ctx.lineWidth = this.options.gridLines.lineWidth; + + if (this.options.lineArc) { + ctx.beginPath(); + ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); + ctx.closePath(); + ctx.stroke(); + } else { + ctx.beginPath(); + for (var i = 0; i < this.valuesCount; i++) { + pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); + if (i === 0) { + ctx.moveTo(pointPosition.x, pointPosition.y); + } else { + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + } + } + + if (this.options.labels.show) { + ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.showLabelBackdrop) { + var labelWidth = ctx.measureText(label).width; + ctx.fillStyle = this.options.labels.backdropColor; + ctx.fillRect( + this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, + yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, + labelWidth + this.options.labels.backdropPaddingX * 2, + this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 + ); + } + + ctx.textAlign = 'center'; + ctx.textBaseline = "middle"; + ctx.fillStyle = this.options.labels.fontColor; + ctx.fillText(label, this.xCenter, yHeight); + } + } + }, this); + + if (!this.options.lineArc) { + ctx.lineWidth = this.options.angleLines.lineWidth; + ctx.strokeStyle = this.options.angleLines.color; + + for (var i = this.valuesCount - 1; i >= 0; i--) { + if (this.options.angleLines.show) { + var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); + ctx.beginPath(); + ctx.moveTo(this.xCenter, this.yCenter); + ctx.lineTo(outerPosition.x, outerPosition.y); + ctx.stroke(); + ctx.closePath(); + } + // Extra 3px out for some label spacing + var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); + ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + ctx.fillStyle = this.options.pointLabels.fontColor; + + var labelsCount = this.labels.length, + halfLabelsCount = this.labels.length / 2, + quarterLabelsCount = halfLabelsCount / 2, + upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), + exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); + if (i === 0) { + ctx.textAlign = 'center'; + } else if (i === halfLabelsCount) { + ctx.textAlign = 'center'; + } else if (i < halfLabelsCount) { + ctx.textAlign = 'left'; + } else { + ctx.textAlign = 'right'; + } + + // Set the correct text baseline based on outer positioning + if (exactQuarter) { + ctx.textBaseline = 'middle'; + } else if (upperHalf) { + ctx.textBaseline = 'bottom'; + } else { + ctx.textBaseline = 'top'; + } + + ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + } + } + } + } + }); + Chart.scales.registerScaleType("radialLinear", LinearRadialScale); }).call(this); From 1f16b349d2a987ca7616343cc1d6dd4490cd8db4 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 09:55:43 -0400 Subject: [PATCH 145/424] Merge `Chart.scales` into `Chart.scaleService` to be consistent --- src/charts/chart.bar.js | 4 ++-- src/charts/chart.line.js | 4 ++-- src/charts/chart.polarArea.js | 2 +- src/charts/chart.radar.js | 2 +- src/core/core.scale.js | 27 ++++++++++++--------------- src/scales/scale.category.js | 5 +---- src/scales/scale.linear.js | 5 ++--- src/scales/scale.radialLinear.js | 2 +- 8 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index 358a5fe016a..e16161bb220 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -220,7 +220,7 @@ this.scales = {}; // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].type); + var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scales.xAxes[0].type); var xScale = new ScaleClass({ ctx: this.chart.ctx, options: this.options.scales.xAxes[0], @@ -231,7 +231,7 @@ // Build up all the y scales helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); var scale = new ScaleClass({ ctx: this.chart.ctx, options: yAxisOptions, diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index d68a9964e16..779f78e3f66 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -344,7 +344,7 @@ // Build the x axes helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type); + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); var scale = new ScaleClass({ ctx: this.chart.ctx, options: xAxisOptions, @@ -357,7 +357,7 @@ // Build the y axes helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); var scale = new ScaleClass({ ctx: this.chart.ctx, options: yAxisOptions, diff --git a/src/charts/chart.polarArea.js b/src/charts/chart.polarArea.js index 72f4b8f7668..4131e6bc01c 100644 --- a/src/charts/chart.polarArea.js +++ b/src/charts/chart.polarArea.js @@ -66,7 +66,7 @@ // Scale setup var self = this; - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.type); + var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); this.scale = new ScaleClass({ options: this.options.scale, lineArc: true, diff --git a/src/charts/chart.radar.js b/src/charts/chart.radar.js index 2fcf88ba050..3d911070f94 100644 --- a/src/charts/chart.radar.js +++ b/src/charts/chart.radar.js @@ -302,7 +302,7 @@ buildScale: function() { var self = this; - var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.type); + var ScaleConstructor = Chart.scaleService.getScaleConstructor(this.options.scale.type); this.scale = new ScaleConstructor({ options: this.options.scale, height: this.chart.height, diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 3d56f634690..dc9a9a70252 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -9,6 +9,18 @@ // a service where scales are registered with their respective charts so that changing the // scales does not require Chart.scaleService = { + // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then + // use the new chart options to grab the correct scale + constructors: {}, + // Use a registration function so that we can move to an ES6 map when we no longer need to support + // old browsers + registerScaleType: function(type, scaleConstructor) { + this.constructors[type] = scaleConstructor; + }, + getScaleConstructor: function(type) { + return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; + }, + // The interesting function fitScalesForChart: function(chartInstance, width, height) { var xPadding = width > 30 ? 5 : 2; @@ -287,19 +299,4 @@ } } }; - - // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then - // use the new chart options to grab the correct scale - Chart.scales = { - constructors: {}, - // Use a registration function so that we can move to an ES6 map when we no longer need to support - // old browsers - registerScaleType: function(type, scaleConstructor) { - this.constructors[type] = scaleConstructor; - }, - getScaleConstructor: function(type) { - return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; - } - }; - }).call(this); diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 9ce5e00f4b9..7ed54613ec9 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -233,8 +233,5 @@ } } }); - Chart.scales.registerScaleType("category", DatasetScale); - - - + Chart.scaleService.registerScaleType("category", DatasetScale); }).call(this); diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 11e1bdfc247..fd4e6d80034 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -523,7 +523,6 @@ } } }); - Chart.scales.registerScaleType("linear", LinearScale); - - + Chart.scaleService.registerScaleType("linear", LinearScale); + }).call(this); diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 7bcda29c942..9d8e30eff45 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -374,7 +374,7 @@ } } }); - Chart.scales.registerScaleType("radialLinear", LinearRadialScale); + Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale); }).call(this); From b5c69984e3e757f89e4b0b0fc30a525af4bf78b6 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 10:15:21 -0400 Subject: [PATCH 146/424] Change spaces to tabs throughout --- src/charts/chart.bar.js | 808 +++++----- src/charts/chart.doughnut.js | 724 ++++----- src/core/core.animation.js | 224 +-- src/core/core.js | 2374 ++++++++++++++--------------- src/core/core.scale.js | 600 ++++---- src/core/core.tooltip.js | 658 ++++---- src/elements/element.arc.js | 154 +- src/elements/element.line.js | 350 ++--- src/elements/element.point.js | 136 +- src/elements/element.rectangle.js | 142 +- 10 files changed, 3085 insertions(+), 3085 deletions(-) diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index e16161bb220..b77fe97fe83 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -1,408 +1,408 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - hover: { - mode: "label" - }, - - scales: { - xAxes: [{ - type: "category", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - - categorySpacing: 10, - spacing: 1, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: true, - }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - spacing: 1, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } - }], - }, - - }; - - - Chart.Type.extend({ - name: "Bar", - defaults: defaultConfig, - initialize: function() { - - var _this = this; - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Rectangle({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - })); - }, this); - - // The bar chart only supports a single x axis because the x axis is always a dataset axis - dataset.xAxisID = this.options.scales.xAxes[0].id; - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - }, this); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // So that we animate from the baseline - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - }, - resetElements: function() { - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScalePoint, - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), - - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); - }, this); - }, - update: function(animationDuration) { - // Update the scale sizes - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScale.calculateBarY(datasetIndex, index), - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), - - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); - }, this); - - - this.render(animationDuration); - }, - buildScale: function(labels) { - var self = this; - - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scales.xAxes[0].type); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - id: this.options.scales.xAxes[0].id, - data: this.data, - }); - this.scales[xScale.id] = xScale; - - // Build up all the y scales - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - //Draw all the bars for each dataset - this.eachElement(function(bar, index, datasetIndex) { - bar.transition(easingDecimal).draw(); - }, this); - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - this.tooltip.pivot(); - - // Hover animations - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + type: "category", // scatter should not use a dataset axis + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + categorySpacing: 10, + spacing: 1, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: true, + }, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }], + yAxes: [{ + type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + display: true, + position: "left", + id: "y-axis-1", + + spacing: 1, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.05)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + beginAtZero: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }], + }, + + }; + + + Chart.Type.extend({ + name: "Bar", + defaults: defaultConfig, + initialize: function() { + + var _this = this; + + // Events + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Rectangle({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + })); + }, this); + + // The bar chart only supports a single x axis because the x axis is always a dataset axis + dataset.xAxisID = this.options.scales.xAxes[0].id; + + if (!dataset.yAxisID) { + dataset.yAxisID = this.options.scales.yAxes[0].id; + } + }, this); + + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScale(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // So that we animate from the baseline + this.resetElements(); + + // Update the chart with the latest data. + this.update(); + }, + resetElements: function() { + // Update the points + this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(bar, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScalePoint, + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), + + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + }, + }); + bar.pivot(); + }, this); + }, + update: function(animationDuration) { + // Update the scale sizes + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the points + this.eachElement(function(bar, index, dataset, datasetIndex) { + var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; + var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; + + helpers.extend(bar, { + // Utility + _chart: this.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), + y: yScale.calculateBarY(datasetIndex, index), + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.data.datasets.length), + backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), + borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), + borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), + + // Tooltip + label: this.data.labels[index], + datasetLabel: this.data.datasets[datasetIndex].label, + }, + }); + bar.pivot(); + }, this); + + + this.render(animationDuration); + }, + buildScale: function(labels) { + var self = this; + + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axis. The line chart only supports a single x axis + var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scales.xAxes[0].type); + var xScale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scales.xAxes[0], + id: this.options.scales.xAxes[0].id, + data: this.data, + }); + this.scales[xScale.id] = xScale; + + // Build up all the y scales + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + draw: function(ease) { + + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + //Draw all the bars for each dataset + this.eachElement(function(bar, index, datasetIndex) { + bar.transition(easingDecimal).draw(); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + + + this.lastActive = this.lastActive || []; + + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + this.tooltip.pivot(); + + // Hover animations + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hoverAnimationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + }); }).call(this); diff --git a/src/charts/chart.doughnut.js b/src/charts/chart.doughnut.js index 17b0802d819..47884f29831 100644 --- a/src/charts/chart.doughnut.js +++ b/src/charts/chart.doughnut.js @@ -1,365 +1,365 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; - - var defaultConfig = { - - animation: { - //Boolean - Whether we animate the rotation of the Doughnut - animateRotate: true, - - //Boolean - Whether we animate scaling the Doughnut from the centre - animateScale: false, - }, - - hover: { - mode: 'single' - }, - - //The percentage of the chart that we cut out of the middle. - - cutoutPercentage: 50, - - }; - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - - }, - - calculateCircumference: function(dataset, value) { - if (dataset.total > 0) { - return (Math.PI * 2) * (value / dataset.total); - } else { - return 0; - } - }, - resetElements: function() { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // So that calculateCircumference works - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(slice, index) { - helpers.extend(slice, { - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, - innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); - - slice.pivot(); - }, this); - - }, this); - }, - update: function(animationDuration) { - - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(slice, index) { - - helpers.extend(slice, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - circumference: this.calculateCircumference(dataset, dataset.data[index]), - outerRadius: dataset.outerRadius, - innerRadius: dataset.innerRadius, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); - - if (index === 0) { - slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - } else { - slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; - } - - slice._model.endAngle = slice._model.startAngle + slice._model.circumference; - - - //Check to see if it's the last slice, if not get the next and update its start angle - if (index < dataset.data.length - 1) { - dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; - } - - slice.pivot(); - }, this); - - }, this); - - this.render(animationDuration); - }, - draw: function(easeDecimal) { - easeDecimal = easeDecimal || 1; - this.clear(); - - this.eachElement(function(slice) { - slice.transition(easeDecimal).draw(); - }, this); - - this.tooltip.transition(easeDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ - }); - - Chart.types.Doughnut.extend({ - name: "Pie", - defaults: helpers.merge(defaultConfig, { - cutoutPercentage: 0 - }) - }); + "use strict"; + + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; + + var defaultConfig = { + + animation: { + //Boolean - Whether we animate the rotation of the Doughnut + animateRotate: true, + + //Boolean - Whether we animate scaling the Doughnut from the centre + animateScale: false, + }, + + hover: { + mode: 'single' + }, + + //The percentage of the chart that we cut out of the middle. + + cutoutPercentage: 50, + + }; + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "Doughnut", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { + + //Set up tooltip events on the chart + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + this.resetElements(); + + // Update the chart with the latest data. + this.update(); + + }, + + calculateCircumference: function(dataset, value) { + if (dataset.total > 0) { + return (Math.PI * 2) * (value / dataset.total); + } else { + return 0; + } + }, + resetElements: function() { + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; + + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + // So that calculateCircumference works + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + helpers.extend(slice, { + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, + innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + slice.pivot(); + }, this); + + }, this); + }, + update: function(animationDuration) { + + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; + + + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + + helpers.extend(slice, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + circumference: this.calculateCircumference(dataset, dataset.data[index]), + outerRadius: dataset.outerRadius, + innerRadius: dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + if (index === 0) { + slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + } else { + slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; + } + + slice._model.endAngle = slice._model.startAngle + slice._model.circumference; + + + //Check to see if it's the last slice, if not get the next and update its start angle + if (index < dataset.data.length - 1) { + dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; + } + + slice.pivot(); + }, this); + + }, this); + + this.render(animationDuration); + }, + draw: function(easeDecimal) { + easeDecimal = easeDecimal || 1; + this.clear(); + + this.eachElement(function(slice) { + slice.transition(easeDecimal).draw(); + }, this); + + this.tooltip.transition(easeDecimal).draw(); + }, + events: function(e) { + + this.lastActive = this.lastActive || []; + + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inGroupRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); + + Chart.types.Doughnut.extend({ + name: "Pie", + defaults: helpers.merge(defaultConfig, { + cutoutPercentage: 0 + }) + }); }).call(this); diff --git a/src/core/core.animation.js b/src/core/core.animation.js index 1794febd7e9..f8812b5d940 100644 --- a/src/core/core.animation.js +++ b/src/core/core.animation.js @@ -11,117 +11,117 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.animation = { - duration: 1000, - easing: "easeOutQuart", - onProgress: function() {}, - onComplete: function() {}, - }; - - Chart.Animation = Chart.Element.extend({ - currentStep: null, // the current animation step - numSteps: 60, // default number of steps - easing: "", // the easing to use for this animation - render: null, // render function used by the animation service - - onAnimationProgress: null, // user specified callback to fire on each step of the animation - onAnimationComplete: null, // user specified callback to fire when the animation finishes - }); - - Chart.animationService = { - frameDuration: 17, - animations: [], - dropFrames: 0, - addAnimation: function(chartInstance, animationObject, duration) { - - if (!duration) { - chartInstance.animating = true; - } - - for (var index = 0; index < this.animations.length; ++index) { - if (this.animations[index].chartInstance === chartInstance) { - // replacing an in progress animation - this.animations[index].animationObject = animationObject; - return; - } - } - - this.animations.push({ - chartInstance: chartInstance, - animationObject: animationObject - }); - - // If there are no animations queued, manually kickstart a digest, for lack of a better word - if (this.animations.length == 1) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - }, - // Cancel the animation for a given chart instance - cancelAnimation: function(chartInstance) { - var index = helpers.findNextWhere(this.animations, function(animationWrapper) { - return animationWrapper.chartInstance === chartInstance; - }); - - if (index) { - this.animations.splice(index, 1); - chartInstance.animating = false; - } - }, - // calls startDigest with the proper context - digestWrapper: function() { - Chart.animationService.startDigest.call(Chart.animationService); - }, - startDigest: function() { - - var startTime = Date.now(); - var framesToDrop = 0; - - if (this.dropFrames > 1) { - framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; - } - - for (var i = 0; i < this.animations.length; i++) { - - if (this.animations[i].animationObject.currentStep === null) { - this.animations[i].animationObject.currentStep = 0; - } - - this.animations[i].animationObject.currentStep += 1 + framesToDrop; - if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { - this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; - } - - this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); - - if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { - // executed the last frame. Remove the animation. - this.animations[i].chartInstance.animating = false; - this.animations.splice(i, 1); - // Keep the index in place to offset the splice - i--; - } - } - - var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; - - if (frameDelay > 1) { - this.dropFrames += frameDelay; - } - - // Do we have more stuff to animate? - if (this.animations.length > 0) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - } - }; + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.animation = { + duration: 1000, + easing: "easeOutQuart", + onProgress: function() {}, + onComplete: function() {}, + }; + + Chart.Animation = Chart.Element.extend({ + currentStep: null, // the current animation step + numSteps: 60, // default number of steps + easing: "", // the easing to use for this animation + render: null, // render function used by the animation service + + onAnimationProgress: null, // user specified callback to fire on each step of the animation + onAnimationComplete: null, // user specified callback to fire when the animation finishes + }); + + Chart.animationService = { + frameDuration: 17, + animations: [], + dropFrames: 0, + addAnimation: function(chartInstance, animationObject, duration) { + + if (!duration) { + chartInstance.animating = true; + } + + for (var index = 0; index < this.animations.length; ++index) { + if (this.animations[index].chartInstance === chartInstance) { + // replacing an in progress animation + this.animations[index].animationObject = animationObject; + return; + } + } + + this.animations.push({ + chartInstance: chartInstance, + animationObject: animationObject + }); + + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (this.animations.length == 1) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + }, + // Cancel the animation for a given chart instance + cancelAnimation: function(chartInstance) { + var index = helpers.findNextWhere(this.animations, function(animationWrapper) { + return animationWrapper.chartInstance === chartInstance; + }); + + if (index) { + this.animations.splice(index, 1); + chartInstance.animating = false; + } + }, + // calls startDigest with the proper context + digestWrapper: function() { + Chart.animationService.startDigest.call(Chart.animationService); + }, + startDigest: function() { + + var startTime = Date.now(); + var framesToDrop = 0; + + if (this.dropFrames > 1) { + framesToDrop = Math.floor(this.dropFrames); + this.dropFrames -= framesToDrop; + } + + for (var i = 0; i < this.animations.length; i++) { + + if (this.animations[i].animationObject.currentStep === null) { + this.animations[i].animationObject.currentStep = 0; + } + + this.animations[i].animationObject.currentStep += 1 + framesToDrop; + if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { + this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; + } + + this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); + + if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { + // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; + this.animations.splice(i, 1); + // Keep the index in place to offset the splice + i--; + } + } + + var endTime = Date.now(); + var delay = endTime - startTime - this.frameDuration; + var frameDelay = delay / this.frameDuration; + + if (frameDelay > 1) { + this.dropFrames += frameDelay; + } + + // Do we have more stuff to animate? + if (this.animations.length > 0) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + } + }; }).call(this); diff --git a/src/core/core.js b/src/core/core.js index b2dcc004598..c01dfbaa955 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -11,1192 +11,1192 @@ (function() { - "use strict"; - - //Declare root variable - window in the browser, global on the server - var root = this, - previous = root.Chart; - - //Occupy the global variable of Chart, and create a simple base class - var Chart = function(context) { - var chart = this; - - // Support a jQuery'd canvas element - if (context.length && context[0].getContext) { - context = context[0]; - } - - // Support a canvas domnode - if (context.getContext) { - context = context.getContext("2d"); - } - - this.canvas = context.canvas; - - this.ctx = context; - - //Variables global to the chart - var computeDimension = function(element, dimension) { - if (element['offset' + dimension]) { - return element['offset' + dimension]; - } else { - return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); - } - }; - - var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; - var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; - - // Firefox requires this to work correctly - context.canvas.width = width; - context.canvas.height = height; - - width = this.width = context.canvas.width; - height = this.height = context.canvas.height; - this.aspectRatio = this.width / this.height; - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. - helpers.retinaScale(this); - - return this; - }; - - var defaultColor = 'rgba(0,0,0,0.1)'; - - //Globally expose the defaults to allow for user updating/changing - Chart.defaults = { - global: { - responsive: true, - maintainAspectRatio: true, - events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], - hover: { - onHover: null, - mode: 'single', - animationDuration: 400, - }, - onClick: null, - defaultColor: defaultColor, - - // Element defaults defined in element extensions - elements: {} - }, - }; - - //Create a dictionary of chart types, to allow for extension of existing types - Chart.types = {}; - - //Global Chart helpers object for utility methods and classes - var helpers = Chart.helpers = {}; - - //-- Basic js utility methods - var each = helpers.each = function(loopable, callback, self) { - var additionalArgs = Array.prototype.slice.call(arguments, 3); - // Check to see if null or undefined firstly. - if (loopable) { - if (loopable.length === +loopable.length) { - var i; - for (i = 0; i < loopable.length; i++) { - callback.apply(self, [loopable[i], i].concat(additionalArgs)); - } - } else { - for (var item in loopable) { - callback.apply(self, [loopable[item], item].concat(additionalArgs)); - } - } - } - }, - clone = helpers.clone = function(obj) { - var objClone = {}; - each(obj, function(value, key) { - if (obj.hasOwnProperty(key)) { - if (typeof value === 'object' && value !== null) { - objClone[key] = clone(value); - } else { - objClone[key] = value; - } - } - }); - return objClone; - }, - extend = helpers.extend = function(base) { - each(Array.prototype.slice.call(arguments, 1), function(extensionObject) { - each(extensionObject, function(value, key) { - if (extensionObject.hasOwnProperty(key)) { - base[key] = value; - } - }); - }); - return base; - }, - merge = helpers.merge = function(base, master) { - //Merge properties in left object over to a shallow clone of object right. - var args = Array.prototype.slice.call(arguments, 0); - args.unshift({}); - return extend.apply(null, args); - }, - // Need a special merge function to chart configs since they are now grouped - configMerge = helpers.configMerge = function(_base) { - var base = clone(_base); - helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { - helpers.each(extension, function(value, key) { - if (extension.hasOwnProperty(key)) { - if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { - // In this case we have an array of objects replacing another array. Rather than doing a strict replace, - // merge. This allows easy scale option merging - var baseArray = base[key]; - - helpers.each(value, function(valueObj, index) { - if (index < baseArray.length) { - baseArray[index] = helpers.configMerge(baseArray[index], valueObj); - } else { - baseArray.push(valueObj); // nothing to merge - } - }); - } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { - // If we are overwriting an object with an object, do a merge of the properties. - base[key] = helpers.configMerge(base[key], value); - } else { - // can just overwrite the value in this case - base[key] = value; - } - } - }); - }); - - return base; - }, - getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { - if (!value) { - return defaultValue; - } - - if (helpers.isArray(value) && index < value.length) { - return value[index]; - } - - return value; - }, - indexOf = helpers.indexOf = function(arrayToSearch, item) { - if (Array.prototype.indexOf) { - return arrayToSearch.indexOf(item); - } else { - for (var i = 0; i < arrayToSearch.length; i++) { - if (arrayToSearch[i] === item) return i; - } - return -1; - } - }, - where = helpers.where = function(collection, filterCallback) { - var filtered = []; - - helpers.each(collection, function(item) { - if (filterCallback(item)) { - filtered.push(item); - } - }); - - return filtered; - }, - findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { - // Default to start of the array - if (!startIndex) { - startIndex = -1; - } - for (var i = startIndex + 1; i < arrayToSearch.length; i++) { - var currentItem = arrayToSearch[i]; - if (filterCallback(currentItem)) { - return currentItem; - } - } - }, - findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { - // Default to end of the array - if (!startIndex) { - startIndex = arrayToSearch.length; - } - for (var i = startIndex - 1; i >= 0; i--) { - var currentItem = arrayToSearch[i]; - if (filterCallback(currentItem)) { - return currentItem; - } - } - }, - inherits = helpers.inherits = function(extensions) { - //Basic javascript inheritance based on the model created in Backbone.js - var parent = this; - var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() { - return parent.apply(this, arguments); - }; - - var Surrogate = function() { - this.constructor = ChartElement; - }; - Surrogate.prototype = parent.prototype; - ChartElement.prototype = new Surrogate(); - - ChartElement.extend = inherits; - - if (extensions) extend(ChartElement.prototype, extensions); - - ChartElement.__super__ = parent.prototype; - - return ChartElement; - }, - noop = helpers.noop = function() {}, - uid = helpers.uid = (function() { - var id = 0; - return function() { - return "chart-" + id++; - }; - })(), - warn = helpers.warn = function(str) { - //Method for warning of errors - if (window.console && typeof window.console.warn === "function") console.warn(str); - }, - amd = helpers.amd = (typeof define === 'function' && define.amd), - //-- Math methods - isNumber = helpers.isNumber = function(n) { - return !isNaN(parseFloat(n)) && isFinite(n); - }, - max = helpers.max = function(array) { - return Math.max.apply(Math, array); - }, - min = helpers.min = function(array) { - return Math.min.apply(Math, array); - }, - sign = helpers.sign = function(x) { - if (Math.sign) { - return Math.sign(x); - } else { - x = +x; // convert to a number - if (x === 0 || isNaN(x)) { - return x; - } - return x > 0 ? 1 : -1; - } - }, - log10 = helpers.log10 = function(x) { - if (Math.log10) { - return Math.log10(x) - } else { - return Math.log(x) / Math.LN10; - } - }, - cap = helpers.cap = function(valueToCap, maxValue, minValue) { - if (isNumber(maxValue)) { - if (valueToCap > maxValue) { - return maxValue; - } - } else if (isNumber(minValue)) { - if (valueToCap < minValue) { - return minValue; - } - } - return valueToCap; - }, - getDecimalPlaces = helpers.getDecimalPlaces = function(num) { - if (num % 1 !== 0 && isNumber(num)) { - var s = num.toString(); - if (s.indexOf("e-") < 0) { - // no exponent, e.g. 0.01 - return s.split(".")[1].length; - } else if (s.indexOf(".") < 0) { - // no decimal point, e.g. 1e-9 - return parseInt(s.split("e-")[1]); - } else { - // exponent and decimal point, e.g. 1.23e-9 - var parts = s.split(".")[1].split("e-"); - return parts[0].length + parseInt(parts[1]); - } - } else { - return 0; - } - }, - toRadians = helpers.toRadians = function(degrees) { - return degrees * (Math.PI / 180); - }, - toDegrees = helpers.toDegrees = function(radians) { - return radians * (180 / Math.PI); - }, - // Gets the angle from vertical upright to the point about a centre. - getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { - var distanceFromXCenter = anglePoint.x - centrePoint.x, - distanceFromYCenter = anglePoint.y - centrePoint.y, - radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); - - var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); - - if (angle < (-0.5 * Math.PI)) { - angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2] - } - - return { - angle: angle, - distance: radialDistanceFromCenter - }; - }, - aliasPixel = helpers.aliasPixel = function(pixelWidth) { - return (pixelWidth % 2 === 0) ? 0 : 0.5; - }, - splineCurve = helpers.splineCurve = function(FirstPoint, MiddlePoint, AfterPoint, t) { - //Props to Rob Spencer at scaled innovation for his post on splining between points - //http://scaledinnovation.com/analytics/splines/aboutSplines.html - var d01 = Math.sqrt(Math.pow(MiddlePoint.x - FirstPoint.x, 2) + Math.pow(MiddlePoint.y - FirstPoint.y, 2)), - d12 = Math.sqrt(Math.pow(AfterPoint.x - MiddlePoint.x, 2) + Math.pow(AfterPoint.y - MiddlePoint.y, 2)), - fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta - fb = t * d12 / (d01 + d12); - return { - previous: { - x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), - y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) - }, - next: { - x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), - y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) - } - }; - }, - calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { - return Math.floor(Math.log(val) / Math.LN10); - }, - calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { - - //Set a minimum step of two - a point at the top of the graph, and a point at the base - var minSteps = 2, - maxSteps = Math.floor(drawingSize / (textSize * 1.5)), - skipFitting = (minSteps >= maxSteps); - - var maxValue = max(valuesArray), - minValue = min(valuesArray); - - // We need some degree of seperation here to calculate the scales if all the values are the same - // Adding/minusing 0.5 will give us a range of 1. - if (maxValue === minValue) { - maxValue += 0.5; - // So we don't end up with a graph with a negative start value if we've said always start from zero - if (minValue >= 0.5 && !startFromZero) { - minValue -= 0.5; - } else { - // Make up a whole number above the values - maxValue += 0.5; - } - } - - var valueRange = Math.abs(maxValue - minValue), - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphRange = graphMax - graphMin, - stepValue = Math.pow(10, rangeOrderOfMagnitude), - numberOfSteps = Math.round(graphRange / stepValue); - - //If we have more space on the graph we'll use it to give more definition to the data - while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { - if (numberOfSteps > maxSteps) { - stepValue *= 2; - numberOfSteps = Math.round(graphRange / stepValue); - // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. - if (numberOfSteps % 1 !== 0) { - skipFitting = true; - } - } - //We can fit in double the amount of scale points on the scale - else { - //If user has declared ints only, and the step value isn't a decimal - if (integersOnly && rangeOrderOfMagnitude >= 0) { - //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float - if (stepValue / 2 % 1 === 0) { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - //If it would make it a float break out of the loop - else { - break; - } - } - //If the scale doesn't have to be an int, make the scale more granular anyway. - else { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - - } - } - - if (skipFitting) { - numberOfSteps = minSteps; - stepValue = graphRange / numberOfSteps; - } - return { - steps: numberOfSteps, - stepValue: stepValue, - min: graphMin, - max: graphMin + (numberOfSteps * stepValue) - }; - - }, - // Implementation of the nice number algorithm used in determining where axis labels will go - niceNum = helpers.niceNum = function(range, round) { - var exponent = Math.floor(helpers.log10(range)); - var fraction = range / Math.pow(10, exponent); - var niceFraction; - - if (round) { - if (fraction < 1.5) { - niceFraction = 1; - } else if (fraction < 3) { - niceFraction = 2; - } else if (fraction < 7) { - niceFraction = 5; - } else { - niceFraction = 10; - } - } else { - if (fraction <= 1.0) { - niceFraction = 1; - } else if (fraction <= 2) { - niceFraction = 2; - } else if (fraction <= 5) { - niceFraction = 5; - } else { - niceFraction = 10; - } - } - - return niceFraction * Math.pow(10, exponent); - }, - /* jshint ignore:start */ - // Blows up jshint errors based on the new Function constructor - //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 instanceof Function) { - return templateString(valuesObject); - } - - var cache = {}; - - function tmpl(str, data) { - // Figure out if we're getting a template, or if we need to - // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] : - - // Generate a reusable function that will serve as a template - // generator (and which will be cached). - new Function("obj", - "var p=[],print=function(){p.push.apply(p,arguments);};" + - - // Introduce the data as local variables using with(){} - "with(obj){p.push('" + - - // Convert the template into pure JavaScript - str - .replace(/[\r\t\n]/g, " ") - .split("<%").join("\t") - .replace(/((^|%>)[^\t]*)'/g, "$1\r") - .replace(/\t=(.*?)%>/g, "',$1,'") - .split("\t").join("');") - .split("%>").join("p.push('") - .split("\r").join("\\'") + - "');}return p.join('');" - ); - - // Provide some basic currying to the user - return data ? fn(data) : fn; - } - return tmpl(templateString, valuesObject); - }, - /* jshint ignore:end */ - generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { - var labelsArray = new Array(numberOfSteps); - if (templateString) { - each(labelsArray, function(val, index) { - labelsArray[index] = template(templateString, { - value: (graphMin + (stepValue * (index + 1))) - }); - }); - } - return labelsArray; - }, - //--Animation methods - //Easing functions adapted from Robert Penner's easing equations - //http://www.robertpenner.com/easing/ - easingEffects = helpers.easingEffects = { - linear: function(t) { - return t; - }, - easeInQuad: function(t) { - return t * t; - }, - easeOutQuad: function(t) { - return -1 * t * (t - 2); - }, - easeInOutQuad: function(t) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t; - } - return -1 / 2 * ((--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) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t * t; - } - return 1 / 2 * ((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) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t * t * t; - } - return -1 / 2 * ((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) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t * t * t * t; - } - return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); - }, - easeInExpo: function(t) { - return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); - }, - easeOutExpo: function(t) { - return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); - }, - easeInOutExpo: function(t) { - if (t === 0) { - return 0; - } - if (t === 1) { - return 1; - } - if ((t /= 1 / 2) < 1) { - return 1 / 2 * Math.pow(2, 10 * (t - 1)); - } - return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); - }, - easeInCirc: function(t) { - if (t >= 1) { - return t; - } - return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); - }, - easeOutCirc: function(t) { - return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); - }, - easeInOutCirc: function(t) { - if ((t /= 1 / 2) < 1) { - return -1 / 2 * (Math.sqrt(1 - t * t) - 1); - } - return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); - }, - easeInElastic: function(t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0) { - return 0; - } - if ((t /= 1) == 1) { - return 1; - } - if (!p) { - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); - }, - easeOutElastic: function(t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0) { - return 0; - } - if ((t /= 1) == 1) { - return 1; - } - if (!p) { - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; - }, - easeInOutElastic: function(t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0) { - return 0; - } - if ((t /= 1 / 2) == 2) { - return 1; - } - if (!p) { - p = 1 * (0.3 * 1.5); - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - if (t < 1) { - return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); - } - return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; - }, - easeInBack: function(t) { - var s = 1.70158; - return 1 * (t /= 1) * t * ((s + 1) * t - s); - }, - easeOutBack: function(t) { - var s = 1.70158; - return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); - }, - easeInOutBack: function(t) { - var s = 1.70158; - if ((t /= 1 / 2) < 1) { - return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); - } - return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); - }, - easeInBounce: function(t) { - return 1 - easingEffects.easeOutBounce(1 - t); - }, - easeOutBounce: function(t) { - if ((t /= 1) < (1 / 2.75)) { - return 1 * (7.5625 * t * t); - } else if (t < (2 / 2.75)) { - return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); - } else if (t < (2.5 / 2.75)) { - return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); - } else { - return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); - } - }, - easeInOutBounce: function(t) { - if (t < 1 / 2) { - return easingEffects.easeInBounce(t * 2) * 0.5; - } - return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; - } - }, - //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ - requestAnimFrame = helpers.requestAnimFrame = (function() { - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - return window.setTimeout(callback, 1000 / 60); - }; - })(), - cancelAnimFrame = helpers.cancelAnimFrame = (function() { - return window.cancelAnimationFrame || - window.webkitCancelAnimationFrame || - window.mozCancelAnimationFrame || - window.oCancelAnimationFrame || - window.msCancelAnimationFrame || - function(callback) { - return window.clearTimeout(callback, 1000 / 60); - }; - })(), - animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { - - var currentStep = 0, - easingFunction = easingEffects[easingString] || easingEffects.linear; - - var animationFrame = function() { - currentStep++; - var stepDecimal = currentStep / totalSteps; - var easeDecimal = easingFunction(stepDecimal); - - callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); - onProgress.call(chartInstance, easeDecimal, stepDecimal); - if (currentStep < totalSteps) { - chartInstance.animationFrame = requestAnimFrame(animationFrame); - } else { - onComplete.apply(chartInstance); - } - }; - requestAnimFrame(animationFrame); - }, - //-- DOM methods - getRelativePosition = helpers.getRelativePosition = function(evt) { - var mouseX, mouseY; - var e = evt.originalEvent || evt, - canvas = evt.currentTarget || evt.srcElement, - boundingRect = canvas.getBoundingClientRect(); - - if (e.touches) { - mouseX = e.touches[0].clientX - boundingRect.left; - mouseY = e.touches[0].clientY - boundingRect.top; - - } else { - mouseX = e.clientX - boundingRect.left; - mouseY = e.clientY - boundingRect.top; - } - - return { - x: mouseX, - y: mouseY - }; - - }, - addEvent = helpers.addEvent = function(node, eventType, method) { - if (node.addEventListener) { - node.addEventListener(eventType, method); - } else if (node.attachEvent) { - node.attachEvent("on" + eventType, method); - } else { - node["on" + eventType] = method; - } - }, - removeEvent = helpers.removeEvent = function(node, eventType, handler) { - if (node.removeEventListener) { - node.removeEventListener(eventType, handler, false); - } else if (node.detachEvent) { - node.detachEvent("on" + eventType, handler); - } else { - node["on" + eventType] = noop; - } - }, - bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) { - // Create the events object if it's not already present - if (!chartInstance.events) chartInstance.events = {}; - - each(arrayOfEvents, function(eventName) { - chartInstance.events[eventName] = function() { - handler.apply(chartInstance, arguments); - }; - addEvent(chartInstance.chart.canvas, eventName, chartInstance.events[eventName]); - }); - }, - unbindEvents = helpers.unbindEvents = function(chartInstance, arrayOfEvents) { - each(arrayOfEvents, function(handler, eventName) { - removeEvent(chartInstance.chart.canvas, eventName, handler); - }); - }, - getMaximumWidth = helpers.getMaximumWidth = function(domNode) { - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); - // TODO = check cross browser stuff with this. - return container.clientWidth - padding; - }, - getMaximumHeight = helpers.getMaximumHeight = function(domNode) { - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); - // TODO = check cross browser stuff with this. - return container.clientHeight - padding; - }, - getStyle = helpers.getStyle = function(el, property) { - return el.currentStyle ? - el.currentStyle[property] : - document.defaultView.getComputedStyle(el, null).getPropertyValue(property); - }, - getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support - retinaScale = helpers.retinaScale = function(chart) { - var ctx = chart.ctx, - width = chart.canvas.width, - height = chart.canvas.height; - - if (window.devicePixelRatio) { - ctx.canvas.style.width = width + "px"; - ctx.canvas.style.height = height + "px"; - ctx.canvas.height = height * window.devicePixelRatio; - ctx.canvas.width = width * window.devicePixelRatio; - ctx.scale(window.devicePixelRatio, window.devicePixelRatio); - } - }, - //-- Canvas methods - clear = helpers.clear = function(chart) { - chart.ctx.clearRect(0, 0, chart.width, chart.height); - }, - fontString = helpers.fontString = function(pixelSize, fontStyle, fontFamily) { - return fontStyle + " " + pixelSize + "px " + fontFamily; - }, - longestText = helpers.longestText = function(ctx, font, arrayOfStrings) { - ctx.font = font; - var longest = 0; - each(arrayOfStrings, function(string) { - var textWidth = ctx.measureText(string).width; - longest = (textWidth > longest) ? textWidth : longest; - }); - return longest; - }, - drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx, x, y, width, height, radius) { - ctx.beginPath(); - ctx.moveTo(x + radius, y); - ctx.lineTo(x + width - radius, y); - ctx.quadraticCurveTo(x + width, y, x + width, y + radius); - ctx.lineTo(x + width, y + height - radius); - ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); - ctx.lineTo(x + radius, y + height); - ctx.quadraticCurveTo(x, y + height, x, y + height - radius); - ctx.lineTo(x, y + radius); - ctx.quadraticCurveTo(x, y, x + radius, y); - ctx.closePath(); - }, - color = helpers.color = function(color) { - if (!window.Color) { - console.log('Color.js not found!'); - return color; - } - return window.Color(color); - }, - isArray = helpers.isArray = function(obj) { - if (!Array.isArray) { - return Object.prototype.toString.call(arg) === '[object Array]'; - } - return Array.isArray(obj); - }; - - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. - //Destroy method on the chart will remove the instance of the chart from this reference. - Chart.instances = {}; - - Chart.Type = function(config, instance) { - this.data = config.data; - this.options = config.options; - this.chart = instance; - this.id = uid(); - //Add the chart instance to the global namespace - Chart.instances[this.id] = this; - - // Initialize is always called when a chart type is created - // By default it is a no op, but it should be extended - if (this.options.responsive) { - this.resize(); - } - this.initialize.call(this); - }; - - //Core methods that'll be a part of every chart type - extend(Chart.Type.prototype, { - initialize: function() { - return this; - }, - clear: function() { - clear(this.chart); - return this; - }, - stop: function() { - // Stops any current animation loop occuring - Chart.animationService.cancelAnimation(this); - return this; - }, - resize: function() { - this.stop(); - var canvas = this.chart.canvas, - newWidth = getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); - - canvas.width = this.chart.width = newWidth; - canvas.height = this.chart.height = newHeight; - - retinaScale(this.chart); - - return this; - }, - redraw: noop, - render: function(duration) { - - if (this.options.animation.duration !== 0 || duration) { - var animation = new Chart.Animation(); - animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps - animation.easing = this.options.animation.easing; - - // render function - animation.render = function(chartInstance, animationObject) { - var easingFunction = helpers.easingEffects[animationObject.easing]; - var stepDecimal = animationObject.currentStep / animationObject.numSteps; - var easeDecimal = easingFunction(stepDecimal); - - chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); - }; - - // user events - animation.onAnimationProgress = this.options.onAnimationProgress; - animation.onAnimationComplete = this.options.onAnimationComplete; - - Chart.animationService.addAnimation(this, animation, duration); - } else { - this.draw(); - this.options.onAnimationComplete.call(this); - } - return this; - }, - eachElement: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - }, this); - }, - eachValue: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, callback, this, datasetIndex); - }, this); - }, - eachDataset: function(callback) { - helpers.each(this.data.datasets, callback, this); - }, - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; - }, - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } - - return []; - }, - generateLegend: function() { - return template(this.options.legendTemplate, this); - }, - 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]; - }, - toBase64Image: function() { - return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); - } - }); - - Chart.Type.extend = function(extensions) { - - var parent = this; - - var ChartType = function() { - return parent.apply(this, arguments); - }; - - //Copy the prototype object of the this class - ChartType.prototype = clone(parent.prototype); - //Now overwrite some of the properties in the base class with the new extensions - extend(ChartType.prototype, extensions); - - ChartType.extend = Chart.Type.extend; - - if (extensions.name || parent.prototype.name) { - - var chartName = extensions.name || parent.prototype.name; - //Assign any potential default values of the new chart type - - //If none are defined, we'll use a clone of the chart type this is being extended from. - //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart - //doesn't define some defaults of their own. - - var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; - - Chart.defaults[chartName] = helpers.configMerge(baseDefaults, extensions.defaults); - - Chart.types[chartName] = ChartType; - - //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(config) { - config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[chartName], config.options || {}); - return new ChartType(config, this); - }; - } else { - warn("Name not provided for this chart, so it hasn't been registered"); - } - return parent; - }; - - Chart.Element = function(configuration) { - extend(this, configuration); - this.initialize.apply(this, arguments); - }; - extend(Chart.Element.prototype, { - initialize: function() {}, - pivot: function() { - if (!this._view) { - this._view = clone(this._model); - } - this._start = clone(this._view); - return this; - }, - transition: function(ease) { - if (!this._view) { - this._view = clone(this._model); - } - if (!this._start) { - this.pivot(); - } - - each(this._model, function(value, key) { - - if (key[0] === '_' || !this._model.hasOwnProperty(key)) { - // Only non-underscored properties - } - - // Init if doesn't exist - else if (!this._view[key]) { - if (typeof value === 'number') { - this._view[key] = value * ease; - } else { - this._view[key] = value || null; - } - } - - // No unnecessary computations - else if (this._model[key] === this._view[key]) { - // It's the same! Woohoo! - } - - // Color transitions if possible - else if (typeof value === 'string') { - try { - var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); - this._view[key] = color.rgbString(); - } catch (err) { - this._view[key] = value; - } - } - // Number transitions - else if (typeof value === 'number') { - var startVal = this._start[key] !== undefined ? this._start[key] : 0; - this._view[key] = ((this._model[key] - startVal) * ease) + startVal; - } - // Everything else - else { - this._view[key] = value; - } - - }, this); - - if (ease === 1) { - delete this._start; - } - return this; - }, - tooltipPosition: function() { - return { - x: this._model.x, - y: this._model.y - }; - }, - hasValue: function() { - return isNumber(this._model.x) && isNumber(this._model.y); - } - }); - - Chart.Element.extend = inherits; - - - // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function() { - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function() { - clearTimeout(timeout); - timeout = setTimeout(function() { - each(Chart.instances, function(instance) { - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive) { - instance.resize(); - instance.update(); - } - }); - }, 50); - }; - })()); - - - if (amd) { - define(function() { - return Chart; - }); - } else if (typeof module === 'object' && module.exports) { - module.exports = Chart; - } - - root.Chart = Chart; - - Chart.noConflict = function() { - root.Chart = previous; - return Chart; - }; + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart; + + //Occupy the global variable of Chart, and create a simple base class + var Chart = function(context) { + var chart = this; + + // Support a jQuery'd canvas element + if (context.length && context[0].getContext) { + context = context[0]; + } + + // Support a canvas domnode + if (context.getContext) { + context = context.getContext("2d"); + } + + this.canvas = context.canvas; + + this.ctx = context; + + //Variables global to the chart + var computeDimension = function(element, dimension) { + if (element['offset' + dimension]) { + return element['offset' + dimension]; + } else { + return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); + } + }; + + var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; + var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; + + // Firefox requires this to work correctly + context.canvas.width = width; + context.canvas.height = height; + + width = this.width = context.canvas.width; + height = this.height = context.canvas.height; + this.aspectRatio = this.width / this.height; + //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. + helpers.retinaScale(this); + + return this; + }; + + var defaultColor = 'rgba(0,0,0,0.1)'; + + //Globally expose the defaults to allow for user updating/changing + Chart.defaults = { + global: { + responsive: true, + maintainAspectRatio: true, + events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], + hover: { + onHover: null, + mode: 'single', + animationDuration: 400, + }, + onClick: null, + defaultColor: defaultColor, + + // Element defaults defined in element extensions + elements: {} + }, + }; + + //Create a dictionary of chart types, to allow for extension of existing types + Chart.types = {}; + + //Global Chart helpers object for utility methods and classes + var helpers = Chart.helpers = {}; + + //-- Basic js utility methods + var each = helpers.each = function(loopable, callback, self) { + var additionalArgs = Array.prototype.slice.call(arguments, 3); + // Check to see if null or undefined firstly. + if (loopable) { + if (loopable.length === +loopable.length) { + var i; + for (i = 0; i < loopable.length; i++) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } + } else { + for (var item in loopable) { + callback.apply(self, [loopable[item], item].concat(additionalArgs)); + } + } + } + }, + clone = helpers.clone = function(obj) { + var objClone = {}; + each(obj, function(value, key) { + if (obj.hasOwnProperty(key)) { + if (typeof value === 'object' && value !== null) { + objClone[key] = clone(value); + } else { + objClone[key] = value; + } + } + }); + return objClone; + }, + extend = helpers.extend = function(base) { + each(Array.prototype.slice.call(arguments, 1), function(extensionObject) { + each(extensionObject, function(value, key) { + if (extensionObject.hasOwnProperty(key)) { + base[key] = value; + } + }); + }); + return base; + }, + merge = helpers.merge = function(base, master) { + //Merge properties in left object over to a shallow clone of object right. + var args = Array.prototype.slice.call(arguments, 0); + args.unshift({}); + return extend.apply(null, args); + }, + // Need a special merge function to chart configs since they are now grouped + configMerge = helpers.configMerge = function(_base) { + var base = clone(_base); + helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { + helpers.each(extension, function(value, key) { + if (extension.hasOwnProperty(key)) { + if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { + // In this case we have an array of objects replacing another array. Rather than doing a strict replace, + // merge. This allows easy scale option merging + var baseArray = base[key]; + + helpers.each(value, function(valueObj, index) { + if (index < baseArray.length) { + baseArray[index] = helpers.configMerge(baseArray[index], valueObj); + } else { + baseArray.push(valueObj); // nothing to merge + } + }); + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { + // If we are overwriting an object with an object, do a merge of the properties. + base[key] = helpers.configMerge(base[key], value); + } else { + // can just overwrite the value in this case + base[key] = value; + } + } + }); + }); + + return base; + }, + getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { + if (!value) { + return defaultValue; + } + + if (helpers.isArray(value) && index < value.length) { + return value[index]; + } + + return value; + }, + indexOf = helpers.indexOf = function(arrayToSearch, item) { + if (Array.prototype.indexOf) { + return arrayToSearch.indexOf(item); + } else { + for (var i = 0; i < arrayToSearch.length; i++) { + if (arrayToSearch[i] === item) return i; + } + return -1; + } + }, + where = helpers.where = function(collection, filterCallback) { + var filtered = []; + + helpers.each(collection, function(item) { + if (filterCallback(item)) { + filtered.push(item); + } + }); + + return filtered; + }, + findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to start of the array + if (!startIndex) { + startIndex = -1; + } + for (var i = startIndex + 1; i < arrayToSearch.length; i++) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to end of the array + if (!startIndex) { + startIndex = arrayToSearch.length; + } + for (var i = startIndex - 1; i >= 0; i--) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + inherits = helpers.inherits = function(extensions) { + //Basic javascript inheritance based on the model created in Backbone.js + var parent = this; + var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() { + return parent.apply(this, arguments); + }; + + var Surrogate = function() { + this.constructor = ChartElement; + }; + Surrogate.prototype = parent.prototype; + ChartElement.prototype = new Surrogate(); + + ChartElement.extend = inherits; + + if (extensions) extend(ChartElement.prototype, extensions); + + ChartElement.__super__ = parent.prototype; + + return ChartElement; + }, + noop = helpers.noop = function() {}, + uid = helpers.uid = (function() { + var id = 0; + return function() { + return "chart-" + id++; + }; + })(), + warn = helpers.warn = function(str) { + //Method for warning of errors + if (window.console && typeof window.console.warn === "function") console.warn(str); + }, + amd = helpers.amd = (typeof define === 'function' && define.amd), + //-- Math methods + isNumber = helpers.isNumber = function(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + }, + max = helpers.max = function(array) { + return Math.max.apply(Math, array); + }, + min = helpers.min = function(array) { + return Math.min.apply(Math, array); + }, + sign = helpers.sign = function(x) { + if (Math.sign) { + return Math.sign(x); + } else { + x = +x; // convert to a number + if (x === 0 || isNaN(x)) { + return x; + } + return x > 0 ? 1 : -1; + } + }, + log10 = helpers.log10 = function(x) { + if (Math.log10) { + return Math.log10(x) + } else { + return Math.log(x) / Math.LN10; + } + }, + cap = helpers.cap = function(valueToCap, maxValue, minValue) { + if (isNumber(maxValue)) { + if (valueToCap > maxValue) { + return maxValue; + } + } else if (isNumber(minValue)) { + if (valueToCap < minValue) { + return minValue; + } + } + return valueToCap; + }, + getDecimalPlaces = helpers.getDecimalPlaces = function(num) { + if (num % 1 !== 0 && isNumber(num)) { + var s = num.toString(); + if (s.indexOf("e-") < 0) { + // no exponent, e.g. 0.01 + return s.split(".")[1].length; + } else if (s.indexOf(".") < 0) { + // no decimal point, e.g. 1e-9 + return parseInt(s.split("e-")[1]); + } else { + // exponent and decimal point, e.g. 1.23e-9 + var parts = s.split(".")[1].split("e-"); + return parts[0].length + parseInt(parts[1]); + } + } else { + return 0; + } + }, + toRadians = helpers.toRadians = function(degrees) { + return degrees * (Math.PI / 180); + }, + toDegrees = helpers.toDegrees = function(radians) { + return radians * (180 / Math.PI); + }, + // Gets the angle from vertical upright to the point about a centre. + getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { + var distanceFromXCenter = anglePoint.x - centrePoint.x, + distanceFromYCenter = anglePoint.y - centrePoint.y, + radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + + var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); + + if (angle < (-0.5 * Math.PI)) { + angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2] + } + + return { + angle: angle, + distance: radialDistanceFromCenter + }; + }, + aliasPixel = helpers.aliasPixel = function(pixelWidth) { + return (pixelWidth % 2 === 0) ? 0 : 0.5; + }, + splineCurve = helpers.splineCurve = function(FirstPoint, MiddlePoint, AfterPoint, t) { + //Props to Rob Spencer at scaled innovation for his post on splining between points + //http://scaledinnovation.com/analytics/splines/aboutSplines.html + var d01 = Math.sqrt(Math.pow(MiddlePoint.x - FirstPoint.x, 2) + Math.pow(MiddlePoint.y - FirstPoint.y, 2)), + d12 = Math.sqrt(Math.pow(AfterPoint.x - MiddlePoint.x, 2) + Math.pow(AfterPoint.y - MiddlePoint.y, 2)), + fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta + fb = t * d12 / (d01 + d12); + return { + previous: { + x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) + }, + next: { + x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) + } + }; + }, + calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { + return Math.floor(Math.log(val) / Math.LN10); + }, + calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { + + //Set a minimum step of two - a point at the top of the graph, and a point at the base + var minSteps = 2, + maxSteps = Math.floor(drawingSize / (textSize * 1.5)), + skipFitting = (minSteps >= maxSteps); + + var maxValue = max(valuesArray), + minValue = min(valuesArray); + + // We need some degree of seperation here to calculate the scales if all the values are the same + // Adding/minusing 0.5 will give us a range of 1. + if (maxValue === minValue) { + maxValue += 0.5; + // So we don't end up with a graph with a negative start value if we've said always start from zero + if (minValue >= 0.5 && !startFromZero) { + minValue -= 0.5; + } else { + // Make up a whole number above the values + maxValue += 0.5; + } + } + + var valueRange = Math.abs(maxValue - minValue), + rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), + graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphRange = graphMax - graphMin, + stepValue = Math.pow(10, rangeOrderOfMagnitude), + numberOfSteps = Math.round(graphRange / stepValue); + + //If we have more space on the graph we'll use it to give more definition to the data + while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { + if (numberOfSteps > maxSteps) { + stepValue *= 2; + numberOfSteps = Math.round(graphRange / stepValue); + // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. + if (numberOfSteps % 1 !== 0) { + skipFitting = true; + } + } + //We can fit in double the amount of scale points on the scale + else { + //If user has declared ints only, and the step value isn't a decimal + if (integersOnly && rangeOrderOfMagnitude >= 0) { + //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float + if (stepValue / 2 % 1 === 0) { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + //If it would make it a float break out of the loop + else { + break; + } + } + //If the scale doesn't have to be an int, make the scale more granular anyway. + else { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + + } + } + + if (skipFitting) { + numberOfSteps = minSteps; + stepValue = graphRange / numberOfSteps; + } + return { + steps: numberOfSteps, + stepValue: stepValue, + min: graphMin, + max: graphMin + (numberOfSteps * stepValue) + }; + + }, + // Implementation of the nice number algorithm used in determining where axis labels will go + niceNum = helpers.niceNum = function(range, round) { + var exponent = Math.floor(helpers.log10(range)); + var fraction = range / Math.pow(10, exponent); + var niceFraction; + + if (round) { + if (fraction < 1.5) { + niceFraction = 1; + } else if (fraction < 3) { + niceFraction = 2; + } else if (fraction < 7) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } else { + if (fraction <= 1.0) { + niceFraction = 1; + } else if (fraction <= 2) { + niceFraction = 2; + } else if (fraction <= 5) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } + + return niceFraction * Math.pow(10, exponent); + }, + /* jshint ignore:start */ + // Blows up jshint errors based on the new Function constructor + //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 instanceof Function) { + return templateString(valuesObject); + } + + var cache = {}; + + function tmpl(str, data) { + // Figure out if we're getting a template, or if we need to + // load the template - and be sure to cache the result. + var fn = !/\W/.test(str) ? + cache[str] = cache[str] : + + // Generate a reusable function that will serve as a template + // generator (and which will be cached). + new Function("obj", + "var p=[],print=function(){p.push.apply(p,arguments);};" + + + // Introduce the data as local variables using with(){} + "with(obj){p.push('" + + + // Convert the template into pure JavaScript + str + .replace(/[\r\t\n]/g, " ") + .split("<%").join("\t") + .replace(/((^|%>)[^\t]*)'/g, "$1\r") + .replace(/\t=(.*?)%>/g, "',$1,'") + .split("\t").join("');") + .split("%>").join("p.push('") + .split("\r").join("\\'") + + "');}return p.join('');" + ); + + // Provide some basic currying to the user + return data ? fn(data) : fn; + } + return tmpl(templateString, valuesObject); + }, + /* jshint ignore:end */ + generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { + var labelsArray = new Array(numberOfSteps); + if (templateString) { + each(labelsArray, function(val, index) { + labelsArray[index] = template(templateString, { + value: (graphMin + (stepValue * (index + 1))) + }); + }); + } + return labelsArray; + }, + //--Animation methods + //Easing functions adapted from Robert Penner's easing equations + //http://www.robertpenner.com/easing/ + easingEffects = helpers.easingEffects = { + linear: function(t) { + return t; + }, + easeInQuad: function(t) { + return t * t; + }, + easeOutQuad: function(t) { + return -1 * t * (t - 2); + }, + easeInOutQuad: function(t) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t; + } + return -1 / 2 * ((--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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t; + } + return 1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t; + } + return -1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t * t; + } + return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); + }, + easeInExpo: function(t) { + return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); + }, + easeOutExpo: function(t) { + return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); + }, + easeInOutExpo: function(t) { + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if ((t /= 1 / 2) < 1) { + return 1 / 2 * Math.pow(2, 10 * (t - 1)); + } + return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); + }, + easeInCirc: function(t) { + if (t >= 1) { + return t; + } + return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); + }, + easeOutCirc: function(t) { + return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); + }, + easeInOutCirc: function(t) { + if ((t /= 1 / 2) < 1) { + return -1 / 2 * (Math.sqrt(1 - t * t) - 1); + } + return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); + }, + easeInElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + }, + easeOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; + }, + easeInOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1 / 2) == 2) { + return 1; + } + if (!p) { + p = 1 * (0.3 * 1.5); + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1) { + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; + }, + easeInBack: function(t) { + var s = 1.70158; + return 1 * (t /= 1) * t * ((s + 1) * t - s); + }, + easeOutBack: function(t) { + var s = 1.70158; + return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); + }, + easeInOutBack: function(t) { + var s = 1.70158; + if ((t /= 1 / 2) < 1) { + return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); + } + return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); + }, + easeInBounce: function(t) { + return 1 - easingEffects.easeOutBounce(1 - t); + }, + easeOutBounce: function(t) { + if ((t /= 1) < (1 / 2.75)) { + return 1 * (7.5625 * t * t); + } else if (t < (2 / 2.75)) { + return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); + } else if (t < (2.5 / 2.75)) { + return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); + } else { + return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); + } + }, + easeInOutBounce: function(t) { + if (t < 1 / 2) { + return easingEffects.easeInBounce(t * 2) * 0.5; + } + return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; + } + }, + //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ + requestAnimFrame = helpers.requestAnimFrame = (function() { + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function(callback) { + return window.setTimeout(callback, 1000 / 60); + }; + })(), + cancelAnimFrame = helpers.cancelAnimFrame = (function() { + return window.cancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.mozCancelAnimationFrame || + window.oCancelAnimationFrame || + window.msCancelAnimationFrame || + function(callback) { + return window.clearTimeout(callback, 1000 / 60); + }; + })(), + animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { + + var currentStep = 0, + easingFunction = easingEffects[easingString] || easingEffects.linear; + + var animationFrame = function() { + currentStep++; + var stepDecimal = currentStep / totalSteps; + var easeDecimal = easingFunction(stepDecimal); + + callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); + onProgress.call(chartInstance, easeDecimal, stepDecimal); + if (currentStep < totalSteps) { + chartInstance.animationFrame = requestAnimFrame(animationFrame); + } else { + onComplete.apply(chartInstance); + } + }; + requestAnimFrame(animationFrame); + }, + //-- DOM methods + getRelativePosition = helpers.getRelativePosition = function(evt) { + var mouseX, mouseY; + var e = evt.originalEvent || evt, + canvas = evt.currentTarget || evt.srcElement, + boundingRect = canvas.getBoundingClientRect(); + + if (e.touches) { + mouseX = e.touches[0].clientX - boundingRect.left; + mouseY = e.touches[0].clientY - boundingRect.top; + + } else { + mouseX = e.clientX - boundingRect.left; + mouseY = e.clientY - boundingRect.top; + } + + return { + x: mouseX, + y: mouseY + }; + + }, + addEvent = helpers.addEvent = function(node, eventType, method) { + if (node.addEventListener) { + node.addEventListener(eventType, method); + } else if (node.attachEvent) { + node.attachEvent("on" + eventType, method); + } else { + node["on" + eventType] = method; + } + }, + removeEvent = helpers.removeEvent = function(node, eventType, handler) { + if (node.removeEventListener) { + node.removeEventListener(eventType, handler, false); + } else if (node.detachEvent) { + node.detachEvent("on" + eventType, handler); + } else { + node["on" + eventType] = noop; + } + }, + bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) { + // Create the events object if it's not already present + if (!chartInstance.events) chartInstance.events = {}; + + each(arrayOfEvents, function(eventName) { + chartInstance.events[eventName] = function() { + handler.apply(chartInstance, arguments); + }; + addEvent(chartInstance.chart.canvas, eventName, chartInstance.events[eventName]); + }); + }, + unbindEvents = helpers.unbindEvents = function(chartInstance, arrayOfEvents) { + each(arrayOfEvents, function(handler, eventName) { + removeEvent(chartInstance.chart.canvas, eventName, handler); + }); + }, + getMaximumWidth = helpers.getMaximumWidth = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); + // TODO = check cross browser stuff with this. + return container.clientWidth - padding; + }, + getMaximumHeight = helpers.getMaximumHeight = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); + // TODO = check cross browser stuff with this. + return container.clientHeight - padding; + }, + getStyle = helpers.getStyle = function(el, property) { + return el.currentStyle ? + el.currentStyle[property] : + document.defaultView.getComputedStyle(el, null).getPropertyValue(property); + }, + getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support + retinaScale = helpers.retinaScale = function(chart) { + var ctx = chart.ctx, + width = chart.canvas.width, + height = chart.canvas.height; + + if (window.devicePixelRatio) { + ctx.canvas.style.width = width + "px"; + ctx.canvas.style.height = height + "px"; + ctx.canvas.height = height * window.devicePixelRatio; + ctx.canvas.width = width * window.devicePixelRatio; + ctx.scale(window.devicePixelRatio, window.devicePixelRatio); + } + }, + //-- Canvas methods + clear = helpers.clear = function(chart) { + chart.ctx.clearRect(0, 0, chart.width, chart.height); + }, + fontString = helpers.fontString = function(pixelSize, fontStyle, fontFamily) { + return fontStyle + " " + pixelSize + "px " + fontFamily; + }, + longestText = helpers.longestText = function(ctx, font, arrayOfStrings) { + ctx.font = font; + var longest = 0; + each(arrayOfStrings, function(string) { + var textWidth = ctx.measureText(string).width; + longest = (textWidth > longest) ? textWidth : longest; + }); + return longest; + }, + drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx, x, y, width, height, radius) { + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + }, + color = helpers.color = function(color) { + if (!window.Color) { + console.log('Color.js not found!'); + return color; + } + return window.Color(color); + }, + isArray = helpers.isArray = function(obj) { + if (!Array.isArray) { + return Object.prototype.toString.call(arg) === '[object Array]'; + } + return Array.isArray(obj); + }; + + //Store a reference to each instance - allowing us to globally resize chart instances on window resize. + //Destroy method on the chart will remove the instance of the chart from this reference. + Chart.instances = {}; + + Chart.Type = function(config, instance) { + this.data = config.data; + this.options = config.options; + this.chart = instance; + this.id = uid(); + //Add the chart instance to the global namespace + Chart.instances[this.id] = this; + + // Initialize is always called when a chart type is created + // By default it is a no op, but it should be extended + if (this.options.responsive) { + this.resize(); + } + this.initialize.call(this); + }; + + //Core methods that'll be a part of every chart type + extend(Chart.Type.prototype, { + initialize: function() { + return this; + }, + clear: function() { + clear(this.chart); + return this; + }, + stop: function() { + // Stops any current animation loop occuring + Chart.animationService.cancelAnimation(this); + return this; + }, + resize: function() { + this.stop(); + var canvas = this.chart.canvas, + newWidth = getMaximumWidth(this.chart.canvas), + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + + canvas.width = this.chart.width = newWidth; + canvas.height = this.chart.height = newHeight; + + retinaScale(this.chart); + + return this; + }, + redraw: noop, + render: function(duration) { + + if (this.options.animation.duration !== 0 || duration) { + var animation = new Chart.Animation(); + animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps + animation.easing = this.options.animation.easing; + + // render function + animation.render = function(chartInstance, animationObject) { + var easingFunction = helpers.easingEffects[animationObject.easing]; + var stepDecimal = animationObject.currentStep / animationObject.numSteps; + var easeDecimal = easingFunction(stepDecimal); + + chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); + }; + + // user events + animation.onAnimationProgress = this.options.onAnimationProgress; + animation.onAnimationComplete = this.options.onAnimationComplete; + + Chart.animationService.addAnimation(this, animation, duration); + } else { + this.draw(); + this.options.onAnimationComplete.call(this); + } + return this; + }, + eachElement: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }, + eachValue: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.data, callback, this, datasetIndex); + }, this); + }, + eachDataset: function(callback) { + helpers.each(this.data.datasets, callback, this); + }, + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + generateLegend: function() { + return template(this.options.legendTemplate, this); + }, + 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]; + }, + toBase64Image: function() { + return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); + } + }); + + Chart.Type.extend = function(extensions) { + + var parent = this; + + var ChartType = function() { + return parent.apply(this, arguments); + }; + + //Copy the prototype object of the this class + ChartType.prototype = clone(parent.prototype); + //Now overwrite some of the properties in the base class with the new extensions + extend(ChartType.prototype, extensions); + + ChartType.extend = Chart.Type.extend; + + if (extensions.name || parent.prototype.name) { + + var chartName = extensions.name || parent.prototype.name; + //Assign any potential default values of the new chart type + + //If none are defined, we'll use a clone of the chart type this is being extended from. + //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart + //doesn't define some defaults of their own. + + var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; + + Chart.defaults[chartName] = helpers.configMerge(baseDefaults, extensions.defaults); + + Chart.types[chartName] = ChartType; + + //Register this new chart type in the Chart prototype + Chart.prototype[chartName] = function(config) { + config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[chartName], config.options || {}); + return new ChartType(config, this); + }; + } else { + warn("Name not provided for this chart, so it hasn't been registered"); + } + return parent; + }; + + Chart.Element = function(configuration) { + extend(this, configuration); + this.initialize.apply(this, arguments); + }; + extend(Chart.Element.prototype, { + initialize: function() {}, + pivot: function() { + if (!this._view) { + this._view = clone(this._model); + } + this._start = clone(this._view); + return this; + }, + transition: function(ease) { + if (!this._view) { + this._view = clone(this._model); + } + if (!this._start) { + this.pivot(); + } + + each(this._model, function(value, key) { + + if (key[0] === '_' || !this._model.hasOwnProperty(key)) { + // Only non-underscored properties + } + + // Init if doesn't exist + else if (!this._view[key]) { + if (typeof value === 'number') { + this._view[key] = value * ease; + } else { + this._view[key] = value || null; + } + } + + // No unnecessary computations + else if (this._model[key] === this._view[key]) { + // It's the same! Woohoo! + } + + // Color transitions if possible + else if (typeof value === 'string') { + try { + var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); + this._view[key] = color.rgbString(); + } catch (err) { + this._view[key] = value; + } + } + // Number transitions + else if (typeof value === 'number') { + var startVal = this._start[key] !== undefined ? this._start[key] : 0; + this._view[key] = ((this._model[key] - startVal) * ease) + startVal; + } + // Everything else + else { + this._view[key] = value; + } + + }, this); + + if (ease === 1) { + delete this._start; + } + return this; + }, + tooltipPosition: function() { + return { + x: this._model.x, + y: this._model.y + }; + }, + hasValue: function() { + return isNumber(this._model.x) && isNumber(this._model.y); + } + }); + + Chart.Element.extend = inherits; + + + // Attach global event to resize each chart instance when the browser resizes + helpers.addEvent(window, "resize", (function() { + // Basic debounce of resize function so it doesn't hurt performance when resizing browser. + var timeout; + return function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + each(Chart.instances, function(instance) { + // If the responsive flag is set in the chart instance config + // Cascade the resize event down to the chart. + if (instance.options.responsive) { + instance.resize(); + instance.update(); + } + }); + }, 50); + }; + })()); + + + if (amd) { + define(function() { + return Chart; + }); + } else if (typeof module === 'object' && module.exports) { + module.exports = Chart; + } + + root.Chart = Chart; + + Chart.noConflict = function() { + root.Chart = previous; + return Chart; + }; }).call(this); diff --git a/src/core/core.scale.js b/src/core/core.scale.js index dc9a9a70252..ce5c8246003 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -1,302 +1,302 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - // The scale service is used to resize charts along with all of their axes. We make this as - // a service where scales are registered with their respective charts so that changing the - // scales does not require - Chart.scaleService = { - // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then - // use the new chart options to grab the correct scale - constructors: {}, - // Use a registration function so that we can move to an ES6 map when we no longer need to support - // old browsers - registerScaleType: function(type, scaleConstructor) { - this.constructors[type] = scaleConstructor; - }, - getScaleConstructor: function(type) { - return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; - }, - - // The interesting function - fitScalesForChart: function(chartInstance, width, height) { - var xPadding = width > 30 ? 5 : 2; - var yPadding = height > 30 ? 5 : 2; - - if (chartInstance) { - var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "left"; - }); - var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "right"; - }); - var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "top"; - }); - var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "bottom"; - }); - - var visibleLeftScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "left"; - }); - var visibleRightScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "right"; - }); - var visibleTopScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "top"; - }); - var visibleBottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "bottom"; - }); - - // // Adjust the padding to take into account displaying labels - // if (topScales.length === 0 || bottomScales.length === 0) { - // var maxFontHeight = 0; - - // var maxFontHeightFunction = function(scaleInstance) { - // if (scaleInstance.options.labels.show) { - // // Only consider font sizes for axes that actually show labels - // maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); - // } - // }; - - // helpers.each(leftScales, maxFontHeightFunction); - // helpers.each(rightScales, maxFontHeightFunction); - - // if (topScales.length === 0) { - // // Add padding so that we can handle drawing the top nicely - // yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides - // } - - // if (bottomScales.length === 0) { - // // Add padding so that we can handle drawing the bottom nicely - // yPadding += 1.5 * maxFontHeight; - // } - // } - - // Essentially we now have any number of scales on each of the 4 sides. - // Our canvas looks like the following. - // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and - // B1 is the bottom axis - // |------------------------------------------------------| - // | | T1 | | - // |----|-----|-------------------------------------|-----| - // | | | | | - // | L1 | L2 | Chart area | R1 | - // | | | | | - // | | | | | - // |----|-----|-------------------------------------|-----| - // | | B1 | | - // | | | | - // |------------------------------------------------------| - - // What we do to find the best sizing, we do the following - // 1. Determine the minimum size of the chart area. - // 2. Split the remaining width equally between each vertical axis - // 3. Split the remaining height equally between each horizontal axis - // 4. Give each scale the maximum size it can be. The scale will return it's minimum size - // 5. Adjust the sizes of each axis based on it's minimum reported size. - // 6. Refit each axis - // 7. Position each axis in the final location - // 8. Tell the chart the final location of the chart area - - // Step 1 - var chartWidth = width / 2; // min 50% - var chartHeight = height / 2; // min 50% - - chartWidth -= (2 * xPadding); - chartHeight -= (2 * yPadding); - - - // Step 2 - var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); - - // Step 3 - var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); - - // Step 4; - var minimumScaleSizes = []; - - var verticalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); - minimumScaleSizes.push({ - horizontal: false, - minSize: minSize, - scale: scaleInstance, - }); - }; - - var horizontalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); - minimumScaleSizes.push({ - horizontal: true, - minSize: minSize, - scale: scaleInstance, - }); - }; - - // vertical scales - helpers.each(leftScales, verticalScaleMinSizeFunction); - helpers.each(rightScales, verticalScaleMinSizeFunction); - - // horizontal scales - helpers.each(topScales, horizontalScaleMinSizeFunction); - helpers.each(bottomScales, horizontalScaleMinSizeFunction); - - // Step 5 - var maxChartHeight = height - (2 * yPadding); - var maxChartWidth = width - (2 * xPadding); - - helpers.each(minimumScaleSizes, function(wrapper) { - if (wrapper.horizontal) { - maxChartHeight -= wrapper.minSize.height; - } else { - maxChartWidth -= wrapper.minSize.width; - } - }); - - // At this point, maxChartHeight and maxChartWidth are the size the chart area could - // be if the axes are drawn at their minimum sizes. - - // Step 6 - var verticalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight); - } - }; - - var horizontalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - var scaleMargin = { - left: totalLeftWidth, - right: totalRightWidth, - top: 0, - bottom: 0, - }; - - if (wrapper) { - scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); - } - }; - - var totalLeftWidth = xPadding; - var totalRightWidth = xPadding; - var totalTopHeight = yPadding; - var totalBottomHeight = yPadding; - - helpers.each(leftScales, verticalScaleFitFunction); - helpers.each(rightScales, verticalScaleFitFunction); - - // Figure out how much margin is on the left and right of the horizontal axes - helpers.each(leftScales, function(scaleInstance) { - totalLeftWidth += scaleInstance.width; - }); - - helpers.each(rightScales, function(scaleInstance) { - totalRightWidth += scaleInstance.width; - }); - - helpers.each(topScales, horizontalScaleFitFunction); - helpers.each(bottomScales, horizontalScaleFitFunction); - - helpers.each(topScales, function(scaleInstance) { - totalTopHeight += scaleInstance.height; - }); - helpers.each(bottomScales, function(scaleInstance) { - totalBottomHeight += scaleInstance.height; - }); - - // Let the left scale know the final margin - helpers.each(leftScales, function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - var scaleMargin = { - left: 0, - right: 0, - top: totalTopHeight, - bottom: totalBottomHeight - }; - - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); - } - }); - - helpers.each(rightScales, function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - var scaleMargin = { - left: 0, - right: 0, - top: totalTopHeight, - bottom: totalBottomHeight - }; - - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); - } - }); - - // Step 7 - // Position the scales - var left = xPadding; - var top = yPadding; - var right = 0; - var bottom = 0; - - var verticalScalePlacer = function(scaleInstance) { - scaleInstance.left = left; - scaleInstance.right = left + scaleInstance.width; - scaleInstance.top = totalTopHeight; - scaleInstance.bottom = totalTopHeight + maxChartHeight; - - // Move to next point - left = scaleInstance.right; - }; - - var horizontalScalePlacer = function(scaleInstance) { - scaleInstance.left = totalLeftWidth; - scaleInstance.right = totalLeftWidth + maxChartWidth; - scaleInstance.top = top; - scaleInstance.bottom = top + scaleInstance.height; - - // Move to next point - top = scaleInstance.bottom; - }; - - helpers.each(leftScales, verticalScalePlacer); - helpers.each(topScales, horizontalScalePlacer); - - // Account for chart width and height - left += maxChartWidth; - top += maxChartHeight; - - helpers.each(rightScales, verticalScalePlacer); - helpers.each(bottomScales, horizontalScalePlacer); - - // Step 8 - chartInstance.chartArea = { - left: totalLeftWidth, - top: totalTopHeight, - right: totalLeftWidth + maxChartWidth, - bottom: totalTopHeight + maxChartHeight, - }; - } - } - }; + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + // The scale service is used to resize charts along with all of their axes. We make this as + // a service where scales are registered with their respective charts so that changing the + // scales does not require + Chart.scaleService = { + // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then + // use the new chart options to grab the correct scale + constructors: {}, + // Use a registration function so that we can move to an ES6 map when we no longer need to support + // old browsers + registerScaleType: function(type, scaleConstructor) { + this.constructors[type] = scaleConstructor; + }, + getScaleConstructor: function(type) { + return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; + }, + + // The interesting function + fitScalesForChart: function(chartInstance, width, height) { + var xPadding = width > 30 ? 5 : 2; + var yPadding = height > 30 ? 5 : 2; + + if (chartInstance) { + var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "left"; + }); + var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "right"; + }); + var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "top"; + }); + var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "bottom"; + }); + + var visibleLeftScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "left"; + }); + var visibleRightScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "right"; + }); + var visibleTopScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "top"; + }); + var visibleBottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "bottom"; + }); + + // // Adjust the padding to take into account displaying labels + // if (topScales.length === 0 || bottomScales.length === 0) { + // var maxFontHeight = 0; + + // var maxFontHeightFunction = function(scaleInstance) { + // if (scaleInstance.options.labels.show) { + // // Only consider font sizes for axes that actually show labels + // maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); + // } + // }; + + // helpers.each(leftScales, maxFontHeightFunction); + // helpers.each(rightScales, maxFontHeightFunction); + + // if (topScales.length === 0) { + // // Add padding so that we can handle drawing the top nicely + // yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides + // } + + // if (bottomScales.length === 0) { + // // Add padding so that we can handle drawing the bottom nicely + // yPadding += 1.5 * maxFontHeight; + // } + // } + + // Essentially we now have any number of scales on each of the 4 sides. + // Our canvas looks like the following. + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and + // B1 is the bottom axis + // |------------------------------------------------------| + // | | T1 | | + // |----|-----|-------------------------------------|-----| + // | | | | | + // | L1 | L2 | Chart area | R1 | + // | | | | | + // | | | | | + // |----|-----|-------------------------------------|-----| + // | | B1 | | + // | | | | + // |------------------------------------------------------| + + // What we do to find the best sizing, we do the following + // 1. Determine the minimum size of the chart area. + // 2. Split the remaining width equally between each vertical axis + // 3. Split the remaining height equally between each horizontal axis + // 4. Give each scale the maximum size it can be. The scale will return it's minimum size + // 5. Adjust the sizes of each axis based on it's minimum reported size. + // 6. Refit each axis + // 7. Position each axis in the final location + // 8. Tell the chart the final location of the chart area + + // Step 1 + var chartWidth = width / 2; // min 50% + var chartHeight = height / 2; // min 50% + + chartWidth -= (2 * xPadding); + chartHeight -= (2 * yPadding); + + + // Step 2 + var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); + + // Step 3 + var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); + + // Step 4; + var minimumScaleSizes = []; + + var verticalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); + minimumScaleSizes.push({ + horizontal: false, + minSize: minSize, + scale: scaleInstance, + }); + }; + + var horizontalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); + minimumScaleSizes.push({ + horizontal: true, + minSize: minSize, + scale: scaleInstance, + }); + }; + + // vertical scales + helpers.each(leftScales, verticalScaleMinSizeFunction); + helpers.each(rightScales, verticalScaleMinSizeFunction); + + // horizontal scales + helpers.each(topScales, horizontalScaleMinSizeFunction); + helpers.each(bottomScales, horizontalScaleMinSizeFunction); + + // Step 5 + var maxChartHeight = height - (2 * yPadding); + var maxChartWidth = width - (2 * xPadding); + + helpers.each(minimumScaleSizes, function(wrapper) { + if (wrapper.horizontal) { + maxChartHeight -= wrapper.minSize.height; + } else { + maxChartWidth -= wrapper.minSize.width; + } + }); + + // At this point, maxChartHeight and maxChartWidth are the size the chart area could + // be if the axes are drawn at their minimum sizes. + + // Step 6 + var verticalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight); + } + }; + + var horizontalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: totalLeftWidth, + right: totalRightWidth, + top: 0, + bottom: 0, + }; + + if (wrapper) { + scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); + } + }; + + var totalLeftWidth = xPadding; + var totalRightWidth = xPadding; + var totalTopHeight = yPadding; + var totalBottomHeight = yPadding; + + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); + + // Figure out how much margin is on the left and right of the horizontal axes + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); + + helpers.each(rightScales, function(scaleInstance) { + totalRightWidth += scaleInstance.width; + }); + + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); + + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; + }); + helpers.each(bottomScales, function(scaleInstance) { + totalBottomHeight += scaleInstance.height; + }); + + // Let the left scale know the final margin + helpers.each(leftScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + + helpers.each(rightScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + + // Step 7 + // Position the scales + var left = xPadding; + var top = yPadding; + var right = 0; + var bottom = 0; + + var verticalScalePlacer = function(scaleInstance) { + scaleInstance.left = left; + scaleInstance.right = left + scaleInstance.width; + scaleInstance.top = totalTopHeight; + scaleInstance.bottom = totalTopHeight + maxChartHeight; + + // Move to next point + left = scaleInstance.right; + }; + + var horizontalScalePlacer = function(scaleInstance) { + scaleInstance.left = totalLeftWidth; + scaleInstance.right = totalLeftWidth + maxChartWidth; + scaleInstance.top = top; + scaleInstance.bottom = top + scaleInstance.height; + + // Move to next point + top = scaleInstance.bottom; + }; + + helpers.each(leftScales, verticalScalePlacer); + helpers.each(topScales, horizontalScalePlacer); + + // Account for chart width and height + left += maxChartWidth; + top += maxChartHeight; + + helpers.each(rightScales, verticalScalePlacer); + helpers.each(bottomScales, horizontalScalePlacer); + + // Step 8 + chartInstance.chartArea = { + left: totalLeftWidth, + top: totalTopHeight, + right: totalLeftWidth + maxChartWidth, + bottom: totalTopHeight + maxChartHeight, + }; + } + } + }; }).call(this); diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 72abb14f051..308a0c069ec 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -11,334 +11,334 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.tooltips = { - enabled: true, - custom: null, - backgroundColor: "rgba(0,0,0,0.8)", - fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - fontSize: 10, - fontStyle: "normal", - fontColor: "#fff", - titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - titleFontSize: 12, - titleFontStyle: "bold", - titleFontColor: "#fff", - yPadding: 6, - xPadding: 6, - caretSize: 8, - cornerRadius: 6, - xOffset: 10, - template: [ - '<% if(label){ %>', - '<%=label %>: ', - '<% } %>', - '<%=value %>', - ].join(''), - multiTemplate: [ - '<%if (datasetLabel){ %>', - '<%=datasetLabel %>: ', - '<% } %>', - '<%=value %>' - ].join(''), - multiKeyBackground: '#fff', - }; - - Chart.Tooltip = Chart.Element.extend({ - initialize: function() { - var options = this._options; - helpers.extend(this, { - _model: { - // Positioning - xPadding: options.tooltips.xPadding, - yPadding: options.tooltips.yPadding, - xOffset: options.tooltips.xOffset, - - // Labels - textColor: options.tooltips.fontColor, - _fontFamily: options.tooltips.fontFamily, - _fontStyle: options.tooltips.fontStyle, - fontSize: options.tooltips.fontSize, - - // Title - titleTextColor: options.tooltips.titleFontColor, - _titleFontFamily: options.tooltips.titleFontFamily, - _titleFontStyle: options.tooltips.titleFontStyle, - titleFontSize: options.tooltips.titleFontSize, - - // Appearance - caretHeight: options.tooltips.caretSize, - cornerRadius: options.tooltips.cornerRadius, - backgroundColor: options.tooltips.backgroundColor, - opacity: 0, - legendColorBackground: options.tooltips.multiKeyBackground, - }, - }); - }, - update: function() { - - var ctx = this._chart.ctx; - - switch (this._options.hover.mode) { - case 'single': - helpers.extend(this._model, { - text: helpers.template(this._options.tooltips.template, { - // These variables are available in the template function. Add others here - element: this._active[0], - value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], - label: this._data.labels ? this._data.labels[this._active[0]._index] : '', - }), - }); - - var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this._model, { - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - caretPadding: tooltipPosition.padding - }); - - break; - - case 'label': - - // Tooltip Content - - var dataArray, - dataIndex; - - var labels = [], - colors = []; - - for (var i = this._data.datasets.length - 1; i >= 0; i--) { - dataArray = this._data.datasets[i].metaData; - dataIndex = helpers.indexOf(dataArray, this._active[0]); - if (dataIndex !== -1) { - break; - } - } - - var medianPosition = (function(index) { - // Get all the points at that particular index - var elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this._data.datasets, function(dataset) { - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { - elements.push(dataCollection[dataIndex]); - } - }, this); - - // Reverse labels if stacked - helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { - xPositions.push(element._view.x); - yPositions.push(element._view.y); - - //Include any colour information about the element - labels.push(helpers.template(this._options.tooltips.multiTemplate, { - // These variables are available in the template function. Add others here - element: element, - datasetLabel: this._data.datasets[element._datasetIndex].label, - value: this._data.datasets[element._datasetIndex].data[element._index], - })); - colors.push({ - fill: element._view.backgroundColor, - stroke: element._view.borderColor - }); - - }, this); - - yMin = helpers.min(yPositions); - yMax = helpers.max(yPositions); - - xMin = helpers.min(xPositions); - xMax = helpers.max(xPositions); - - return { - x: (xMin > this._chart.width / 2) ? xMin : xMax, - y: (yMin + yMax) / 2, - }; - }).call(this, dataIndex); - - // Apply for now - helpers.extend(this._model, { - x: medianPosition.x, - y: medianPosition.y, - labels: labels, - title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', - legendColors: colors, - legendBackgroundColor: this._options.tooltips.multiKeyBackground, - }); - - - // Calculate Appearance Tweaks - - this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; - - var titleWidth = ctx.measureText(this.title).width, - //Label has a legend square as well so account for this. - labelWidth = helpers.longestText(ctx, this.font, labels) + this._model.fontSize + 3, - longestTextWidth = helpers.max([labelWidth, titleWidth]); - - this._model.width = longestTextWidth + (this._model.xPadding * 2); - - - var halfHeight = this._model.height / 2; - - //Check to ensure the height will fit on the canvas - if (this._model.y - halfHeight < 0) { - this._model.y = halfHeight; - } else if (this._model.y + halfHeight > this._chart.height) { - this._model.y = this._chart.height - halfHeight; - } - - //Decide whether to align left or right based on position on canvas - if (this._model.x > this._chart.width / 2) { - this._model.x -= this._model.xOffset + this._model.width; - } else { - this._model.x += this._model.xOffset; - } - break; - } - - return this; - }, - draw: function() { - - var ctx = this._chart.ctx; - var vm = this._view; - - switch (this._options.hover.mode) { - case 'single': - - ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - - vm.xAlign = "center"; - vm.yAlign = "above"; - - //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding || 2; - - var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, - tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, - tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - - if (vm.x + tooltipWidth / 2 > this._chart.width) { - vm.xAlign = "left"; - } else if (vm.x - tooltipWidth / 2 < 0) { - vm.xAlign = "right"; - } - - if (vm.y - tooltipHeight < 0) { - vm.yAlign = "below"; - } - - var tooltipX = vm.x - tooltipWidth / 2, - tooltipY = vm.y - tooltipHeight; - - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - - // Custom Tooltips - if (this._custom) { - this._custom(this._view); - } else { - switch (vm.yAlign) { - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } - - switch (vm.xAlign) { - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } - - helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); - - ctx.fill(); - - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); - - } - break; - case 'label': - - helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - ctx.fill(); - ctx.closePath(); - - ctx.textAlign = "left"; - ctx.textBaseline = "middle"; - ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); - ctx.font = helpers.fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); - ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); - - ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - helpers.each(vm.labels, function(label, index) { - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); - - //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) - //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); - //Instead we'll make a white filled block to put the legendColour palette over. - - ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); - - ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); - - - }, this); - break; - } - }, - getLineHeight: function(index) { - var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, - afterTitleIndex = index - 1; - - //If the index is zero, we're getting the title - if (index === 0) { - return baseLineHeight + this._view.titleFontSize / 2; - } else { - return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; - } - - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.tooltips = { + enabled: true, + custom: null, + backgroundColor: "rgba(0,0,0,0.8)", + fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + fontSize: 10, + fontStyle: "normal", + fontColor: "#fff", + titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + titleFontSize: 12, + titleFontStyle: "bold", + titleFontColor: "#fff", + yPadding: 6, + xPadding: 6, + caretSize: 8, + cornerRadius: 6, + xOffset: 10, + template: [ + '<% if(label){ %>', + '<%=label %>: ', + '<% } %>', + '<%=value %>', + ].join(''), + multiTemplate: [ + '<%if (datasetLabel){ %>', + '<%=datasetLabel %>: ', + '<% } %>', + '<%=value %>' + ].join(''), + multiKeyBackground: '#fff', + }; + + Chart.Tooltip = Chart.Element.extend({ + initialize: function() { + var options = this._options; + helpers.extend(this, { + _model: { + // Positioning + xPadding: options.tooltips.xPadding, + yPadding: options.tooltips.yPadding, + xOffset: options.tooltips.xOffset, + + // Labels + textColor: options.tooltips.fontColor, + _fontFamily: options.tooltips.fontFamily, + _fontStyle: options.tooltips.fontStyle, + fontSize: options.tooltips.fontSize, + + // Title + titleTextColor: options.tooltips.titleFontColor, + _titleFontFamily: options.tooltips.titleFontFamily, + _titleFontStyle: options.tooltips.titleFontStyle, + titleFontSize: options.tooltips.titleFontSize, + + // Appearance + caretHeight: options.tooltips.caretSize, + cornerRadius: options.tooltips.cornerRadius, + backgroundColor: options.tooltips.backgroundColor, + opacity: 0, + legendColorBackground: options.tooltips.multiKeyBackground, + }, + }); + }, + update: function() { + + var ctx = this._chart.ctx; + + switch (this._options.hover.mode) { + case 'single': + helpers.extend(this._model, { + text: helpers.template(this._options.tooltips.template, { + // These variables are available in the template function. Add others here + element: this._active[0], + value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], + label: this._data.labels ? this._data.labels[this._active[0]._index] : '', + }), + }); + + var tooltipPosition = this._active[0].tooltipPosition(); + helpers.extend(this._model, { + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + caretPadding: tooltipPosition.padding + }); + + break; + + case 'label': + + // Tooltip Content + + var dataArray, + dataIndex; + + var labels = [], + colors = []; + + for (var i = this._data.datasets.length - 1; i >= 0; i--) { + dataArray = this._data.datasets[i].metaData; + dataIndex = helpers.indexOf(dataArray, this._active[0]); + if (dataIndex !== -1) { + break; + } + } + + var medianPosition = (function(index) { + // Get all the points at that particular index + var elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this._data.datasets, function(dataset) { + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { + elements.push(dataCollection[dataIndex]); + } + }, this); + + // Reverse labels if stacked + helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { + xPositions.push(element._view.x); + yPositions.push(element._view.y); + + //Include any colour information about the element + labels.push(helpers.template(this._options.tooltips.multiTemplate, { + // These variables are available in the template function. Add others here + element: element, + datasetLabel: this._data.datasets[element._datasetIndex].label, + value: this._data.datasets[element._datasetIndex].data[element._index], + })); + colors.push({ + fill: element._view.backgroundColor, + stroke: element._view.borderColor + }); + + }, this); + + yMin = helpers.min(yPositions); + yMax = helpers.max(yPositions); + + xMin = helpers.min(xPositions); + xMax = helpers.max(xPositions); + + return { + x: (xMin > this._chart.width / 2) ? xMin : xMax, + y: (yMin + yMax) / 2, + }; + }).call(this, dataIndex); + + // Apply for now + helpers.extend(this._model, { + x: medianPosition.x, + y: medianPosition.y, + labels: labels, + title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', + legendColors: colors, + legendBackgroundColor: this._options.tooltips.multiKeyBackground, + }); + + + // Calculate Appearance Tweaks + + this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; + + var titleWidth = ctx.measureText(this.title).width, + //Label has a legend square as well so account for this. + labelWidth = helpers.longestText(ctx, this.font, labels) + this._model.fontSize + 3, + longestTextWidth = helpers.max([labelWidth, titleWidth]); + + this._model.width = longestTextWidth + (this._model.xPadding * 2); + + + var halfHeight = this._model.height / 2; + + //Check to ensure the height will fit on the canvas + if (this._model.y - halfHeight < 0) { + this._model.y = halfHeight; + } else if (this._model.y + halfHeight > this._chart.height) { + this._model.y = this._chart.height - halfHeight; + } + + //Decide whether to align left or right based on position on canvas + if (this._model.x > this._chart.width / 2) { + this._model.x -= this._model.xOffset + this._model.width; + } else { + this._model.x += this._model.xOffset; + } + break; + } + + return this; + }, + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._view; + + switch (this._options.hover.mode) { + case 'single': + + ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + + vm.xAlign = "center"; + vm.yAlign = "above"; + + //Distance between the actual element.y position and the start of the tooltip caret + var caretPadding = vm.caretPadding || 2; + + var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, + tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; + + if (vm.x + tooltipWidth / 2 > this._chart.width) { + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth / 2 < 0) { + vm.xAlign = "right"; + } + + if (vm.y - tooltipHeight < 0) { + vm.yAlign = "below"; + } + + var tooltipX = vm.x - tooltipWidth / 2, + tooltipY = vm.y - tooltipHeight; + + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + + // Custom Tooltips + if (this._custom) { + this._custom(this._view); + } else { + switch (vm.yAlign) { + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } + + switch (vm.xAlign) { + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } + + helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); + + ctx.fill(); + + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); + + } + break; + case 'label': + + helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + ctx.fill(); + ctx.closePath(); + + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); + ctx.font = helpers.fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); + ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); + + ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + helpers.each(vm.labels, function(label, index) { + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); + + //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) + //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + //Instead we'll make a white filled block to put the legendColour palette over. + + ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); + + ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + + }, this); + break; + } + }, + getLineHeight: function(index) { + var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, + afterTitleIndex = index - 1; + + //If the index is zero, we're getting the title + if (index === 0) { + return baseLineHeight + this._view.titleFontSize / 2; + } else { + return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; + } + + }, + }); }).call(this); diff --git a/src/elements/element.arc.js b/src/elements/element.arc.js index 0d3bddb68ff..a726abfd29a 100644 --- a/src/elements/element.arc.js +++ b/src/elements/element.arc.js @@ -11,83 +11,83 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.elements.arc = { - backgroundColor: Chart.defaults.global.defaultColor, - borderColor: "#fff", - borderWidth: 2 - }; - - Chart.Arc = Chart.Element.extend({ - inGroupRange: function(mouseX) { - var vm = this._view; - - if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); - } else { - return false; - } - }, - inRange: function(chartX, chartY) { - - var vm = this._view; - - var pointRelativePosition = helpers.getAngleFromPoint(vm, { - x: chartX, - y: chartY - }); - - // Put into the range of (-PI/2, 3PI/2] - var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; - var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle - - //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), - withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); - - return (betweenAngles && withinRadius); - //Ensure within the outside of the arc centre, but inside arc outer - }, - tooltipPosition: function() { - var vm = this._view; - - var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), - rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; - return { - x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), - y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) - }; - }, - draw: function() { - - var ctx = this._chart.ctx; - var vm = this._view; - - ctx.beginPath(); - - ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); - - ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); - - ctx.closePath(); - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; - - ctx.fillStyle = vm.backgroundColor; - - ctx.fill(); - ctx.lineJoin = 'bevel'; - - if (vm.borderWidth) { - ctx.stroke(); - } - } - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.arc = { + backgroundColor: Chart.defaults.global.defaultColor, + borderColor: "#fff", + borderWidth: 2 + }; + + Chart.Arc = Chart.Element.extend({ + inGroupRange: function(mouseX) { + var vm = this._view; + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + } else { + return false; + } + }, + inRange: function(chartX, chartY) { + + var vm = this._view; + + var pointRelativePosition = helpers.getAngleFromPoint(vm, { + x: chartX, + y: chartY + }); + + // Put into the range of (-PI/2, 3PI/2] + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle + + //Check if within the range of the open/close angle + var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), + withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); + + return (betweenAngles && withinRadius); + //Ensure within the outside of the arc centre, but inside arc outer + }, + tooltipPosition: function() { + var vm = this._view; + + var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), + rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; + return { + x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), + y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) + }; + }, + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._view; + + ctx.beginPath(); + + ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); + + ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); + + ctx.closePath(); + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; + + ctx.fillStyle = vm.backgroundColor; + + ctx.fill(); + ctx.lineJoin = 'bevel'; + + if (vm.borderWidth) { + ctx.stroke(); + } + } + }); }).call(this); diff --git a/src/elements/element.line.js b/src/elements/element.line.js index eaa245c76b8..edefce6d092 100644 --- a/src/elements/element.line.js +++ b/src/elements/element.line.js @@ -11,180 +11,180 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.elements.line = { - tension: 0.4, - backgroundColor: Chart.defaults.global.defaultColor, - borderWidth: 3, - borderColor: Chart.defaults.global.defaultColor, - fill: true, // do we fill in the area between the line and its base axis - skipNull: true, - drawNull: false, - }; - - - Chart.Line = Chart.Element.extend({ - draw: function() { - - var vm = this._view; - var ctx = this._chart.ctx; - var first = this._children[0]; - var last = this._children[this._children.length - 1]; - - // Draw the background first (so the border is always on top) - helpers.each(this._children, function(point, index) { - var previous = this.previousPoint(point, this._children, index); - var next = this.nextPoint(point, this._children, index); - - // First point only - if (index === 0) { - ctx.moveTo(point._view.x, point._view.y); - return; - } - - // Start Skip and drag along scale baseline - if (point._view.skip && vm.skipNull && !this._loop) { - ctx.lineTo(previous._view.x, point._view.y); - ctx.moveTo(next._view.x, point._view.y); - } - // End Skip Stright line from the base line - else if (previous._view.skip && vm.skipNull && !this._loop) { - ctx.moveTo(point._view.x, previous._view.y); - ctx.lineTo(point._view.x, point._view.y); - } - - if (previous._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, point._view.y); - } - // Normal Bezier Curve - else { - if (vm.tension > 0) { - ctx.bezierCurveTo( - previous._view.controlPointNextX, - previous._view.controlPointNextY, - point._view.controlPointPreviousX, - point._view.controlPointPreviousY, - point._view.x, - point._view.y - ); - } else { - ctx.lineTo(point._view.x, point._view.y); - } - } - }, this); - - // For radial scales, loop back around to the first point - if (this._loop) { - if (vm.tension > 0 && !first._view.skip) { - - ctx.bezierCurveTo( - last._view.controlPointNextX, - last._view.controlPointNextY, - first._view.controlPointPreviousX, - first._view.controlPointPreviousY, - first._view.x, - first._view.y - ); - } else { - ctx.lineTo(first._view.x, first._view.y); - } - } - - // If we had points and want to fill this line, do so. - if (this._children.length > 0 && vm.fill) { - //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero); - ctx.lineTo(this._children[0]._view.x, vm.scaleZero); - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; - ctx.closePath(); - ctx.fill(); - } - - - // Now draw the line between all the points with any borders - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; - ctx.beginPath(); - - helpers.each(this._children, function(point, index) { - var previous = this.previousPoint(point, this._children, index); - var next = this.nextPoint(point, this._children, index); - - // First point only - if (index === 0) { - ctx.moveTo(point._view.x, point._view.y); - return; - } - - // Start Skip and drag along scale baseline - if (point._view.skip && vm.skipNull && !this._loop) { - ctx.moveTo(previous._view.x, point._view.y); - ctx.moveTo(next._view.x, point._view.y); - return; - } - // End Skip Stright line from the base line - if (previous._view.skip && vm.skipNull && !this._loop) { - ctx.moveTo(point._view.x, previous._view.y); - ctx.moveTo(point._view.x, point._view.y); - return; - } - - if (previous._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, point._view.y); - return; - } - // Normal Bezier Curve - if (vm.tension > 0) { - ctx.bezierCurveTo( - previous._view.controlPointNextX, - previous._view.controlPointNextY, - point._view.controlPointPreviousX, - point._view.controlPointPreviousY, - point._view.x, - point._view.y - ); - } else { - ctx.lineTo(point._view.x, point._view.y); - } - }, this); - - if (this._loop && !first._view.skip) { - if (vm.tension > 0) { - - ctx.bezierCurveTo( - last._view.controlPointNextX, - last._view.controlPointNextY, - first._view.controlPointPreviousX, - first._view.controlPointPreviousY, - first._view.x, - first._view.y - ); - } else { - ctx.lineTo(first._view.x, first._view.y); - } - } - - - ctx.stroke(); - - }, - nextPoint: function(point, collection, index) { - if (this.loop) { - return collection[index + 1] || collection[0]; - } - return collection[index + 1] || collection[collection.length - 1]; - }, - previousPoint: function(point, collection, index) { - if (this.loop) { - return collection[index - 1] || collection[collection.length - 1]; - } - return collection[index - 1] || collection[0]; - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.line = { + tension: 0.4, + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 3, + borderColor: Chart.defaults.global.defaultColor, + fill: true, // do we fill in the area between the line and its base axis + skipNull: true, + drawNull: false, + }; + + + Chart.Line = Chart.Element.extend({ + draw: function() { + + var vm = this._view; + var ctx = this._chart.ctx; + var first = this._children[0]; + var last = this._children[this._children.length - 1]; + + // Draw the background first (so the border is always on top) + helpers.each(this._children, function(point, index) { + var previous = this.previousPoint(point, this._children, index); + var next = this.nextPoint(point, this._children, index); + + // First point only + if (index === 0) { + ctx.moveTo(point._view.x, point._view.y); + return; + } + + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.lineTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); + } + // End Skip Stright line from the base line + else if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); + ctx.lineTo(point._view.x, point._view.y); + } + + if (previous._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, point._view.y); + } + // Normal Bezier Curve + else { + if (vm.tension > 0) { + ctx.bezierCurveTo( + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y + ); + } else { + ctx.lineTo(point._view.x, point._view.y); + } + } + }, this); + + // For radial scales, loop back around to the first point + if (this._loop) { + if (vm.tension > 0 && !first._view.skip) { + + ctx.bezierCurveTo( + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y + ); + } else { + ctx.lineTo(first._view.x, first._view.y); + } + } + + // If we had points and want to fill this line, do so. + if (this._children.length > 0 && vm.fill) { + //Round off the line by going to the base of the chart, back to the start, then fill. + ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero); + ctx.lineTo(this._children[0]._view.x, vm.scaleZero); + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; + ctx.closePath(); + ctx.fill(); + } + + + // Now draw the line between all the points with any borders + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.beginPath(); + + helpers.each(this._children, function(point, index) { + var previous = this.previousPoint(point, this._children, index); + var next = this.nextPoint(point, this._children, index); + + // First point only + if (index === 0) { + ctx.moveTo(point._view.x, point._view.y); + return; + } + + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); + return; + } + // End Skip Stright line from the base line + if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); + ctx.moveTo(point._view.x, point._view.y); + return; + } + + if (previous._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, point._view.y); + return; + } + // Normal Bezier Curve + if (vm.tension > 0) { + ctx.bezierCurveTo( + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y + ); + } else { + ctx.lineTo(point._view.x, point._view.y); + } + }, this); + + if (this._loop && !first._view.skip) { + if (vm.tension > 0) { + + ctx.bezierCurveTo( + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y + ); + } else { + ctx.lineTo(first._view.x, first._view.y); + } + } + + + ctx.stroke(); + + }, + nextPoint: function(point, collection, index) { + if (this.loop) { + return collection[index + 1] || collection[0]; + } + return collection[index + 1] || collection[collection.length - 1]; + }, + previousPoint: function(point, collection, index) { + if (this.loop) { + return collection[index - 1] || collection[collection.length - 1]; + } + return collection[index - 1] || collection[0]; + }, + }); }).call(this); diff --git a/src/elements/element.point.js b/src/elements/element.point.js index f402d729202..13e272de6f7 100644 --- a/src/elements/element.point.js +++ b/src/elements/element.point.js @@ -11,74 +11,74 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.elements.point = { - radius: 3, - backgroundColor: Chart.defaults.global.defaultColor, - borderWidth: 1, - borderColor: Chart.defaults.global.defaultColor, - // Hover - hitRadius: 1, - hoverRadius: 4, - hoverBorderWidth: 1, - }; - - - Chart.Point = Chart.Element.extend({ - inRange: function(mouseX, mouseY) { - var vm = this._view; - var hoverRange = vm.hitRadius + vm.radius; - return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); - }, - inGroupRange: function(mouseX) { - var vm = this._view; - - if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); - } else { - return false; - } - }, - tooltipPosition: function() { - var vm = this._view; - return { - x: vm.x, - y: vm.y, - padding: vm.radius + vm.borderWidth - }; - }, - draw: function() { - - var vm = this._view; - var ctx = this._chart.ctx; - - - if (vm.skip) { - return; - } - - if (vm.radius > 0 || vm.borderWidth > 0) { - - ctx.beginPath(); - - ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); - ctx.closePath(); - - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; - - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; - - ctx.fill(); - ctx.stroke(); - } - } - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.point = { + radius: 3, + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + // Hover + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1, + }; + + + Chart.Point = Chart.Element.extend({ + inRange: function(mouseX, mouseY) { + var vm = this._view; + var hoverRange = vm.hitRadius + vm.radius; + return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + }, + inGroupRange: function(mouseX) { + var vm = this._view; + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); + } else { + return false; + } + }, + tooltipPosition: function() { + var vm = this._view; + return { + x: vm.x, + y: vm.y, + padding: vm.radius + vm.borderWidth + }; + }, + draw: function() { + + var vm = this._view; + var ctx = this._chart.ctx; + + + if (vm.skip) { + return; + } + + if (vm.radius > 0 || vm.borderWidth > 0) { + + ctx.beginPath(); + + ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); + ctx.closePath(); + + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; + + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; + + ctx.fill(); + ctx.stroke(); + } + } + }); }).call(this); diff --git a/src/elements/element.rectangle.js b/src/elements/element.rectangle.js index fc4a58c0f17..7c35df01d3e 100644 --- a/src/elements/element.rectangle.js +++ b/src/elements/element.rectangle.js @@ -11,85 +11,85 @@ (function() { - "use strict"; + "use strict"; - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; - Chart.defaults.global.elements.rectangle = { - backgroundColor: Chart.defaults.global.defaultColor, - borderWidth: 0, - borderColor: Chart.defaults.global.defaultColor, - }; + Chart.defaults.global.elements.rectangle = { + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 0, + borderColor: Chart.defaults.global.defaultColor, + }; - Chart.Rectangle = Chart.Element.extend({ - draw: function() { + Chart.Rectangle = Chart.Element.extend({ + draw: function() { - var ctx = this._chart.ctx; - var vm = this._view; + var ctx = this._chart.ctx; + var vm = this._view; - var halfWidth = vm.width / 2, - leftX = vm.x - halfWidth, - rightX = vm.x + halfWidth, - top = vm.base - (vm.base - vm.y), - halfStroke = vm.borderWidth / 2; + var halfWidth = vm.width / 2, + leftX = vm.x - halfWidth, + rightX = vm.x + halfWidth, + top = vm.base - (vm.base - vm.y), + halfStroke = vm.borderWidth / 2; - // Canvas doesn't allow us to stroke inside the width so we can - // adjust the sizes to fit if we're setting a stroke on the line - if (vm.borderWidth) { - leftX += halfStroke; - rightX -= halfStroke; - top += halfStroke; - } + // Canvas doesn't allow us to stroke inside the width so we can + // adjust the sizes to fit if we're setting a stroke on the line + if (vm.borderWidth) { + leftX += halfStroke; + rightX -= halfStroke; + top += halfStroke; + } - ctx.beginPath(); + ctx.beginPath(); - ctx.fillStyle = vm.backgroundColor; - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; - // It'd be nice to keep this class totally generic to any rectangle - // and simply specify which border to miss out. - ctx.moveTo(leftX, vm.base); - ctx.lineTo(leftX, top); - ctx.lineTo(rightX, top); - ctx.lineTo(rightX, vm.base); - ctx.fill(); - if (vm.borderWidth) { - ctx.stroke(); - } - }, - height: function() { - var vm = this._view; - return vm.base - vm.y; - }, - inRange: function(mouseX, mouseY) { - var vm = this._view; - if (vm.y < vm.base) { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); - } else { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); - } - }, - inGroupRange: function(mouseX) { - var vm = this._view; - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); - }, - tooltipPosition: function() { - var vm = this._view; - if (vm.y < vm.base) { - return { - x: vm.x, - y: vm.y - }; - } else { - return { - x: vm.x, - y: vm.base - }; - } - }, - }); + // It'd be nice to keep this class totally generic to any rectangle + // and simply specify which border to miss out. + ctx.moveTo(leftX, vm.base); + ctx.lineTo(leftX, top); + ctx.lineTo(rightX, top); + ctx.lineTo(rightX, vm.base); + ctx.fill(); + if (vm.borderWidth) { + ctx.stroke(); + } + }, + height: function() { + var vm = this._view; + return vm.base - vm.y; + }, + inRange: function(mouseX, mouseY) { + var vm = this._view; + if (vm.y < vm.base) { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); + } else { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); + } + }, + inGroupRange: function(mouseX) { + var vm = this._view; + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + }, + tooltipPosition: function() { + var vm = this._view; + if (vm.y < vm.base) { + return { + x: vm.x, + y: vm.y + }; + } else { + return { + x: vm.x, + y: vm.base + }; + } + }, + }); }).call(this); From b0bddce017c1e8fa0094e69213a096a98377907d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 11:45:30 -0400 Subject: [PATCH 147/424] Remove some unused scale code --- src/core/core.scale.js | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index ce5c8246003..7494d14c865 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -40,44 +40,6 @@ return scaleInstance.options.position == "bottom"; }); - var visibleLeftScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "left"; - }); - var visibleRightScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "right"; - }); - var visibleTopScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "top"; - }); - var visibleBottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "bottom"; - }); - - // // Adjust the padding to take into account displaying labels - // if (topScales.length === 0 || bottomScales.length === 0) { - // var maxFontHeight = 0; - - // var maxFontHeightFunction = function(scaleInstance) { - // if (scaleInstance.options.labels.show) { - // // Only consider font sizes for axes that actually show labels - // maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); - // } - // }; - - // helpers.each(leftScales, maxFontHeightFunction); - // helpers.each(rightScales, maxFontHeightFunction); - - // if (topScales.length === 0) { - // // Add padding so that we can handle drawing the top nicely - // yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides - // } - - // if (bottomScales.length === 0) { - // // Add padding so that we can handle drawing the bottom nicely - // yPadding += 1.5 * maxFontHeight; - // } - // } - // Essentially we now have any number of scales on each of the 4 sides. // Our canvas looks like the following. // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and From 3e4fce58faa4d0aae316da17f6d0f8b09e02bd87 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 13:22:28 -0400 Subject: [PATCH 148/424] Clone handles arrays better --- src/core/core.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/core.js b/src/core/core.js index c01dfbaa955..b4af0a10b0b 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -108,7 +108,9 @@ var objClone = {}; each(obj, function(value, key) { if (obj.hasOwnProperty(key)) { - if (typeof value === 'object' && value !== null) { + if (helpers.isArray(value)) { + objClone[key] = value.slice(0); + } else if (typeof value === 'object' && value !== null) { objClone[key] = clone(value); } else { objClone[key] = value; From faa43d51a952c111c90f5ea020f9647b216d927e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 13:25:41 -0400 Subject: [PATCH 149/424] Category scale now has defaults. Updated the bar & line charts to use this new default. --- src/charts/chart.bar.js | 25 ++----------------- src/charts/chart.line.js | 25 ------------------- src/core/core.js | 47 +++++++++++++++++++++++++++++++++++- src/core/core.scale.js | 9 +++++-- src/scales/scale.category.js | 31 +++++++++++++++++++++++- 5 files changed, 85 insertions(+), 52 deletions(-) diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index b77fe97fe83..d83b25b44a3 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -12,38 +12,17 @@ scales: { xAxes: [{ - type: "category", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - + type: "category", categorySpacing: 10, spacing: 1, // grid line settings gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", offsetGridLines: true, }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, }], yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance + type: "linear", display: true, position: "left", id: "y-axis-1", diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 779f78e3f66..97b3e1ef208 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -13,31 +13,6 @@ scales: { xAxes: [{ type: "category", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: false, - }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, }], yAxes: [{ type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance diff --git a/src/core/core.js b/src/core/core.js index b4af0a10b0b..1cb6fafc7b9 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -141,21 +141,28 @@ helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { helpers.each(extension, function(value, key) { if (extension.hasOwnProperty(key)) { - if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { + if (key === 'scales') { + // Scale config merging is complex. Add out own function here for that + base[key] = helpers.scaleMerge(base.hasOwnProperty(key) ? base[key] : {}, value); + + } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { // In this case we have an array of objects replacing another array. Rather than doing a strict replace, // merge. This allows easy scale option merging var baseArray = base[key]; helpers.each(value, function(valueObj, index) { + if (index < baseArray.length) { baseArray[index] = helpers.configMerge(baseArray[index], valueObj); } else { baseArray.push(valueObj); // nothing to merge } }); + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { // If we are overwriting an object with an object, do a merge of the properties. base[key] = helpers.configMerge(base[key], value); + } else { // can just overwrite the value in this case base[key] = value; @@ -166,6 +173,44 @@ return base; }, + scaleMerge = helpers.scaleMerge = function(_base, extension) { + var base = clone(_base); + + helpers.each(extension, function(value, key) { + if (extension.hasOwnProperty(key)) { + if (key === 'xAxes' || key === 'yAxes') { + // These properties are arrays of items + if (base.hasOwnProperty(key)) { + helpers.each(value, function(valueObj, index) { + if (index >= base[key].length || !base[key][index].type) { + base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj)); + } else if (valueObj.type !== base[key][index].type) { + // Type changed. Bring in the new defaults before we bring in valueObj so that valueObj can override the correct scale defaults + base[key][index] = helpers.configMerge(base[key][index], valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj) + } else { + // Type is the same + base[key][index] = helpers.configMerge(base[key][index], valueObj); + } + }); + } else { + base[key] = []; + helpers.each(value, function(valueObj) { + base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj)); + }); + } + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { + // If we are overwriting an object with an object, do a merge of the properties. + base[key] = helpers.configMerge(base[key], value); + + } else { + // can just overwrite the value in this case + base[key] = value; + } + } + }); + + return base; + }, getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { if (!value) { return defaultValue; diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 7494d14c865..c738f1f5853 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -14,13 +14,18 @@ constructors: {}, // Use a registration function so that we can move to an ES6 map when we no longer need to support // old browsers - registerScaleType: function(type, scaleConstructor) { + // Scale config defaults + defaults: {}, + registerScaleType: function(type, scaleConstructor, defaults) { this.constructors[type] = scaleConstructor; + this.defaults[type] = defaults; }, getScaleConstructor: function(type) { return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; }, - + getScaleDefaults: function(type) { + return this.defaults.hasOwnProperty(type) ? this.defaults[type] : {}; + }, // The interesting function fitScalesForChart: function(chartInstance, width, height) { var xPadding = width > 30 ? 5 : 2; diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 7ed54613ec9..35773157840 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -5,6 +5,35 @@ Chart = root.Chart, helpers = Chart.helpers; + // Default config for a category scale + var defaultConfig = { + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }; + var DatasetScale = Chart.Element.extend({ isHorizontal: function() { return this.options.position == "top" || this.options.position == "bottom"; @@ -233,5 +262,5 @@ } } }); - Chart.scaleService.registerScaleType("category", DatasetScale); + Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig); }).call(this); From 109de75c6a0124e7da82059778b14cd9cf4d595e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 13:57:55 -0400 Subject: [PATCH 150/424] Create linear scale default settings. Cleaned up unnecessary settings from bar, line, and scatter default configs. Removed unnecessary config options from the affected sample files --- samples/bar-multi-axis.html | 51 +---------------------------- samples/bar-stacked.html | 5 ++- samples/line-multi-axis.html | 47 -------------------------- samples/line.html | 4 +-- samples/scatter-multi-axis.html | 47 -------------------------- src/charts/chart.bar.js | 30 ----------------- src/charts/chart.line.js | 32 ++---------------- src/charts/chart.scatter.js | 58 ++------------------------------- src/scales/scale.linear.js | 35 ++++++++++++++++++-- 9 files changed, 44 insertions(+), 265 deletions(-) diff --git a/samples/bar-multi-axis.html b/samples/bar-multi-axis.html index cdb573007e9..d6ae2595156 100644 --- a/samples/bar-multi-axis.html +++ b/samples/bar-multi-axis.html @@ -58,62 +58,13 @@ display: true, position: "left", id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } }, { type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance display: true, position: "right", id: "y-axis-2", - - // grid line settings gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: false, // only want the grid lines for one axis to show up - drawTicks: false, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", + drawOnChartArea: false } }], } diff --git a/samples/bar-stacked.html b/samples/bar-stacked.html index 1d7257f3de7..573be2c183c 100644 --- a/samples/bar-stacked.html +++ b/samples/bar-stacked.html @@ -2,7 +2,7 @@ - Bar Chart + Stacked Bar Chart @@ -44,6 +44,9 @@ options: { responsive: true, scales: { + xAxes: [{ + stacked: true, + }], yAxes: [{ stacked: true }] diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html index 97833376e73..729cf3731b2 100644 --- a/samples/line-multi-axis.html +++ b/samples/line-multi-axis.html @@ -63,32 +63,6 @@ display: true, position: "left", id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } }, { type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance display: true, @@ -97,29 +71,8 @@ // grid line settings gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, drawOnChartArea: false, // only want the grid lines for one axis to show up - drawTicks: false, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } }], } } diff --git a/samples/line.html b/samples/line.html index 82ca744c55e..a20b6773e27 100644 --- a/samples/line.html +++ b/samples/line.html @@ -43,10 +43,10 @@ responsive: true, scales: { xAxes: [{ - display: false + display: true }], yAxes: [{ - display: false + display: true }] } } diff --git a/samples/scatter-multi-axis.html b/samples/scatter-multi-axis.html index 45e0cbed53b..ab08e0d2648 100644 --- a/samples/scatter-multi-axis.html +++ b/samples/scatter-multi-axis.html @@ -107,32 +107,6 @@ display: true, position: "left", id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } }, { type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance display: true, @@ -141,29 +115,8 @@ // grid line settings gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, drawOnChartArea: false, // only want the grid lines for one axis to show up - drawTicks: false, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } }], } } diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index d83b25b44a3..1cba8b9b56e 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -23,36 +23,6 @@ }], yAxes: [{ type: "linear", - display: true, - position: "left", - id: "y-axis-1", - - spacing: 1, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } }], }, diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 97b3e1ef208..64f2158f9d5 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -12,38 +12,10 @@ scales: { xAxes: [{ - type: "category", // scatter should not use a dataset axis + type: "category", }], yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } + type: "linear", }], }, }; diff --git a/src/charts/chart.scatter.js b/src/charts/chart.scatter.js index a3ae0306249..6711dfbaae3 100644 --- a/src/charts/chart.scatter.js +++ b/src/charts/chart.scatter.js @@ -12,66 +12,12 @@ scales: { xAxes: [{ - type: "linear", // scatter should not use a dataset axis - display: true, + type: "linear", // scatter should not use a category axis position: "bottom", id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, }], yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } + type: "linear", }], }, diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index fd4e6d80034..0ddd956b541 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -5,6 +5,37 @@ Chart = root.Chart, helpers = Chart.helpers; + var defaultConfig = { + display: true, + position: "left", + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + beginAtZero: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }; + var LinearScale = Chart.Element.extend({ calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use isHorizontal: function() { @@ -523,6 +554,6 @@ } } }); - Chart.scaleService.registerScaleType("linear", LinearScale); - + Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig); + }).call(this); From 47b25d1c6db94c509f7bbfc170d1727c9fbc77ad Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 14:16:01 -0400 Subject: [PATCH 151/424] Move linearRadial default config to be a property of the scale. --- src/charts/chart.polarArea.js | 39 +------------------- src/charts/chart.radar.js | 58 ----------------------------- src/charts/chart.scatter.js | 2 + src/core/core.js | 5 ++- src/scales/scale.radialLinear.js | 63 +++++++++++++++++++++++++++++++- 5 files changed, 69 insertions(+), 98 deletions(-) diff --git a/src/charts/chart.polarArea.js b/src/charts/chart.polarArea.js index 4131e6bc01c..b1f6a0f8fa0 100644 --- a/src/charts/chart.polarArea.js +++ b/src/charts/chart.polarArea.js @@ -10,44 +10,7 @@ scale: { type: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - - lineArc: true, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, - - // scale numbers - beginAtZero: true, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - } + lineArc: true, // so that lines are circular }, //Boolean - Whether to animate the rotation of the chart diff --git a/src/charts/chart.radar.js b/src/charts/chart.radar.js index 3d911070f94..bff30df9005 100644 --- a/src/charts/chart.radar.js +++ b/src/charts/chart.radar.js @@ -13,64 +13,6 @@ scale: { type: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - - lineArc: false, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, - - angleLines: { - show: true, - color: "rgba(0,0,0,.1)", - lineWidth: 1 - }, - - // scale numbers - beginAtZero: true, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - }, - - pointLabels: { - //String - Point label font declaration - fontFamily: "'Arial'", - - //String - Point label font weight - fontStyle: "normal", - - //Number - Point label font size in pixels - fontSize: 10, - - //String - Point label font colour - fontColor: "#666", - }, }, elements: { diff --git a/src/charts/chart.scatter.js b/src/charts/chart.scatter.js index 6711dfbaae3..fb2f101fe1e 100644 --- a/src/charts/chart.scatter.js +++ b/src/charts/chart.scatter.js @@ -18,6 +18,8 @@ }], yAxes: [{ type: "linear", + position: "left", + id: "y-axis-1", }], }, diff --git a/src/core/core.js b/src/core/core.js index 1cb6fafc7b9..28eef831dc0 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -145,7 +145,10 @@ // Scale config merging is complex. Add out own function here for that base[key] = helpers.scaleMerge(base.hasOwnProperty(key) ? base[key] : {}, value); - } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { + } else if (key === 'scale') { + // Used in polar area & radar charts since there is only one scale + base[key] = helpers.configMerge(base.hasOwnProperty(key) ? base[key] : {}, Chart.scaleService.getScaleDefaults(value.type), value); + }else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { // In this case we have an array of objects replacing another array. Rather than doing a strict replace, // merge. This allows easy scale option merging var baseArray = base[key]; diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 9d8e30eff45..b15c487a373 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -5,6 +5,67 @@ Chart = root.Chart, helpers = Chart.helpers; + var defaultConfig = { + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate: false, + + lineArc: false, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + }, + + angleLines: { + show: true, + color: "rgba(0,0,0, 0.1)", + lineWidth: 1 + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, + + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + }, + + pointLabels: { + //String - Point label font declaration + fontFamily: "'Arial'", + + //String - Point label font weight + fontStyle: "normal", + + //Number - Point label font size in pixels + fontSize: 10, + + //String - Point label font colour + fontColor: "#666", + }, + }; + var LinearRadialScale = Chart.Element.extend({ initialize: function() { this.size = helpers.min([this.height, this.width]); @@ -374,7 +435,7 @@ } } }); - Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale); + Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale, defaultConfig); }).call(this); From ecd3b58b281cf604ad871f91f167d4374e5cc75e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 14:47:13 -0400 Subject: [PATCH 152/424] Fix typo in linear scale. --- src/scales/scale.linear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 0ddd956b541..60caae47734 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -133,7 +133,7 @@ if (this.options.labels.userCallback) { // If the user provided a callback for label generation, use that as first priority - label = this.options.lables.userCallback(tick, index, ticks); + label = this.options.labels.userCallback(tick, index, ticks); } else if (this.options.labels.template) { // else fall back to the template string label = helpers.template(this.options.labels.template, { From 8c34bdbcd7d65b43f9b8281962a2c527672a9844 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 17:45:59 -0400 Subject: [PATCH 153/424] Clean up of radial linear scale. Radar chart update function improvements --- src/charts/chart.polarArea.js | 2 +- src/charts/chart.radar.js | 13 +++++++++---- src/scales/scale.radialLinear.js | 30 +++++++++++++++++------------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/charts/chart.polarArea.js b/src/charts/chart.polarArea.js index b1f6a0f8fa0..dcbb90c4236 100644 --- a/src/charts/chart.polarArea.js +++ b/src/charts/chart.polarArea.js @@ -141,7 +141,7 @@ x: this.chart.width / 2, y: this.chart.height / 2, innerRadius: 0, - outerRadius: this.scale.calculateCenterOffset(value), + outerRadius: this.scale.getDistanceFromCenterForValue(value), startAngle: startAngle, endAngle: endAngle, diff --git a/src/charts/chart.radar.js b/src/charts/chart.radar.js index bff30df9005..3f723cba30b 100644 --- a/src/charts/chart.radar.js +++ b/src/charts/chart.radar.js @@ -131,6 +131,11 @@ }, this); }, update: function(animationDuration) { + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines @@ -138,11 +143,11 @@ var scaleBase; if (this.scale.min < 0 && this.scale.max < 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.max); + scaleBase = this.scale.getPointPositionForValue(0, this.scale.max); } else if (this.scale.min > 0 && this.scale.max > 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.min); + scaleBase = this.scale.getPointPositionForValue(0, this.scale.min); } else { - scaleBase = this.scale.getPointPosition(0, 0); + scaleBase = this.scale.getPointPositionForValue(0, 0); } helpers.extend(dataset.metaDataset, { @@ -175,7 +180,7 @@ // Update the points this.eachElement(function(point, index, dataset, datasetIndex) { - var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); + var pointPosition = this.scale.getPointPositionForValue(index, this.data.datasets[datasetIndex].data[index]); helpers.extend(point, { // Utility diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index b15c487a373..530c1ebe8f0 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -71,11 +71,6 @@ this.size = helpers.min([this.height, this.width]); this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, - calculateCenterOffset: function(value) { - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); - return (value - this.min) * scalingFactor; - }, update: function() { if (!this.options.lineArc) { this.setScaleSize(); @@ -323,6 +318,11 @@ return index * angleMultiplier - (Math.PI / 2); }, + getDistanceFromCenterForValue: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + return (value - this.min) * scalingFactor; + }, getPointPosition: function(index, distanceFromCenter) { var thisAngle = this.getIndexAngle(index); return { @@ -330,15 +330,17 @@ y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter }; }, + getPointPositionForValue: function(index, value) { + return this.getPointPosition(index, this.getDistanceFromCenterForValue(value)); + }, draw: function() { if (this.options.display) { var ctx = this.ctx; helpers.each(this.yLabels, function(label, index) { // Don't draw a centre value if (index > 0) { - var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), - yHeight = this.yCenter - yCenterOffset, - pointPosition; + var yCenterOffset = this.getDistanceFromCenterForValue(this.ticks[index]); + var yHeight = this.yCenter - yCenterOffset; // Draw circular lines around the scale if (this.options.gridLines.show) { @@ -346,14 +348,16 @@ ctx.lineWidth = this.options.gridLines.lineWidth; if (this.options.lineArc) { + // Draw circular arcs between the points ctx.beginPath(); ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); ctx.closePath(); ctx.stroke(); } else { + // Draw straight lines connecting each index ctx.beginPath(); for (var i = 0; i < this.valuesCount; i++) { - pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); + var pointPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.ticks[index])); if (i === 0) { ctx.moveTo(pointPosition.x, pointPosition.y); } else { @@ -368,14 +372,14 @@ if (this.options.labels.show) { ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - if (this.showLabelBackdrop) { + if (this.options.labels.showLabelBackdrop) { var labelWidth = ctx.measureText(label).width; ctx.fillStyle = this.options.labels.backdropColor; ctx.fillRect( this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, labelWidth + this.options.labels.backdropPaddingX * 2, - this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 + this.options.labels.fontSize + this.options.labels.backdropPaddingY * 2 ); } @@ -393,7 +397,7 @@ for (var i = this.valuesCount - 1; i >= 0; i--) { if (this.options.angleLines.show) { - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); + var outerPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max)); ctx.beginPath(); ctx.moveTo(this.xCenter, this.yCenter); ctx.lineTo(outerPosition.x, outerPosition.y); @@ -401,7 +405,7 @@ ctx.closePath(); } // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); + var pointLabelPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max) + 5); ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); ctx.fillStyle = this.options.pointLabels.fontColor; From 89574b61c5aa134e12a66289203a9c9293ad167f Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 13 Jun 2015 20:40:35 -0400 Subject: [PATCH 154/424] Prototype controller + some of line chart converted --- gulpfile.js | 1 + src/charts/chart.line.js | 103 +---------------- src/controllers/controller.rectangular.js | 133 ++++++++++++++++++++++ 3 files changed, 139 insertions(+), 98 deletions(-) create mode 100644 src/controllers/controller.rectangular.js diff --git a/gulpfile.js b/gulpfile.js index 03b3d538bd1..68bed24db2e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -26,6 +26,7 @@ gulp.task('build', function() { var srcFiles = [ './src/core/core.js', './src/core/**', + './src/controllers/**', './src/scales/**', './src/elements/**', './src/charts/**', diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 64f2158f9d5..063d5871265 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -27,32 +27,17 @@ initialize: function() { var _this = this; + this.controller = new Chart.RectangularController(this); // Events helpers.bindEvents(this, this.options.events, this.events); // Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - - dataset.metaData = []; - + this.controller.addLine(dataset, datasetIndex); + helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, - y: 0, - }, - })); - + this.controller.addPoint(dataset, datasetIndex, index); }, this); // The line chart onlty supports a single x axis because the x axis is always a dataset axis @@ -63,7 +48,6 @@ if (!dataset.yAxisID) { dataset.yAxisID = this.options.scales.yAxes[0].id; } - }, this); // Build and fit the scale. Needs to happen after the axis IDs have been set @@ -92,84 +76,7 @@ return collection[index - 1] || collection[index]; }, resetElements: function() { - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScalePoint, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); + this.controller.resetElements(); }, update: function(animationDuration) { diff --git a/src/controllers/controller.rectangular.js b/src/controllers/controller.rectangular.js new file mode 100644 index 00000000000..eb99a47d91e --- /dev/null +++ b/src/controllers/controller.rectangular.js @@ -0,0 +1,133 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.RectangularController = function(chart) { + this.chart = chart; + }; + + Chart.RectangularController.prototype.eachLine = function(callback) { + helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + callback(dataset.metaDataset, datasetIndex) + }, this); + }; + + Chart.RectangularController.prototype.eachPoint = function(callback) { + helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }; + + Chart.RectangularController.prototype.addLine = function addLine(dataset, datasetIndex) { + if (dataset) { + dataset.metaDataset = new Chart.Line({ + _chart: this.chart.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); + } + } + + Chart.RectangularController.prototype.addPoint = function(dataset, datasetIndex, index) { + if (dataset) { + dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); + + if (index < dataset.metaData.length) { + dataset.metaData[index] = new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart.chart, + _model: { + x: 0, + y: 0, + }, + }) + } + } + }; + + Chart.RectangularController.prototype.resetElements = function() { + // Update the points + this.eachPoint(function(point, index, dataset, datasetIndex) { + var xScale = this.chart.scales[this.chart.data.datasets[datasetIndex].xAxisID]; + var yScale = this.chart.scales[this.chart.data.datasets[datasetIndex].yAxisID]; + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart.chart, //WTF + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + y: yScalePoint, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: this.chart.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachPoint(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.chart.previousPoint(dataset, index)._model, + point._model, + this.chart.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chart.chartArea.bottom) { + point._model.controlPointNextY = this.chart.chartArea.bottom; + } else if (controlPoints.next.y < this.chart.chartArea.top) { + point._model.controlPointNextY = this.chart.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chart.chartArea.bottom) { + point._model.controlPointPreviousY = this.chart.chartArea.bottom; + } else if (controlPoints.previous.y < this.chart.chartArea.top) { + point._model.controlPointPreviousY = this.chart.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + }; + +}).call(this); From 9751e8f5b1c9210af4c3fd6c83e9d6139752eb08 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Jun 2015 10:35:59 -0400 Subject: [PATCH 155/424] Created a generic base class to be used by rectangular charts. Modified `Chart.Type.extend` to put the parent's prototype in __super__. Moved more code into the controller and renamed the controller to RectangularElementController. --- gulpfile.js | 1 + src/charts/chart.line.js | 326 +----------------- src/charts/chart.rectangularbase.js | 226 ++++++++++++ .../controller.elements.rectangular.js | 233 +++++++++++++ src/controllers/controller.rectangular.js | 133 ------- src/core/core.js | 3 + 6 files changed, 466 insertions(+), 456 deletions(-) create mode 100644 src/charts/chart.rectangularbase.js create mode 100644 src/controllers/controller.elements.rectangular.js delete mode 100644 src/controllers/controller.rectangular.js diff --git a/gulpfile.js b/gulpfile.js index 68bed24db2e..27b85ef1818 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,6 +29,7 @@ gulp.task('build', function() { './src/controllers/**', './src/scales/**', './src/elements/**', + './src/charts/chart.rectangularbase.js', // need this before the other chart types './src/charts/**', './src/**', './node_modules/color/dist/color.min.js' diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 063d5871265..3f5407a9a83 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -21,16 +21,12 @@ }; - Chart.Type.extend({ + Chart.types.RectangularBase.extend({ name: "Line", defaults: defaultConfig, initialize: function() { - var _this = this; - this.controller = new Chart.RectangularController(this); - - // Events - helpers.bindEvents(this, this.options.events, this.events); + this.controller = new Chart.RectangularElementController(this); // Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { @@ -50,177 +46,7 @@ } }, this); - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[index]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[index]; - }, - resetElements: function() { - this.controller.resetElements(); - }, - update: function(animationDuration) { - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var yScale = this.scales[dataset.yAxisID]; - var scaleBase; - - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.options.elements.line.tension), - backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.options.elements.line.backgroundColor), - borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.options.elements.line.borderWidth), - borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.options.elements.line.borderColor), - fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill), - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(animationDuration); - }, - buildScale: function() { - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axes - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - data: this.data, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - - // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); + this.__super__.initialize.call(this); }, draw: function(ease) { @@ -254,151 +80,5 @@ // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, }); - - }).call(this); diff --git a/src/charts/chart.rectangularbase.js b/src/charts/chart.rectangularbase.js new file mode 100644 index 00000000000..eda983e7d67 --- /dev/null +++ b/src/charts/chart.rectangularbase.js @@ -0,0 +1,226 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + + }; + + // Rectangular base class that derives into line & bar charts + Chart.Type.extend({ + name: "RectangularBase", + defaults: defaultConfig, + initialize: function() { + // Events + helpers.bindEvents(this, this.options.events, this.events); + + // Build and fit the scale. Needs to happen after the axis IDs have been set + this.buildScales(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz + this.update(); + }, + resetElements: function() { + this.controller.resetElements(); + }, + update: function(animationDuration) { + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + this.controller.updateElements(); + this.render(animationDuration); + }, + buildScales: function() { + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axes + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + draw: helpers.noop, + events: function(e) { + + this.lastActive = this.lastActive || []; + + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + }); + + +}).call(this); diff --git a/src/controllers/controller.elements.rectangular.js b/src/controllers/controller.elements.rectangular.js new file mode 100644 index 00000000000..96b5bc18141 --- /dev/null +++ b/src/controllers/controller.elements.rectangular.js @@ -0,0 +1,233 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.RectangularElementController = function(chart) { + this.chart = chart; + }; + + Chart.RectangularElementController.prototype.getScaleForId = function getScaleForId(scaleID) { + return this.chart.scales[scaleID]; + }; + + // 2 helper functions to get points in collections + Chart.RectangularElementController.prototype.nextPoint = function nextPoint(collection, index) { + return collection[index + 1] || collection[index]; + }; + Chart.RectangularElementController.prototype.previousPoint = function previousPoint(collection, index) { + return collection[index - 1] || collection[index]; + }; + + Chart.RectangularElementController.prototype.eachLine = function eachLine(callback) { + helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + callback.call(this, dataset, datasetIndex) + }, this); + }; + + Chart.RectangularElementController.prototype.eachPoint = function eachPoint(callback) { + helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }; + + Chart.RectangularElementController.prototype.addLine = function addLine(dataset, datasetIndex) { + if (dataset) { + dataset.metaDataset = new Chart.Line({ + _chart: this.chart.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + }); + } + } + + Chart.RectangularElementController.prototype.addPoint = function addPoint(dataset, datasetIndex, index) { + if (dataset) { + dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); + + if (index < dataset.metaData.length) { + dataset.metaData[index] = new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart.chart, + _model: { + x: 0, + y: 0, + }, + }) + } + } + }; + + Chart.RectangularElementController.prototype.resetElements = function resetElements() { + // Update the points + this.resetPoints(); + }; + + Chart.RectangularElementController.prototype.resetPoints = function() { + this.eachPoint(function(point, index, dataset, datasetIndex) { + var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart.chart, //WTF + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + y: yScalePoint, + }, + }); + + this.updatePointElementAppearance(point, datasetIndex, index); + }, this); + + this.updateBezierControlPoints(); + }; + + Chart.RectangularElementController.prototype.updateElements = function updateElements() { + // Update the lines + this.updateLines(); + + // Update the points + this.updatePoints(); + }; + + Chart.RectangularElementController.prototype.updateLines = function updateLines() { + this.eachLine(function(dataset, datasetIndex) { + var yScale = this.getScaleForId(dataset.yAxisID); + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + helpers.extend(dataset.metaDataset, { + // Utility + _scale: yScale, + _datasetIndex: datasetIndex, + // Data + _children: dataset.metaData, + // Model + _model: { + // Appearance + tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chart.options.elements.line.tension), + backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chart.options.elements.line.backgroundColor), + borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chart.options.elements.line.borderWidth), + borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chart.options.elements.line.borderColor), + fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chart.options.elements.line.fill), + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chart.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chart.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: scaleBase, + }, + }); + + dataset.metaDataset.pivot(); + }); + }; + + Chart.RectangularElementController.prototype.updatePoints = function() { + this.eachPoint(function(point, index, dataset, datasetIndex) { + var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + helpers.extend(point, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + y: yScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + }, + }); + + this.updatePointElementAppearance(point, datasetIndex, index); + }, this); + + this.updateBezierControlPoints(); + }; + + Chart.RectangularElementController.prototype.updatePointElementAppearance = function(point, datasetIndex, index) { + helpers.extend(point._model, { + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: this.chart.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), + }); + }; + + Chart.RectangularElementController.prototype.updateBezierControlPoints = function updateBezierControlPoints() { + // Update control points for the bezier curve + this.eachPoint(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chart.chartArea.bottom) { + point._model.controlPointNextY = this.chart.chartArea.bottom; + } else if (controlPoints.next.y < this.chart.chartArea.top) { + point._model.controlPointNextY = this.chart.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chart.chartArea.bottom) { + point._model.controlPointPreviousY = this.chart.chartArea.bottom; + } else if (controlPoints.previous.y < this.chart.chartArea.top) { + point._model.controlPointPreviousY = this.chart.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + }; + +}).call(this); diff --git a/src/controllers/controller.rectangular.js b/src/controllers/controller.rectangular.js deleted file mode 100644 index eb99a47d91e..00000000000 --- a/src/controllers/controller.rectangular.js +++ /dev/null @@ -1,133 +0,0 @@ -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.RectangularController = function(chart) { - this.chart = chart; - }; - - Chart.RectangularController.prototype.eachLine = function(callback) { - helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - callback(dataset.metaDataset, datasetIndex) - }, this); - }; - - Chart.RectangularController.prototype.eachPoint = function(callback) { - helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - }, this); - }; - - Chart.RectangularController.prototype.addLine = function addLine(dataset, datasetIndex) { - if (dataset) { - dataset.metaDataset = new Chart.Line({ - _chart: this.chart.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - } - } - - Chart.RectangularController.prototype.addPoint = function(dataset, datasetIndex, index) { - if (dataset) { - dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); - - if (index < dataset.metaData.length) { - dataset.metaData[index] = new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart.chart, - _model: { - x: 0, - y: 0, - }, - }) - } - } - }; - - Chart.RectangularController.prototype.resetElements = function() { - // Update the points - this.eachPoint(function(point, index, dataset, datasetIndex) { - var xScale = this.chart.scales[this.chart.data.datasets[datasetIndex].xAxisID]; - var yScale = this.chart.scales[this.chart.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chart.chart, //WTF - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScalePoint, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: this.chart.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachPoint(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.chart.previousPoint(dataset, index)._model, - point._model, - this.chart.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chart.chartArea.bottom) { - point._model.controlPointNextY = this.chart.chartArea.bottom; - } else if (controlPoints.next.y < this.chart.chartArea.top) { - point._model.controlPointNextY = this.chart.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chart.chartArea.bottom) { - point._model.controlPointPreviousY = this.chart.chartArea.bottom; - } else if (controlPoints.previous.y < this.chart.chartArea.top) { - point._model.controlPointPreviousY = this.chart.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - }; - -}).call(this); diff --git a/src/core/core.js b/src/core/core.js index 28eef831dc0..9ed29d43e04 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -1102,9 +1102,12 @@ //Copy the prototype object of the this class ChartType.prototype = clone(parent.prototype); + ChartType.prototype.__super__ = clone(parent.prototype); + //Now overwrite some of the properties in the base class with the new extensions extend(ChartType.prototype, extensions); + ChartType.extend = Chart.Type.extend; if (extensions.name || parent.prototype.name) { From 68ae02263b0fa5886335072eec15d1496ae3d615 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Jun 2015 13:00:09 -0400 Subject: [PATCH 156/424] Fix the broken scatter chart. Introduced the concept of a canvas controller that goes along with the element controller. --- src/charts/chart.line.js | 9 ++- src/charts/chart.rectangularbase.js | 60 +-------------- .../controller.canvas.rectangular.js | 73 +++++++++++++++++++ src/core/core.js | 9 +-- 4 files changed, 83 insertions(+), 68 deletions(-) create mode 100644 src/controllers/controller.canvas.rectangular.js diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index 3f5407a9a83..f1d71eb506b 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -26,14 +26,15 @@ defaults: defaultConfig, initialize: function() { - this.controller = new Chart.RectangularElementController(this); + this.elementController = new Chart.RectangularElementController(this); + this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); // Create a new line and its points for each dataset and piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { - this.controller.addLine(dataset, datasetIndex); + this.elementController.addLine(dataset, datasetIndex); helpers.each(dataset.data, function(dataPoint, index) { - this.controller.addPoint(dataset, datasetIndex, index); + this.elementController.addPoint(dataset, datasetIndex, index); }, this); // The line chart onlty supports a single x axis because the x axis is always a dataset axis @@ -46,7 +47,7 @@ } }, this); - this.__super__.initialize.call(this); + this.canvasController.initialize(); }, draw: function(ease) { diff --git a/src/charts/chart.rectangularbase.js b/src/charts/chart.rectangularbase.js index eda983e7d67..76d03f5e348 100644 --- a/src/charts/chart.rectangularbase.js +++ b/src/charts/chart.rectangularbase.js @@ -13,68 +13,10 @@ Chart.Type.extend({ name: "RectangularBase", defaults: defaultConfig, - initialize: function() { - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScales(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - resetElements: function() { - this.controller.resetElements(); - }, update: function(animationDuration) { - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - this.controller.updateElements(); + this.canvasController.update(); this.render(animationDuration); }, - buildScales: function() { - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axes - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - data: this.data, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - - // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, draw: helpers.noop, events: function(e) { diff --git a/src/controllers/controller.canvas.rectangular.js b/src/controllers/controller.canvas.rectangular.js new file mode 100644 index 00000000000..b57cfabe739 --- /dev/null +++ b/src/controllers/controller.canvas.rectangular.js @@ -0,0 +1,73 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.RectangularCanvasController = function(chart, elementController) { + this.chart = chart; + this.elementController = elementController; + }; + + Chart.RectangularCanvasController.prototype.initialize = function() { + this.bindEvents(); + this.buildScales(); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this.chart, this.chart.chart.width, this.chart.chart.height); + this.elementController.resetElements(); + + this.initToolTip(); + + this.chart.update(); + }; + + Chart.RectangularCanvasController.prototype.bindEvents = function() { + helpers.bindEvents(this.chart, this.chart.options.events, this.chart.events); + }; + + Chart.RectangularCanvasController.prototype.initToolTip = function() { + this.chart.tooltip = new Chart.Tooltip({ + _chart: this.chart.chart, + _data: this.chart.data, + _options: this.chart.options, + }, this); + }; + + Chart.RectangularCanvasController.prototype.buildScales = function() { + // Map of scale ID to scale object so we can lookup later + this.chart.scales = {}; + + // Build the x axes + helpers.each(this.chart.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.chart.ctx, + options: xAxisOptions, + data: this.chart.data, + id: xAxisOptions.id, + }); + + this.chart.scales[scale.id] = scale; + }, this); + + // Build the y axes + helpers.each(this.chart.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.chart.ctx, + options: yAxisOptions, + data: this.chart.data, + id: yAxisOptions.id, + }); + + this.chart.scales[scale.id] = scale; + }, this); + }; + + Chart.RectangularCanvasController.prototype.update = function() { + Chart.scaleService.fitScalesForChart(this.chart, this.chart.chart.width, this.chart.chart.height); + this.elementController.updateElements(); + }; +}).call(this); diff --git a/src/core/core.js b/src/core/core.js index 9ed29d43e04..6328edd8296 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -285,7 +285,9 @@ ChartElement.extend = inherits; - if (extensions) extend(ChartElement.prototype, extensions); + if (extensions) { + extend(ChartElement.prototype, extensions); + } ChartElement.__super__ = parent.prototype; @@ -1102,12 +1104,9 @@ //Copy the prototype object of the this class ChartType.prototype = clone(parent.prototype); - ChartType.prototype.__super__ = clone(parent.prototype); - + //Now overwrite some of the properties in the base class with the new extensions extend(ChartType.prototype, extensions); - - ChartType.extend = Chart.Type.extend; if (extensions.name || parent.prototype.name) { From 886c99623f5781b6965fddc62d447a9ea916f0db Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Jun 2015 13:37:37 -0400 Subject: [PATCH 157/424] Drop the base class in favour of an expanded canvas controller. Renamed 'chart' to 'chartInstance' in the controllers --- gulpfile.js | 1 - src/charts/chart.line.js | 2 +- src/charts/chart.rectangularbase.js | 168 ------------------ .../controller.canvas.rectangular.js | 158 ++++++++++++++-- .../controller.elements.rectangular.js | 123 +++++++++---- src/core/core.js | 5 +- 6 files changed, 230 insertions(+), 227 deletions(-) delete mode 100644 src/charts/chart.rectangularbase.js diff --git a/gulpfile.js b/gulpfile.js index 27b85ef1818..68bed24db2e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,7 +29,6 @@ gulp.task('build', function() { './src/controllers/**', './src/scales/**', './src/elements/**', - './src/charts/chart.rectangularbase.js', // need this before the other chart types './src/charts/**', './src/**', './node_modules/color/dist/color.min.js' diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js index f1d71eb506b..469cf0c8739 100644 --- a/src/charts/chart.line.js +++ b/src/charts/chart.line.js @@ -21,7 +21,7 @@ }; - Chart.types.RectangularBase.extend({ + Chart.Type.extend({ name: "Line", defaults: defaultConfig, initialize: function() { diff --git a/src/charts/chart.rectangularbase.js b/src/charts/chart.rectangularbase.js deleted file mode 100644 index 76d03f5e348..00000000000 --- a/src/charts/chart.rectangularbase.js +++ /dev/null @@ -1,168 +0,0 @@ -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - - }; - - // Rectangular base class that derives into line & bar charts - Chart.Type.extend({ - name: "RectangularBase", - defaults: defaultConfig, - update: function(animationDuration) { - this.canvasController.update(); - this.render(animationDuration); - }, - draw: helpers.noop, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); - - -}).call(this); diff --git a/src/controllers/controller.canvas.rectangular.js b/src/controllers/controller.canvas.rectangular.js index b57cfabe739..22caa778ccf 100644 --- a/src/controllers/controller.canvas.rectangular.js +++ b/src/controllers/controller.canvas.rectangular.js @@ -6,7 +6,7 @@ helpers = Chart.helpers; Chart.RectangularCanvasController = function(chart, elementController) { - this.chart = chart; + this.chartInstance = chart; this.elementController = elementController; }; @@ -15,59 +15,181 @@ this.buildScales(); // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this.chart, this.chart.chart.width, this.chart.chart.height); + Chart.scaleService.fitScalesForChart(this.chartInstance, this.chartInstance.chart.width, this.chartInstance.chart.height); this.elementController.resetElements(); this.initToolTip(); - this.chart.update(); + this.chartInstance.update(); }; Chart.RectangularCanvasController.prototype.bindEvents = function() { - helpers.bindEvents(this.chart, this.chart.options.events, this.chart.events); + helpers.bindEvents(this.chartInstance, this.chartInstance.options.events, function(evt) { + // this will be the chart instance + this.canvasController.eventHandler(evt); + }); + }; + + Chart.RectangularCanvasController.prototype.eventHandler = function(e) { + this.lastActive = this.lastActive || []; + + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.chartInstance.options.hover.mode) { + case 'single': + return this.elementController.getElementAtEvent(e); + case 'label': + return this.elementController.getElementsAtEvent(e); + case 'dataset': + return this.elementController.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.chartInstance.options.hover.onHover) { + this.chartInstance.options.hover.onHover.call(this.chartInstance, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.chartInstance.options.onClick) { + this.chartInstance.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.chartInstance.options.hover.mode) { + case 'single': + this.elementController.updatePointElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.elementController.updatePointElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.chartInstance.options.hover.mode) { + switch (this.chartInstance.options.hover.mode) { + case 'single': + this.elementController.setPointHoverStyle(this.active[0]); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.elementController.setPointHoverStyle(this.active[i]); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.chartInstance.options.tooltips.enabled) { + + // The usual updates + this.chartInstance.tooltip.initialize(); + + // Active + if (this.active.length) { + this.chartInstance.tooltip._model.opacity = 1; + + helpers.extend(this.chartInstance.tooltip, { + _active: this.active, + }); + + this.chartInstance.tooltip.update(); + } else { + // Inactive + this.chartInstance.tooltip._model.opacity = 0; + } + } + + // Hover animations + this.chartInstance.tooltip.pivot(); + + if (!this.chartInstance.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.chartInstance.stop(); + this.chartInstance.render(this.chartInstance.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; }; Chart.RectangularCanvasController.prototype.initToolTip = function() { - this.chart.tooltip = new Chart.Tooltip({ - _chart: this.chart.chart, - _data: this.chart.data, - _options: this.chart.options, + this.chartInstance.tooltip = new Chart.Tooltip({ + _chart: this.chartInstance.chart, + _data: this.chartInstance.data, + _options: this.chartInstance.options, }, this); }; Chart.RectangularCanvasController.prototype.buildScales = function() { // Map of scale ID to scale object so we can lookup later - this.chart.scales = {}; + this.chartInstance.scales = {}; // Build the x axes - helpers.each(this.chart.options.scales.xAxes, function(xAxisOptions) { + helpers.each(this.chartInstance.options.scales.xAxes, function(xAxisOptions) { var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); var scale = new ScaleClass({ - ctx: this.chart.chart.ctx, + ctx: this.chartInstance.chart.ctx, options: xAxisOptions, - data: this.chart.data, + data: this.chartInstance.data, id: xAxisOptions.id, }); - this.chart.scales[scale.id] = scale; + this.chartInstance.scales[scale.id] = scale; }, this); // Build the y axes - helpers.each(this.chart.options.scales.yAxes, function(yAxisOptions) { + helpers.each(this.chartInstance.options.scales.yAxes, function(yAxisOptions) { var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); var scale = new ScaleClass({ - ctx: this.chart.chart.ctx, + ctx: this.chartInstance.chart.ctx, options: yAxisOptions, - data: this.chart.data, + data: this.chartInstance.data, id: yAxisOptions.id, }); - this.chart.scales[scale.id] = scale; + this.chartInstance.scales[scale.id] = scale; }, this); }; Chart.RectangularCanvasController.prototype.update = function() { - Chart.scaleService.fitScalesForChart(this.chart, this.chart.chart.width, this.chart.chart.height); + Chart.scaleService.fitScalesForChart(this.chartInstance, this.chartInstance.chart.width, this.chartInstance.chart.height); this.elementController.updateElements(); }; }).call(this); diff --git a/src/controllers/controller.elements.rectangular.js b/src/controllers/controller.elements.rectangular.js index 96b5bc18141..a23949b9d9f 100644 --- a/src/controllers/controller.elements.rectangular.js +++ b/src/controllers/controller.elements.rectangular.js @@ -6,11 +6,11 @@ helpers = Chart.helpers; Chart.RectangularElementController = function(chart) { - this.chart = chart; + this.chartInstance = chart; }; Chart.RectangularElementController.prototype.getScaleForId = function getScaleForId(scaleID) { - return this.chart.scales[scaleID]; + return this.chartInstance.scales[scaleID]; }; // 2 helper functions to get points in collections @@ -22,13 +22,13 @@ }; Chart.RectangularElementController.prototype.eachLine = function eachLine(callback) { - helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { callback.call(this, dataset, datasetIndex) }, this); }; Chart.RectangularElementController.prototype.eachPoint = function eachPoint(callback) { - helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); }, this); }; @@ -36,7 +36,7 @@ Chart.RectangularElementController.prototype.addLine = function addLine(dataset, datasetIndex) { if (dataset) { dataset.metaDataset = new Chart.Line({ - _chart: this.chart.chart, + _chart: this.chartInstance.chart, _datasetIndex: datasetIndex, _points: dataset.metaData, }); @@ -45,13 +45,13 @@ Chart.RectangularElementController.prototype.addPoint = function addPoint(dataset, datasetIndex, index) { if (dataset) { - dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); + dataset.metaData = dataset.metaData || new Array(this.chartInstance.data.datasets[datasetIndex].data.length); if (index < dataset.metaData.length) { dataset.metaData[index] = new Chart.Point({ _datasetIndex: datasetIndex, _index: index, - _chart: this.chart.chart, + _chart: this.chartInstance.chart, _model: { x: 0, y: 0, @@ -68,8 +68,8 @@ Chart.RectangularElementController.prototype.resetPoints = function() { this.eachPoint(function(point, index, dataset, datasetIndex) { - var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); + var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); var yScalePoint; @@ -84,7 +84,7 @@ helpers.extend(point, { // Utility - _chart: this.chart.chart, //WTF + _chart: this.chartInstance.chart, //WTF _xScale: xScale, _yScale: yScale, _datasetIndex: datasetIndex, @@ -92,7 +92,7 @@ // Desired view properties _model: { - x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + x: xScale.getPointPixelForValue(this.chartInstance.data.datasets[datasetIndex].data[index], index, datasetIndex), y: yScalePoint, }, }); @@ -133,13 +133,13 @@ // Model _model: { // Appearance - tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chart.options.elements.line.tension), - backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chart.options.elements.line.backgroundColor), - borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chart.options.elements.line.borderWidth), - borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chart.options.elements.line.borderColor), - fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chart.options.elements.line.fill), - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chart.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chart.options.elements.line.drawNull, + tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chartInstance.options.elements.line.tension), + backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chartInstance.options.elements.line.backgroundColor), + borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chartInstance.options.elements.line.borderWidth), + borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chartInstance.options.elements.line.borderColor), + fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chartInstance.options.elements.line.fill), + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chartInstance.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chartInstance.options.elements.line.drawNull, // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom, @@ -153,12 +153,12 @@ Chart.RectangularElementController.prototype.updatePoints = function() { this.eachPoint(function(point, index, dataset, datasetIndex) { - var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); + var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); helpers.extend(point, { // Utility - _chart: this.chart.chart, + _chart: this.chartInstance.chart, _xScale: xScale, _yScale: yScale, _datasetIndex: datasetIndex, @@ -166,8 +166,8 @@ // Desired view properties _model: { - x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + x: xScale.getPointPixelForValue(this.chartInstance.data.datasets[datasetIndex].data[index], index, datasetIndex), + y: yScale.getPointPixelForValue(this.chartInstance.data.datasets[datasetIndex].data[index], index, datasetIndex), }, }); @@ -180,18 +180,28 @@ Chart.RectangularElementController.prototype.updatePointElementAppearance = function(point, datasetIndex, index) { helpers.extend(point._model, { // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: this.chart.data.datasets[datasetIndex].data[index] === null, + tension: point.custom && point.custom.tension ? point.custom.tension : this.chartInstance.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].radius, index, this.chartInstance.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].pointBackgroundColor, index, this.chartInstance.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].pointBorderColor, index, this.chartInstance.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].pointBorderWidth, index, this.chartInstance.options.elements.point.borderWidth), + skip: this.chartInstance.data.datasets[datasetIndex].data[index] === null, // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].hitRadius, index, this.chartInstance.options.elements.point.hitRadius), }); }; + Chart.RectangularElementController.prototype.setPointHoverStyle = function(point) { + var dataset = this.chartInstance.data.datasets[point._datasetIndex]; + var index = point._index; + + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chartInstance.options.elements.point.hoverRadius); + point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + }; + Chart.RectangularElementController.prototype.updateBezierControlPoints = function updateBezierControlPoints() { // Update control points for the bezier curve this.eachPoint(function(point, index, dataset, datasetIndex) { @@ -208,19 +218,19 @@ // Prevent the bezier going outside of the bounds of the graph // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chart.chartArea.bottom) { - point._model.controlPointNextY = this.chart.chartArea.bottom; - } else if (controlPoints.next.y < this.chart.chartArea.top) { - point._model.controlPointNextY = this.chart.chartArea.top; + if (controlPoints.next.y > this.chartInstance.chartArea.bottom) { + point._model.controlPointNextY = this.chartInstance.chartArea.bottom; + } else if (controlPoints.next.y < this.chartInstance.chartArea.top) { + point._model.controlPointNextY = this.chartInstance.chartArea.top; } else { point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chart.chartArea.bottom) { - point._model.controlPointPreviousY = this.chart.chartArea.bottom; - } else if (controlPoints.previous.y < this.chart.chartArea.top) { - point._model.controlPointPreviousY = this.chart.chartArea.top; + if (controlPoints.previous.y > this.chartInstance.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartInstance.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartInstance.chartArea.top) { + point._model.controlPointPreviousY = this.chartInstance.chartArea.top; } else { point._model.controlPointPreviousY = controlPoints.previous.y; } @@ -230,4 +240,41 @@ }, this); }; + Chart.RectangularElementController.prototype.getElementsAtEvent = function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.chartInstance.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.chartInstance.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.chartInstance.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.chartInstance.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }; + + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + Chart.RectangularElementController.prototype.getElementAtEvent = function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.chartInstance.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.chartInstance.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.chartInstance.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.chartInstance.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }; + }).call(this); diff --git a/src/core/core.js b/src/core/core.js index 6328edd8296..e3f8ddcdadc 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -990,7 +990,10 @@ return this; }, - redraw: noop, + update: function(animationDuration) { + this.canvasController.update(); + this.render(animationDuration); + }, render: function(duration) { if (this.options.animation.duration !== 0 || duration) { From 0fa2ac4ea0240fa8d26543ea3f267bcab85586d1 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Jun 2015 15:26:34 -0400 Subject: [PATCH 158/424] Bar chart now uses the rectangular canvas & element controllers. --- src/charts/chart.bar.js | 291 +----------------- .../controller.canvas.rectangular.js | 8 +- .../controller.elements.rectangular.js | 185 +++++++++-- 3 files changed, 175 insertions(+), 309 deletions(-) diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js index 1cba8b9b56e..4d9990b113f 100644 --- a/src/charts/chart.bar.js +++ b/src/charts/chart.bar.js @@ -33,24 +33,16 @@ name: "Bar", defaults: defaultConfig, initialize: function() { - - var _this = this; - - // Events - helpers.bindEvents(this, this.options.events, this.events); + this.elementController = new Chart.RectangularElementController(this); + this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); //Create a new bar for each piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Rectangle({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - })); + this.elementController.addRectangle(dataset, datasetIndex, index); }, this); - // The bar chart only supports a single x axis because the x axis is always a dataset axis + // The bar chart only supports a single x axis because the x axis is always a category axis dataset.xAxisID = this.options.scales.xAxes[0].id; if (!dataset.yAxisID) { @@ -58,138 +50,7 @@ } }, this); - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // So that we animate from the baseline - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - }, - resetElements: function() { - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScalePoint, - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), - - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); - }, this); - }, - update: function(animationDuration) { - // Update the scale sizes - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScale.calculateBarY(datasetIndex, index), - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), - - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); - }, this); - - - this.render(animationDuration); - }, - buildScale: function(labels) { - var self = this; - - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scales.xAxes[0].type); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - id: this.options.scales.xAxes[0].id, - data: this.data, - }); - this.scales[xScale.id] = xScale; - - // Build up all the y scales - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); + this.canvasController.initialize(); }, draw: function(ease) { @@ -209,148 +70,6 @@ // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); }, - events: function(e) { - - - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - this.tooltip.pivot(); - - // Hover animations - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, }); diff --git a/src/controllers/controller.canvas.rectangular.js b/src/controllers/controller.canvas.rectangular.js index 22caa778ccf..a4a75cef07b 100644 --- a/src/controllers/controller.canvas.rectangular.js +++ b/src/controllers/controller.canvas.rectangular.js @@ -68,11 +68,11 @@ if (this.lastActive.length) { switch (this.chartInstance.options.hover.mode) { case 'single': - this.elementController.updatePointElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); + this.elementController.resetElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { - this.elementController.updatePointElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + this.elementController.resetElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); } break; case 'dataset': @@ -86,11 +86,11 @@ if (this.active.length && this.chartInstance.options.hover.mode) { switch (this.chartInstance.options.hover.mode) { case 'single': - this.elementController.setPointHoverStyle(this.active[0]); + this.elementController.setElementHoverStyle(this.active[0]); break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.elementController.setPointHoverStyle(this.active[i]); + this.elementController.setElementHoverStyle(this.active[i]); } break; case 'dataset': diff --git a/src/controllers/controller.elements.rectangular.js b/src/controllers/controller.elements.rectangular.js index a23949b9d9f..469aa018874 100644 --- a/src/controllers/controller.elements.rectangular.js +++ b/src/controllers/controller.elements.rectangular.js @@ -23,13 +23,19 @@ Chart.RectangularElementController.prototype.eachLine = function eachLine(callback) { helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { - callback.call(this, dataset, datasetIndex) + if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { + callback.call(this, dataset, datasetIndex) + } }, this); }; - Chart.RectangularElementController.prototype.eachPoint = function eachPoint(callback) { + Chart.RectangularElementController.prototype.eachRectangle = function(callback) { helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + helpers.each(dataset.metaData, function(element, index) { + if (element instanceof Chart.Rectangle) { + callback(element, index, dataset, datasetIndex); + } + }, this); }, this); }; @@ -61,13 +67,35 @@ } }; + Chart.RectangularElementController.prototype.addRectangle = function(dataset, datasetIndex, index) { + if (dataset) { + dataset.metaData = dataset.metaData || new Array(this.chartInstance.data.datasets[datasetIndex].data.length); + + if (index < dataset.metaData.length) { + dataset.metaData[index] = new Chart.Rectangle({ + _chart: this.chartInstance.chart, + _datasetIndex: datasetIndex, + _index: index, + }); + } + } + }; + Chart.RectangularElementController.prototype.resetElements = function resetElements() { - // Update the points - this.resetPoints(); + helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { + // All elements must be the same type for the given dataset so we are fine to check just the first one + if (dataset.metaData[0] instanceof Chart.Point) { + // Have points. Update all of them + this.resetDatasetPoints(dataset, datasetIndex); + } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // Have rectangles (bars) + this.resetDatasetRectangles(dataset, datasetIndex); + } + }, this); }; - Chart.RectangularElementController.prototype.resetPoints = function() { - this.eachPoint(function(point, index, dataset, datasetIndex) { + Chart.RectangularElementController.prototype.resetDatasetPoints = function resetDatasetPoints(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(point, index){ var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); @@ -100,15 +128,75 @@ this.updatePointElementAppearance(point, datasetIndex, index); }, this); - this.updateBezierControlPoints(); + this.updateBezierControlPoints(dataset); + }; + + Chart.RectangularElementController.prototype.resetDatasetRectangles = function resetDatasetRectangles(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(rectangle, index) { + var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); + var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(rectangle, { + // Utility + _chart: this.chartInstance.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.chartInstance.data.datasets.length, datasetIndex, index), + y: yScalePoint, + + // Tooltip + label: this.chartInstance.data.labels[index], + datasetLabel: this.chartInstance.data.datasets[datasetIndex].label, + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.chartInstance.data.datasets.length), + }, + }); + + this.updateRectangleElementAppearance(rectangle, datasetIndex, index); + rectangle.pivot(); + }, this); + }; + + Chart.RectangularElementController.prototype.resetElementAppearance = function(element, datasetIndex, index) { + if (element instanceof Chart.Point) { + this.updatePointElementAppearance(element, datasetIndex, index); + } else if (element instanceof Chart.Rectangle) { + this.updateRectangleElementAppearance(element, datasetIndex, index); + } }; Chart.RectangularElementController.prototype.updateElements = function updateElements() { // Update the lines this.updateLines(); - // Update the points - this.updatePoints(); + helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { + // All elements must be the same type for the given dataset so we are fine to check just the first one + if (dataset.metaData[0] instanceof Chart.Point) { + // Have points. Update all of them + this.updatePoints(dataset, datasetIndex); + } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // Have rectangles (bars) + this.updateRectangles(dataset, datasetIndex); + } + }, this); }; Chart.RectangularElementController.prototype.updateLines = function updateLines() { @@ -151,8 +239,8 @@ }); }; - Chart.RectangularElementController.prototype.updatePoints = function() { - this.eachPoint(function(point, index, dataset, datasetIndex) { + Chart.RectangularElementController.prototype.updatePoints = function updatePoints(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(point, index) { var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); @@ -174,10 +262,10 @@ this.updatePointElementAppearance(point, datasetIndex, index); }, this); - this.updateBezierControlPoints(); + this.updateBezierControlPoints(dataset); }; - Chart.RectangularElementController.prototype.updatePointElementAppearance = function(point, datasetIndex, index) { + Chart.RectangularElementController.prototype.updatePointElementAppearance = function updatePointElementAppearance(point, datasetIndex, index) { helpers.extend(point._model, { // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.chartInstance.options.elements.line.tension, @@ -192,7 +280,57 @@ }); }; - Chart.RectangularElementController.prototype.setPointHoverStyle = function(point) { + Chart.RectangularElementController.prototype.updateRectangles = function updateRectangles(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(rectangle, index){ + var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); + var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); + + helpers.extend(rectangle, { + // Utility + _chart: this.chartInstance.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.chartInstance.data.datasets.length, datasetIndex, index), + y: yScale.calculateBarY(datasetIndex, index), + + // Appearance + base: yScale.calculateBarBase(datasetIndex, index), + width: xScale.calculateBarWidth(this.chartInstance.data.datasets.length), + + // Tooltip + label: this.chartInstance.data.labels[index], + datasetLabel: this.chartInstance.data.datasets[datasetIndex].label, + }, + }); + + this.updateRectangleElementAppearance(rectangle, datasetIndex, index); + rectangle.pivot(); + }, this); + }; + + Chart.RectangularElementController.prototype.updateRectangleElementAppearance = function updateRectangleElementAppearance(rectangle, datasetIndex, index) { + helpers.extend(rectangle._model, { + // Appearance + backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].backgroundColor, index, this.chartInstance.options.elements.rectangle.backgroundColor), + borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].borderColor, index, this.chartInstance.options.elements.rectangle.borderColor), + borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].borderWidth, index, this.chartInstance.options.elements.rectangle.borderWidth), + }); + }; + + Chart.RectangularElementController.prototype.setElementHoverStyle = function setElementHoverStyle(element) { + if (element instanceof Chart.Point) { + this.setPointHoverStyle(element); + } else if (element instanceof Chart.Rectangle) { + this.setRectangleHoverStyle(element); + } + }; + + Chart.RectangularElementController.prototype.setPointHoverStyle = function setPointHoverStyle(point) { var dataset = this.chartInstance.data.datasets[point._datasetIndex]; var index = point._index; @@ -202,13 +340,22 @@ point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); }; - Chart.RectangularElementController.prototype.updateBezierControlPoints = function updateBezierControlPoints() { + Chart.RectangularElementController.prototype.setRectangleHoverStyle = function(rectangle) { + var dataset = this.chartInstance.data.datasets[rectangle._datasetIndex]; + var index = rectangle._index; + + rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + }; + + Chart.RectangularElementController.prototype.updateBezierControlPoints = function updateBezierControlPoints(dataset) { // Update control points for the bezier curve - this.eachPoint(function(point, index, dataset, datasetIndex) { + helpers.each(dataset.metaData, function(point, index) { var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, + this.previousPoint(dataset.metaData, index)._model, point._model, - this.nextPoint(dataset, index)._model, + this.nextPoint(dataset.metaData, index)._model, point._model.tension ); From 81c66c8d8549a458518a6534ae3e81c5c496fe85 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Jun 2015 17:05:46 -0400 Subject: [PATCH 159/424] Fix duplicate property --- src/scales/scale.linear.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 60caae47734..f6abee47226 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -37,7 +37,6 @@ }; var LinearScale = Chart.Element.extend({ - calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use isHorizontal: function() { return this.options.position == "top" || this.options.position == "bottom"; }, From 3f9afb1f31e68338ff426ae46f64aeda0014f25c Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 14 Jun 2015 18:09:45 -0600 Subject: [PATCH 160/424] More core file separation, and no duplicate copyrights --- gulpfile.js | 15 +- src/core/core.animation.js | 11 - src/core/core.chart.js | 209 ++++++++++++++ src/core/core.element.js | 91 ++++++ src/core/{core.js => core.helpers.js} | 399 +------------------------- src/core/core.responsive.js | 30 ++ src/core/core.tooltip.js | 11 - 7 files changed, 343 insertions(+), 423 deletions(-) create mode 100644 src/core/core.chart.js create mode 100644 src/core/core.element.js rename src/core/{core.js => core.helpers.js} (70%) mode change 100755 => 100644 create mode 100644 src/core/core.responsive.js diff --git a/gulpfile.js b/gulpfile.js index 68bed24db2e..940a97aab36 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,15 +16,18 @@ var gulp = require('gulp'), 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 + * 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() { var srcFiles = [ './src/core/core.js', + './src/core/core.helpers.js', + './src/core/core.chart.js', + './src/core/core.element.js', './src/core/**', './src/controllers/**', './src/scales/**', @@ -49,9 +52,9 @@ gulp.task('build', function() { }); /* - * Usage : gulp bump - * Prompts: Version increment to bump - * Output: - New version number written into package.json & bower.json + * Usage : gulp bump + * Prompts: Version increment to bump + * Output: - New version number written into package.json & bower.json */ gulp.task('bump', function(complete) { diff --git a/src/core/core.animation.js b/src/core/core.animation.js index f8812b5d940..03e7577fbbf 100644 --- a/src/core/core.animation.js +++ b/src/core/core.animation.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 - */ - - (function() { "use strict"; diff --git a/src/core/core.chart.js b/src/core/core.chart.js new file mode 100644 index 00000000000..a47361df6be --- /dev/null +++ b/src/core/core.chart.js @@ -0,0 +1,209 @@ +(function() { + + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart, + helpers = Chart.helpers; + + + //Create a dictionary of chart types, to allow for extension of existing types + Chart.types = {}; + + //Store a reference to each instance - allowing us to globally resize chart instances on window resize. + //Destroy method on the chart will remove the instance of the chart from this reference. + Chart.instances = {}; + + Chart.Type = function(config, instance) { + this.data = config.data; + this.options = config.options; + this.chart = instance; + this.id = helpers.uid(); + //Add the chart instance to the global namespace + Chart.instances[this.id] = this; + + // Initialize is always called when a chart type is created + // By default it is a no op, but it should be extended + if (this.options.responsive) { + this.resize(); + } + this.initialize.call(this); + }; + + //Core methods that'll be a part of every chart type + helpers.extend(Chart.Type.prototype, { + initialize: function() { + return this; + }, + clear: function() { + helpers.clear(this.chart); + return this; + }, + stop: function() { + // Stops any current animation loop occuring + Chart.animationService.cancelAnimation(this); + return this; + }, + resize: function() { + this.stop(); + var canvas = this.chart.canvas, + newWidth = helpers.getMaximumWidth(this.chart.canvas), + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + + canvas.width = this.chart.width = newWidth; + canvas.height = this.chart.height = newHeight; + + helpers.retinaScale(this.chart); + + return this; + }, + update: function(animationDuration) { + this.canvasController.update(); + this.render(animationDuration); + }, + render: function(duration) { + + if (this.options.animation.duration !== 0 || duration) { + var animation = new Chart.Animation(); + animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps + animation.easing = this.options.animation.easing; + + // render function + animation.render = function(chartInstance, animationObject) { + var easingFunction = helpers.easingEffects[animationObject.easing]; + var stepDecimal = animationObject.currentStep / animationObject.numSteps; + var easeDecimal = easingFunction(stepDecimal); + + chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); + }; + + // user events + animation.onAnimationProgress = this.options.onAnimationProgress; + animation.onAnimationComplete = this.options.onAnimationComplete; + + Chart.animationService.addAnimation(this, animation, duration); + } else { + this.draw(); + this.options.onAnimationComplete.call(this); + } + return this; + }, + eachElement: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }, + eachValue: function(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.data, callback, this, datasetIndex); + }, this); + }, + eachDataset: function(callback) { + helpers.each(this.data.datasets, callback, this); + }, + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + generateLegend: function() { + return template(this.options.legendTemplate, this); + }, + 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]; + }, + toBase64Image: function() { + return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); + } + }); + + Chart.Type.extend = function(extensions) { + + var parent = this; + + var ChartType = function() { + return parent.apply(this, arguments); + }; + + //Copy the prototype object of the this class + ChartType.prototype = helpers.clone(parent.prototype); + + //Now overwrite some of the properties in the base class with the new extensions + helpers.extend(ChartType.prototype, extensions); + ChartType.extend = Chart.Type.extend; + + if (extensions.name || parent.prototype.name) { + + var chartName = extensions.name || parent.prototype.name; + //Assign any potential default values of the new chart type + + //If none are defined, we'll use a clone of the chart type this is being extended from. + //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart + //doesn't define some defaults of their own. + + var baseDefaults = (Chart.defaults[parent.prototype.name]) ? helpers.clone(Chart.defaults[parent.prototype.name]) : {}; + + Chart.defaults[chartName] = helpers.configMerge(baseDefaults, extensions.defaults); + + Chart.types[chartName] = ChartType; + + //Register this new chart type in the Chart prototype + Chart.prototype[chartName] = function(config) { + config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[chartName], config.options || {}); + return new ChartType(config, this); + }; + } else { + warn("Name not provided for this chart, so it hasn't been registered"); + } + return parent; + }; + +}).call(this); diff --git a/src/core/core.element.js b/src/core/core.element.js new file mode 100644 index 00000000000..d787a633674 --- /dev/null +++ b/src/core/core.element.js @@ -0,0 +1,91 @@ +(function() { + + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart, + helpers = Chart.helpers; + + + Chart.Element = function(configuration) { + helpers.extend(this, configuration); + this.initialize.apply(this, arguments); + }; + helpers.extend(Chart.Element.prototype, { + initialize: function() {}, + pivot: function() { + if (!this._view) { + this._view = helpers.clone(this._model); + } + this._start = helpers.clone(this._view); + return this; + }, + transition: function(ease) { + if (!this._view) { + this._view = helpers.clone(this._model); + } + if (!this._start) { + this.pivot(); + } + + helpers.each(this._model, function(value, key) { + + if (key[0] === '_' || !this._model.hasOwnProperty(key)) { + // Only non-underscored properties + } + + // Init if doesn't exist + else if (!this._view[key]) { + if (typeof value === 'number') { + this._view[key] = value * ease; + } else { + this._view[key] = value || null; + } + } + + // No unnecessary computations + else if (this._model[key] === this._view[key]) { + // It's the same! Woohoo! + } + + // Color transitions if possible + else if (typeof value === 'string') { + try { + var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); + this._view[key] = color.rgbString(); + } catch (err) { + this._view[key] = value; + } + } + // Number transitions + else if (typeof value === 'number') { + var startVal = this._start[key] !== undefined ? this._start[key] : 0; + this._view[key] = ((this._model[key] - startVal) * ease) + startVal; + } + // Everything else + else { + this._view[key] = value; + } + + }, this); + + if (ease === 1) { + delete this._start; + } + return this; + }, + tooltipPosition: function() { + return { + x: this._model.x, + y: this._model.y + }; + }, + hasValue: function() { + return helpers.isNumber(this._model.x) && helpers.isNumber(this._model.y); + } + }); + + Chart.Element.extend = helpers.inherits; + +}).call(this); diff --git a/src/core/core.js b/src/core/core.helpers.js old mode 100755 new mode 100644 similarity index 70% rename from src/core/core.js rename to src/core/core.helpers.js index e3f8ddcdadc..c3e649437d3 --- a/src/core/core.js +++ b/src/core/core.helpers.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 - */ - - (function() { "use strict"; @@ -17,73 +6,6 @@ var root = this, previous = root.Chart; - //Occupy the global variable of Chart, and create a simple base class - var Chart = function(context) { - var chart = this; - - // Support a jQuery'd canvas element - if (context.length && context[0].getContext) { - context = context[0]; - } - - // Support a canvas domnode - if (context.getContext) { - context = context.getContext("2d"); - } - - this.canvas = context.canvas; - - this.ctx = context; - - //Variables global to the chart - var computeDimension = function(element, dimension) { - if (element['offset' + dimension]) { - return element['offset' + dimension]; - } else { - return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); - } - }; - - var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; - var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; - - // Firefox requires this to work correctly - context.canvas.width = width; - context.canvas.height = height; - - width = this.width = context.canvas.width; - height = this.height = context.canvas.height; - this.aspectRatio = this.width / this.height; - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. - helpers.retinaScale(this); - - return this; - }; - - var defaultColor = 'rgba(0,0,0,0.1)'; - - //Globally expose the defaults to allow for user updating/changing - Chart.defaults = { - global: { - responsive: true, - maintainAspectRatio: true, - events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], - hover: { - onHover: null, - mode: 'single', - animationDuration: 400, - }, - onClick: null, - defaultColor: defaultColor, - - // Element defaults defined in element extensions - elements: {} - }, - }; - - //Create a dictionary of chart types, to allow for extension of existing types - Chart.types = {}; - //Global Chart helpers object for utility methods and classes var helpers = Chart.helpers = {}; @@ -148,13 +70,13 @@ } else if (key === 'scale') { // Used in polar area & radar charts since there is only one scale base[key] = helpers.configMerge(base.hasOwnProperty(key) ? base[key] : {}, Chart.scaleService.getScaleDefaults(value.type), value); - }else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { + } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { // In this case we have an array of objects replacing another array. Rather than doing a strict replace, // merge. This allows easy scale option merging var baseArray = base[key]; helpers.each(value, function(valueObj, index) { - + if (index < baseArray.length) { baseArray[index] = helpers.configMerge(baseArray[index], valueObj); } else { @@ -187,7 +109,7 @@ helpers.each(value, function(valueObj, index) { if (index >= base[key].length || !base[key][index].type) { base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj)); - } else if (valueObj.type !== base[key][index].type) { + } else if (valueObj.type !== base[key][index].type) { // Type changed. Bring in the new defaults before we bring in valueObj so that valueObj can override the correct scale defaults base[key][index] = helpers.configMerge(base[key][index], valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj) } else { @@ -285,9 +207,7 @@ ChartElement.extend = inherits; - if (extensions) { - extend(ChartElement.prototype, extensions); - } + if (extensions) extend(ChartElement.prototype, extensions); ChartElement.__super__ = parent.prototype; @@ -943,315 +863,4 @@ return Array.isArray(obj); }; - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. - //Destroy method on the chart will remove the instance of the chart from this reference. - Chart.instances = {}; - - Chart.Type = function(config, instance) { - this.data = config.data; - this.options = config.options; - this.chart = instance; - this.id = uid(); - //Add the chart instance to the global namespace - Chart.instances[this.id] = this; - - // Initialize is always called when a chart type is created - // By default it is a no op, but it should be extended - if (this.options.responsive) { - this.resize(); - } - this.initialize.call(this); - }; - - //Core methods that'll be a part of every chart type - extend(Chart.Type.prototype, { - initialize: function() { - return this; - }, - clear: function() { - clear(this.chart); - return this; - }, - stop: function() { - // Stops any current animation loop occuring - Chart.animationService.cancelAnimation(this); - return this; - }, - resize: function() { - this.stop(); - var canvas = this.chart.canvas, - newWidth = getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); - - canvas.width = this.chart.width = newWidth; - canvas.height = this.chart.height = newHeight; - - retinaScale(this.chart); - - return this; - }, - update: function(animationDuration) { - this.canvasController.update(); - this.render(animationDuration); - }, - render: function(duration) { - - if (this.options.animation.duration !== 0 || duration) { - var animation = new Chart.Animation(); - animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps - animation.easing = this.options.animation.easing; - - // render function - animation.render = function(chartInstance, animationObject) { - var easingFunction = helpers.easingEffects[animationObject.easing]; - var stepDecimal = animationObject.currentStep / animationObject.numSteps; - var easeDecimal = easingFunction(stepDecimal); - - chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); - }; - - // user events - animation.onAnimationProgress = this.options.onAnimationProgress; - animation.onAnimationComplete = this.options.onAnimationComplete; - - Chart.animationService.addAnimation(this, animation, duration); - } else { - this.draw(); - this.options.onAnimationComplete.call(this); - } - return this; - }, - eachElement: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - }, this); - }, - eachValue: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, callback, this, datasetIndex); - }, this); - }, - eachDataset: function(callback) { - helpers.each(this.data.datasets, callback, this); - }, - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; - }, - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } - - return []; - }, - generateLegend: function() { - return template(this.options.legendTemplate, this); - }, - 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]; - }, - toBase64Image: function() { - return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); - } - }); - - Chart.Type.extend = function(extensions) { - - var parent = this; - - var ChartType = function() { - return parent.apply(this, arguments); - }; - - //Copy the prototype object of the this class - ChartType.prototype = clone(parent.prototype); - - //Now overwrite some of the properties in the base class with the new extensions - extend(ChartType.prototype, extensions); - ChartType.extend = Chart.Type.extend; - - if (extensions.name || parent.prototype.name) { - - var chartName = extensions.name || parent.prototype.name; - //Assign any potential default values of the new chart type - - //If none are defined, we'll use a clone of the chart type this is being extended from. - //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart - //doesn't define some defaults of their own. - - var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; - - Chart.defaults[chartName] = helpers.configMerge(baseDefaults, extensions.defaults); - - Chart.types[chartName] = ChartType; - - //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(config) { - config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[chartName], config.options || {}); - return new ChartType(config, this); - }; - } else { - warn("Name not provided for this chart, so it hasn't been registered"); - } - return parent; - }; - - Chart.Element = function(configuration) { - extend(this, configuration); - this.initialize.apply(this, arguments); - }; - extend(Chart.Element.prototype, { - initialize: function() {}, - pivot: function() { - if (!this._view) { - this._view = clone(this._model); - } - this._start = clone(this._view); - return this; - }, - transition: function(ease) { - if (!this._view) { - this._view = clone(this._model); - } - if (!this._start) { - this.pivot(); - } - - each(this._model, function(value, key) { - - if (key[0] === '_' || !this._model.hasOwnProperty(key)) { - // Only non-underscored properties - } - - // Init if doesn't exist - else if (!this._view[key]) { - if (typeof value === 'number') { - this._view[key] = value * ease; - } else { - this._view[key] = value || null; - } - } - - // No unnecessary computations - else if (this._model[key] === this._view[key]) { - // It's the same! Woohoo! - } - - // Color transitions if possible - else if (typeof value === 'string') { - try { - var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); - this._view[key] = color.rgbString(); - } catch (err) { - this._view[key] = value; - } - } - // Number transitions - else if (typeof value === 'number') { - var startVal = this._start[key] !== undefined ? this._start[key] : 0; - this._view[key] = ((this._model[key] - startVal) * ease) + startVal; - } - // Everything else - else { - this._view[key] = value; - } - - }, this); - - if (ease === 1) { - delete this._start; - } - return this; - }, - tooltipPosition: function() { - return { - x: this._model.x, - y: this._model.y - }; - }, - hasValue: function() { - return isNumber(this._model.x) && isNumber(this._model.y); - } - }); - - Chart.Element.extend = inherits; - - - // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function() { - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function() { - clearTimeout(timeout); - timeout = setTimeout(function() { - each(Chart.instances, function(instance) { - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive) { - instance.resize(); - instance.update(); - } - }); - }, 50); - }; - })()); - - - if (amd) { - define(function() { - return Chart; - }); - } else if (typeof module === 'object' && module.exports) { - module.exports = Chart; - } - - root.Chart = Chart; - - Chart.noConflict = function() { - root.Chart = previous; - return Chart; - }; - }).call(this); diff --git a/src/core/core.responsive.js b/src/core/core.responsive.js new file mode 100644 index 00000000000..73c12ea3057 --- /dev/null +++ b/src/core/core.responsive.js @@ -0,0 +1,30 @@ +(function() { + + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart, + helpers = Chart.helpers; + + + // Attach global event to resize each chart instance when the browser resizes + helpers.addEvent(window, "resize", (function() { + // Basic debounce of resize function so it doesn't hurt performance when resizing browser. + var timeout; + return function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + each(Chart.instances, function(instance) { + // If the responsive flag is set in the chart instance config + // Cascade the resize event down to the chart. + if (instance.options.responsive) { + instance.resize(); + instance.update(); + } + }); + }, 50); + }; + })()); + +}).call(this); diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 308a0c069ec..13e5548bcc0 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.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 - */ - - (function() { "use strict"; From 4047440acc33e0ba81487de0a1616afb7369afa8 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 14 Jun 2015 18:10:00 -0600 Subject: [PATCH 161/424] Git thinks the core file is new now haha --- src/core/core.js | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 src/core/core.js diff --git a/src/core/core.js b/src/core/core.js new file mode 100755 index 00000000000..5811ba26142 --- /dev/null +++ b/src/core/core.js @@ -0,0 +1,99 @@ +/*! + * 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 + */ + + +(function() { + + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart; + + //Occupy the global variable of Chart, and create a simple base class + var Chart = function(context) { + var chart = this; + + // Support a jQuery'd canvas element + if (context.length && context[0].getContext) { + context = context[0]; + } + + // Support a canvas domnode + if (context.getContext) { + context = context.getContext("2d"); + } + + this.canvas = context.canvas; + + this.ctx = context; + + //Variables global to the chart + var computeDimension = function(element, dimension) { + if (element['offset' + dimension]) { + return element['offset' + dimension]; + } else { + return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); + } + }; + + var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; + var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; + + // Firefox requires this to work correctly + context.canvas.width = width; + context.canvas.height = height; + + width = this.width = context.canvas.width; + height = this.height = context.canvas.height; + this.aspectRatio = this.width / this.height; + //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. + Chart.helpers.retinaScale(this); + + return this; + }; + + var defaultColor = 'rgba(0,0,0,0.1)'; + + //Globally expose the defaults to allow for user updating/changing + Chart.defaults = { + global: { + responsive: true, + maintainAspectRatio: true, + events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], + hover: { + onHover: null, + mode: 'single', + animationDuration: 400, + }, + onClick: null, + defaultColor: defaultColor, + + // Element defaults defined in element extensions + elements: {} + }, + }; + + if (typeof amd !== 'undefined') { + define(function() { + return Chart; + }); + } else if (typeof module === 'object' && module.exports) { + module.exports = Chart; + } + + root.Chart = Chart; + + Chart.noConflict = function() { + root.Chart = previous; + return Chart; + }; + +}).call(this); From d73dae09e76dc9b08849c2a15b49f49d01e95d8b Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 14 Jun 2015 19:15:10 -0600 Subject: [PATCH 162/424] No hardcoded chart type methods --- gulpfile.js | 1 - samples/bar.html | 2 +- src/{charts => _charts}/chart.bar.js | 1 - src/{charts => _charts}/chart.doughnut.js | 0 src/{charts => _charts}/chart.line.js | 0 src/{charts => _charts}/chart.polarArea.js | 0 src/{charts => _charts}/chart.radar.js | 0 src/{charts => _charts}/chart.scatter.js | 0 .../controller.canvas.rectangular.js | 186 --------- src/core/core.chart.js | 209 ---------- src/core/core.controller.js | 371 ++++++++++++++++++ src/core/core.js | 7 +- 12 files changed, 377 insertions(+), 400 deletions(-) rename src/{charts => _charts}/chart.bar.js (99%) rename src/{charts => _charts}/chart.doughnut.js (100%) rename src/{charts => _charts}/chart.line.js (100%) rename src/{charts => _charts}/chart.polarArea.js (100%) rename src/{charts => _charts}/chart.radar.js (100%) rename src/{charts => _charts}/chart.scatter.js (100%) delete mode 100644 src/core/core.chart.js create mode 100644 src/core/core.controller.js diff --git a/gulpfile.js b/gulpfile.js index 940a97aab36..9ce3dc3f4bb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,7 +33,6 @@ gulp.task('build', function() { './src/scales/**', './src/elements/**', './src/charts/**', - './src/**', './node_modules/color/dist/color.min.js' ], isCustom = !!(util.env.types), diff --git a/samples/bar.html b/samples/bar.html index 117c375313e..5e0018d8de2 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -39,7 +39,7 @@ }; window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myBar = new Chart(ctx).Bar({ + window.myBar = new Chart(ctx, { data: barChartData, options: { responsive: true, diff --git a/src/charts/chart.bar.js b/src/_charts/chart.bar.js similarity index 99% rename from src/charts/chart.bar.js rename to src/_charts/chart.bar.js index 4d9990b113f..9154fb5445c 100644 --- a/src/charts/chart.bar.js +++ b/src/_charts/chart.bar.js @@ -25,7 +25,6 @@ type: "linear", }], }, - }; diff --git a/src/charts/chart.doughnut.js b/src/_charts/chart.doughnut.js similarity index 100% rename from src/charts/chart.doughnut.js rename to src/_charts/chart.doughnut.js diff --git a/src/charts/chart.line.js b/src/_charts/chart.line.js similarity index 100% rename from src/charts/chart.line.js rename to src/_charts/chart.line.js diff --git a/src/charts/chart.polarArea.js b/src/_charts/chart.polarArea.js similarity index 100% rename from src/charts/chart.polarArea.js rename to src/_charts/chart.polarArea.js diff --git a/src/charts/chart.radar.js b/src/_charts/chart.radar.js similarity index 100% rename from src/charts/chart.radar.js rename to src/_charts/chart.radar.js diff --git a/src/charts/chart.scatter.js b/src/_charts/chart.scatter.js similarity index 100% rename from src/charts/chart.scatter.js rename to src/_charts/chart.scatter.js diff --git a/src/controllers/controller.canvas.rectangular.js b/src/controllers/controller.canvas.rectangular.js index a4a75cef07b..80da709a44e 100644 --- a/src/controllers/controller.canvas.rectangular.js +++ b/src/controllers/controller.canvas.rectangular.js @@ -5,191 +5,5 @@ Chart = root.Chart, helpers = Chart.helpers; - Chart.RectangularCanvasController = function(chart, elementController) { - this.chartInstance = chart; - this.elementController = elementController; - }; - Chart.RectangularCanvasController.prototype.initialize = function() { - this.bindEvents(); - this.buildScales(); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this.chartInstance, this.chartInstance.chart.width, this.chartInstance.chart.height); - this.elementController.resetElements(); - - this.initToolTip(); - - this.chartInstance.update(); - }; - - Chart.RectangularCanvasController.prototype.bindEvents = function() { - helpers.bindEvents(this.chartInstance, this.chartInstance.options.events, function(evt) { - // this will be the chart instance - this.canvasController.eventHandler(evt); - }); - }; - - Chart.RectangularCanvasController.prototype.eventHandler = function(e) { - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.chartInstance.options.hover.mode) { - case 'single': - return this.elementController.getElementAtEvent(e); - case 'label': - return this.elementController.getElementsAtEvent(e); - case 'dataset': - return this.elementController.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.chartInstance.options.hover.onHover) { - this.chartInstance.options.hover.onHover.call(this.chartInstance, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.chartInstance.options.onClick) { - this.chartInstance.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.chartInstance.options.hover.mode) { - case 'single': - this.elementController.resetElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - this.elementController.resetElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.chartInstance.options.hover.mode) { - switch (this.chartInstance.options.hover.mode) { - case 'single': - this.elementController.setElementHoverStyle(this.active[0]); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - this.elementController.setElementHoverStyle(this.active[i]); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.chartInstance.options.tooltips.enabled) { - - // The usual updates - this.chartInstance.tooltip.initialize(); - - // Active - if (this.active.length) { - this.chartInstance.tooltip._model.opacity = 1; - - helpers.extend(this.chartInstance.tooltip, { - _active: this.active, - }); - - this.chartInstance.tooltip.update(); - } else { - // Inactive - this.chartInstance.tooltip._model.opacity = 0; - } - } - - // Hover animations - this.chartInstance.tooltip.pivot(); - - if (!this.chartInstance.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.chartInstance.stop(); - this.chartInstance.render(this.chartInstance.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }; - - Chart.RectangularCanvasController.prototype.initToolTip = function() { - this.chartInstance.tooltip = new Chart.Tooltip({ - _chart: this.chartInstance.chart, - _data: this.chartInstance.data, - _options: this.chartInstance.options, - }, this); - }; - - Chart.RectangularCanvasController.prototype.buildScales = function() { - // Map of scale ID to scale object so we can lookup later - this.chartInstance.scales = {}; - - // Build the x axes - helpers.each(this.chartInstance.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chartInstance.chart.ctx, - options: xAxisOptions, - data: this.chartInstance.data, - id: xAxisOptions.id, - }); - - this.chartInstance.scales[scale.id] = scale; - }, this); - - // Build the y axes - helpers.each(this.chartInstance.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chartInstance.chart.ctx, - options: yAxisOptions, - data: this.chartInstance.data, - id: yAxisOptions.id, - }); - - this.chartInstance.scales[scale.id] = scale; - }, this); - }; - - Chart.RectangularCanvasController.prototype.update = function() { - Chart.scaleService.fitScalesForChart(this.chartInstance, this.chartInstance.chart.width, this.chartInstance.chart.height); - this.elementController.updateElements(); - }; }).call(this); diff --git a/src/core/core.chart.js b/src/core/core.chart.js deleted file mode 100644 index a47361df6be..00000000000 --- a/src/core/core.chart.js +++ /dev/null @@ -1,209 +0,0 @@ -(function() { - - "use strict"; - - //Declare root variable - window in the browser, global on the server - var root = this, - previous = root.Chart, - helpers = Chart.helpers; - - - //Create a dictionary of chart types, to allow for extension of existing types - Chart.types = {}; - - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. - //Destroy method on the chart will remove the instance of the chart from this reference. - Chart.instances = {}; - - Chart.Type = function(config, instance) { - this.data = config.data; - this.options = config.options; - this.chart = instance; - this.id = helpers.uid(); - //Add the chart instance to the global namespace - Chart.instances[this.id] = this; - - // Initialize is always called when a chart type is created - // By default it is a no op, but it should be extended - if (this.options.responsive) { - this.resize(); - } - this.initialize.call(this); - }; - - //Core methods that'll be a part of every chart type - helpers.extend(Chart.Type.prototype, { - initialize: function() { - return this; - }, - clear: function() { - helpers.clear(this.chart); - return this; - }, - stop: function() { - // Stops any current animation loop occuring - Chart.animationService.cancelAnimation(this); - return this; - }, - resize: function() { - this.stop(); - var canvas = this.chart.canvas, - newWidth = helpers.getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); - - canvas.width = this.chart.width = newWidth; - canvas.height = this.chart.height = newHeight; - - helpers.retinaScale(this.chart); - - return this; - }, - update: function(animationDuration) { - this.canvasController.update(); - this.render(animationDuration); - }, - render: function(duration) { - - if (this.options.animation.duration !== 0 || duration) { - var animation = new Chart.Animation(); - animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps - animation.easing = this.options.animation.easing; - - // render function - animation.render = function(chartInstance, animationObject) { - var easingFunction = helpers.easingEffects[animationObject.easing]; - var stepDecimal = animationObject.currentStep / animationObject.numSteps; - var easeDecimal = easingFunction(stepDecimal); - - chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); - }; - - // user events - animation.onAnimationProgress = this.options.onAnimationProgress; - animation.onAnimationComplete = this.options.onAnimationComplete; - - Chart.animationService.addAnimation(this, animation, duration); - } else { - this.draw(); - this.options.onAnimationComplete.call(this); - } - return this; - }, - eachElement: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - }, this); - }, - eachValue: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, callback, this, datasetIndex); - }, this); - }, - eachDataset: function(callback) { - helpers.each(this.data.datasets, callback, this); - }, - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; - }, - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } - - return []; - }, - generateLegend: function() { - return template(this.options.legendTemplate, this); - }, - 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]; - }, - toBase64Image: function() { - return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); - } - }); - - Chart.Type.extend = function(extensions) { - - var parent = this; - - var ChartType = function() { - return parent.apply(this, arguments); - }; - - //Copy the prototype object of the this class - ChartType.prototype = helpers.clone(parent.prototype); - - //Now overwrite some of the properties in the base class with the new extensions - helpers.extend(ChartType.prototype, extensions); - ChartType.extend = Chart.Type.extend; - - if (extensions.name || parent.prototype.name) { - - var chartName = extensions.name || parent.prototype.name; - //Assign any potential default values of the new chart type - - //If none are defined, we'll use a clone of the chart type this is being extended from. - //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart - //doesn't define some defaults of their own. - - var baseDefaults = (Chart.defaults[parent.prototype.name]) ? helpers.clone(Chart.defaults[parent.prototype.name]) : {}; - - Chart.defaults[chartName] = helpers.configMerge(baseDefaults, extensions.defaults); - - Chart.types[chartName] = ChartType; - - //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(config) { - config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[chartName], config.options || {}); - return new ChartType(config, this); - }; - } else { - warn("Name not provided for this chart, so it hasn't been registered"); - } - return parent; - }; - -}).call(this); diff --git a/src/core/core.controller.js b/src/core/core.controller.js new file mode 100644 index 00000000000..b52e8b0b3c5 --- /dev/null +++ b/src/core/core.controller.js @@ -0,0 +1,371 @@ +(function() { + + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart, + helpers = Chart.helpers; + + + //Create a dictionary of chart types, to allow for extension of existing types + Chart.types = {}; + + //Store a reference to each instance - allowing us to globally resize chart instances on window resize. + //Destroy method on the chart will remove the instance of the chart from this reference. + Chart.instances = {}; + + Chart.Controller = function(instance) { + + this.chart = instance; + var config = instance.config; + this.data = config.data; + this.options = config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[config.type], config.options || {}); + this.id = helpers.uid(); + + console.log(this.options); + + //Add the chart instance to the global namespace + Chart.instances[this.id] = this; + + // Initialize is always called when a chart type is created + // By default it is a no op, but it should be extended + + if (this.options.responsive) { + this.resize(); + } + + this.initialize.call(this); + + return this; + }; + + helpers.extend(Chart.Controller.prototype, { + + initialize: function initialize() { + return this; + }, + + clear: function clear() { + helpers.clear(this.chart); + return this; + }, + + stop: function stop() { + // Stops any current animation loop occuring + Chart.animationService.cancelAnimation(this); + return this; + }, + + resize: function resize() { + this.stop(); + var canvas = this.chart.canvas, + newWidth = helpers.getMaximumWidth(this.chart.canvas), + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + + canvas.width = this.chart.width = newWidth; + canvas.height = this.chart.height = newHeight; + + helpers.retinaScale(this.chart); + + return this; + }, + + update: function update(animationDuration) { + this.canvasController.update(); + this.render(animationDuration); + }, + + render: function render(duration) { + + if (this.options.animation.duration !== 0 || duration) { + var animation = new Chart.Animation(); + animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps + animation.easing = this.options.animation.easing; + + // render function + animation.render = function(chartInstance, animationObject) { + var easingFunction = helpers.easingEffects[animationObject.easing]; + var stepDecimal = animationObject.currentStep / animationObject.numSteps; + var easeDecimal = easingFunction(stepDecimal); + + chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); + }; + + // user events + animation.onAnimationProgress = this.options.onAnimationProgress; + animation.onAnimationComplete = this.options.onAnimationComplete; + + Chart.animationService.addAnimation(this, animation, duration); + } else { + this.draw(); + this.options.onAnimationComplete.call(this); + } + return this; + }, + + eachElement: function eachElement(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }, + + eachValue: function eachValue(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.data, callback, this, datasetIndex); + }, this); + }, + + eachDataset: function eachDataset(callback) { + helpers.each(this.data.datasets, callback, this); + }, + + getElementsAtEvent: function getElementsAtEvent(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw + getElementAtEvent: function getElementAtEvent(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + + generateLegend: function generateLegend() { + return template(this.options.legendTemplate, this); + }, + + destroy: function destroy() { + 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]; + }, + + toBase64Image: function toBase64Image() { + return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); + }, + initialize: function initialize() { + this.bindEvents(); + this.buildScales(); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + this.elementController.resetElements(); + + this.initToolTip(); + + this.update(); + }, + + bindEvents: function bindEvents() { + helpers.bindEvents(this, this.options.events, function(evt) { + // this will be the chart instance + this.canvasController.eventHandler(evt); + }); + }, + + eventHandler: function eventHandler(e) { + this.lastActive = this.lastActive || []; + + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.elementController.getElementAtEvent(e); + case 'label': + return this.elementController.getElementsAtEvent(e); + case 'dataset': + return this.elementController.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + this.elementController.resetElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.elementController.resetElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + this.elementController.setElementHoverStyle(this.active[0]); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.elementController.setElementHoverStyle(this.active[i]); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + + initToolTip: function initToolTip() { + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + }, + + buildScales: function buildScales() { + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axes + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + update: function update() { + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + this.elementController.updateElements(); + } + }); + +}).call(this); diff --git a/src/core/core.js b/src/core/core.js index 5811ba26142..d8037c6111d 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -18,8 +18,9 @@ previous = root.Chart; //Occupy the global variable of Chart, and create a simple base class - var Chart = function(context) { + var Chart = function(context, config) { var chart = this; + this.config = config; // Support a jQuery'd canvas element if (context.length && context[0].getContext) { @@ -57,7 +58,9 @@ //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. Chart.helpers.retinaScale(this); - return this; + this.controller = new Chart.Controller(this); + + return this.controller; }; var defaultColor = 'rgba(0,0,0,0.1)'; From d811812356003a77e158938f437c59fae5673cac Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 14 Jun 2015 19:26:44 -0600 Subject: [PATCH 163/424] Little tweaks --- src/core/core.controller.js | 140 +++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 67 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index b52e8b0b3c5..74e73d9f495 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -43,6 +43,18 @@ helpers.extend(Chart.Controller.prototype, { initialize: function initialize() { + + this.bindEvents(); + this.buildScales(); + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + this.resetElements(); + + this.initToolTip(); + + this.update(); + return this; }, @@ -71,9 +83,43 @@ return this; }, + buildScales: function buildScales() { + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axes + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + }, + + resetElements: function resetElements() { + // This will loop through any data and do the appropriate element reset for the type + }, update: function update(animationDuration) { - this.canvasController.update(); - this.render(animationDuration); + // This will loop through any data and do the appropriate element update for the type + //this.render(animationDuration); }, render: function render(duration) { @@ -104,15 +150,15 @@ return this; }, - eachElement: function eachElement(callback) { + eachValue: function eachValue(callback) { helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + helpers.each(dataset.data, callback, this, datasetIndex); }, this); }, - eachValue: function eachValue(callback) { + eachElement: function eachElement(callback) { helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, callback, this, datasetIndex); + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); }, this); }, @@ -120,7 +166,27 @@ helpers.each(this.data.datasets, callback, this); }, + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw + getElementAtEvent: function getElementAtEvent(e) { + + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + getElementsAtEvent: function getElementsAtEvent(e) { + var elementsArray = [], eventPosition = helpers.getRelativePosition(e), datasetIterator = function(dataset) { @@ -139,31 +205,13 @@ return elementsArray.length ? elementsArray : []; }, - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw - getElementAtEvent: function getElementAtEvent(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } - - return []; - }, - generateLegend: function generateLegend() { return template(this.options.legendTemplate, this); }, destroy: function destroy() { this.clear(); - unbindEvents(this, this.events); + helpers.unbindEvents(this, this.events); var canvas = this.chart.canvas; // Reset canvas height/width attributes starts a fresh with the canvas context @@ -185,19 +233,6 @@ toBase64Image: function toBase64Image() { return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); }, - initialize: function initialize() { - this.bindEvents(); - this.buildScales(); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - this.elementController.resetElements(); - - this.initToolTip(); - - this.update(); - }, - bindEvents: function bindEvents() { helpers.bindEvents(this, this.options.events, function(evt) { // this will be the chart instance @@ -332,36 +367,7 @@ }, this); }, - buildScales: function buildScales() { - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axes - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - data: this.data, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - - // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - this.scales[scale.id] = scale; - }, this); - }, update: function update() { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); this.elementController.updateElements(); From 43f2c015f3e2a5b61263e8ab07ff921c5a8541c0 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 14 Jun 2015 19:30:02 -0600 Subject: [PATCH 164/424] Charts become config blocks (themes, if you will :) --- src/_charts/chart.bar.js | 88 ++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/_charts/chart.bar.js b/src/_charts/chart.bar.js index 9154fb5445c..24d2abb2bfb 100644 --- a/src/_charts/chart.bar.js +++ b/src/_charts/chart.bar.js @@ -5,7 +5,8 @@ Chart = root.Chart, helpers = Chart.helpers; - var defaultConfig = { + + Chart.defaults.bar = { hover: { mode: "label" }, @@ -27,49 +28,48 @@ }, }; - - Chart.Type.extend({ - name: "Bar", - defaults: defaultConfig, - initialize: function() { - this.elementController = new Chart.RectangularElementController(this); - this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, function(dataPoint, index) { - this.elementController.addRectangle(dataset, datasetIndex, index); - }, this); - - // The bar chart only supports a single x axis because the x axis is always a category axis - dataset.xAxisID = this.options.scales.xAxes[0].id; - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - }, this); - - this.canvasController.initialize(); - }, - draw: function(ease) { - - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - //Draw all the bars for each dataset - this.eachElement(function(bar, index, datasetIndex) { - bar.transition(easingDecimal).draw(); - }, this); - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - }); + // Chart.Type.extend({ + // name: "Bar", + // defaults: defaultConfig, + // initialize: function() { + // this.elementController = new Chart.RectangularElementController(this); + // this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); + + // //Create a new bar for each piece of data + // helpers.each(this.data.datasets, function(dataset, datasetIndex) { + // helpers.each(dataset.data, function(dataPoint, index) { + // this.elementController.addRectangle(dataset, datasetIndex, index); + // }, this); + + // // The bar chart only supports a single x axis because the x axis is always a category axis + // dataset.xAxisID = this.options.scales.xAxes[0].id; + + // if (!dataset.yAxisID) { + // dataset.yAxisID = this.options.scales.yAxes[0].id; + // } + // }, this); + + // this.canvasController.initialize(); + // }, + // draw: function(ease) { + + // var easingDecimal = ease || 1; + // this.clear(); + + // // Draw all the scales + // helpers.each(this.scales, function(scale) { + // scale.draw(this.chartArea); + // }, this); + + // //Draw all the bars for each dataset + // this.eachElement(function(bar, index, datasetIndex) { + // bar.transition(easingDecimal).draw(); + // }, this); + + // // Finally draw the tooltip + // this.tooltip.transition(easingDecimal).draw(); + // }, + // }); }).call(this); From aaa2484e1b5b7bc3d7fa328fa803c154647f7087 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 14 Jun 2015 19:42:39 -0600 Subject: [PATCH 165/424] Controller function organization --- gulpfile.js | 2 +- samples/bar.html | 1 + src/{_charts => charts}/chart.bar.js | 0 src/{_charts => charts}/chart.doughnut.js | 0 src/{_charts => charts}/chart.line.js | 0 src/{_charts => charts}/chart.polarArea.js | 0 src/{_charts => charts}/chart.radar.js | 0 src/{_charts => charts}/chart.scatter.js | 0 src/core/core.controller.js | 57 +++++++++++++--------- 9 files changed, 36 insertions(+), 24 deletions(-) rename src/{_charts => charts}/chart.bar.js (100%) rename src/{_charts => charts}/chart.doughnut.js (100%) rename src/{_charts => charts}/chart.line.js (100%) rename src/{_charts => charts}/chart.polarArea.js (100%) rename src/{_charts => charts}/chart.radar.js (100%) rename src/{_charts => charts}/chart.scatter.js (100%) diff --git a/gulpfile.js b/gulpfile.js index 9ce3dc3f4bb..70d58c0083c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,7 +32,7 @@ gulp.task('build', function() { './src/controllers/**', './src/scales/**', './src/elements/**', - './src/charts/**', + './src/charts/chart.bar.js', './node_modules/color/dist/color.min.js' ], isCustom = !!(util.env.types), diff --git a/samples/bar.html b/samples/bar.html index 5e0018d8de2..812b2e0d792 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -40,6 +40,7 @@ window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx, { + type: 'bar', data: barChartData, options: { responsive: true, diff --git a/src/_charts/chart.bar.js b/src/charts/chart.bar.js similarity index 100% rename from src/_charts/chart.bar.js rename to src/charts/chart.bar.js diff --git a/src/_charts/chart.doughnut.js b/src/charts/chart.doughnut.js similarity index 100% rename from src/_charts/chart.doughnut.js rename to src/charts/chart.doughnut.js diff --git a/src/_charts/chart.line.js b/src/charts/chart.line.js similarity index 100% rename from src/_charts/chart.line.js rename to src/charts/chart.line.js diff --git a/src/_charts/chart.polarArea.js b/src/charts/chart.polarArea.js similarity index 100% rename from src/_charts/chart.polarArea.js rename to src/charts/chart.polarArea.js diff --git a/src/_charts/chart.radar.js b/src/charts/chart.radar.js similarity index 100% rename from src/_charts/chart.radar.js rename to src/charts/chart.radar.js diff --git a/src/_charts/chart.scatter.js b/src/charts/chart.scatter.js similarity index 100% rename from src/_charts/chart.scatter.js rename to src/charts/chart.scatter.js diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 74e73d9f495..dd2a023405f 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -46,13 +46,8 @@ this.bindEvents(); this.buildScales(); - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - this.resetElements(); - this.initToolTip(); - this.update(); return this; @@ -112,6 +107,8 @@ this.scales[scale.id] = scale; }, this); + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); }, resetElements: function resetElements() { @@ -119,7 +116,8 @@ }, update: function update(animationDuration) { // This will loop through any data and do the appropriate element update for the type - //this.render(animationDuration); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + this.render(animationDuration); }, render: function render(duration) { @@ -205,6 +203,26 @@ return elementsArray.length ? elementsArray : []; }, + getDatasetAtEvent: function getDatasetAtEvent(e) { + + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + generateLegend: function generateLegend() { return template(this.options.legendTemplate, this); }, @@ -233,13 +251,20 @@ toBase64Image: function toBase64Image() { return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); }, + + initToolTip: function initToolTip() { + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + }, + bindEvents: function bindEvents() { helpers.bindEvents(this, this.options.events, function(evt) { - // this will be the chart instance - this.canvasController.eventHandler(evt); + this.eventHandler(evt); }); }, - eventHandler: function eventHandler(e) { this.lastActive = this.lastActive || []; @@ -358,20 +383,6 @@ this.lastActive = this.active; return this; }, - - initToolTip: function initToolTip() { - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - }, - - - update: function update() { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - this.elementController.updateElements(); - } }); }).call(this); From b0ece8b516e0988a3238c903411b24d3029cfddc Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 14:36:02 -0600 Subject: [PATCH 166/424] New controllers, bar drawing (with errors) --- src/controllers/controller.bar.js | 431 ++++++++++++++++++ .../controller.canvas.rectangular.js | 9 - .../controller.elements.rectangular.js | 427 ----------------- src/core/core.controller.js | 75 ++- src/core/core.element.js | 1 + src/core/core.js | 12 +- src/elements/element.rectangle.js | 15 +- 7 files changed, 508 insertions(+), 462 deletions(-) create mode 100644 src/controllers/controller.bar.js delete mode 100644 src/controllers/controller.canvas.rectangular.js delete mode 100644 src/controllers/controller.elements.rectangular.js diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js new file mode 100644 index 00000000000..ef235c18d46 --- /dev/null +++ b/src/controllers/controller.bar.js @@ -0,0 +1,431 @@ +(function() { + + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.controllers.bar = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; + + helpers.extend(Chart.controllers.bar.prototype, { + + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, + + linkScales: function() { + if (!this.getDataset().xAxisID) { + this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; + } + + if (!this.getDataset().yAxisID) { + this.getDataset().yAxisID = this.chart.options.scales.yAxes[0].id; + } + }, + + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, + + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + + addElements: function() { + this.getDataset().metaData = this.getDataset().metaData || []; + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Rectangle({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + }, this); + }, + + reset: function() { + this.update(true); + }, + + update: function(reset) { + + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var yScale = this.getScaleForId(this.getDataset().yAxisID); + helpers.each(this.getDataset().metaData, function(rectangle, index) { + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(rectangle, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), + y: reset ? yScalePoint : yScale.getPixelForValue(this.getDataset().data[index]), + + // Tooltip + label: this.chart.data.labels[index], + datasetLabel: this.getDataset().label, + + // Appearance + base: yScale.calculateBarBase(this.index, index), + width: xScale.calculateBarWidth(this.chart.data.datasets.length), + backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), + borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), + borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), + + }, + }); + rectangle.pivot(); + }, this); + }, + + draw: function(ease) { + var easingDecimal = ease || 1; + helpers.each(this.getDataset().metaData, function(rectangle, index) { + rectangle.transition(easingDecimal).draw(); + }, this); + }, + + + + + + + + + // eachLine: function eachLine(callback) { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { + // callback.call(this, dataset, datasetIndex); + // } + // }, this); + // }, + + // eachRectangle: function(callback) { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // helpers.each(dataset.metaData, function(element, index) { + // if (element instanceof Chart.Rectangle) { + // callback(element, index, dataset, datasetIndex); + // } + // }, this); + // }, this); + // }, + + // addLine: function addLine(dataset, datasetIndex) { + // if (dataset) { + // dataset.metaDataset = new Chart.Line({ + // _chart: this.chart.chart, + // _datasetIndex: datasetIndex, + // _points: dataset.metaData, + // }); + // } + // }, + + // addPoint: function addPoint(dataset, datasetIndex, index) { + // if (dataset) { + // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); + + // if (index < dataset.metaData.length) { + // dataset.metaData[index] = new Chart.Point({ + // _datasetIndex: datasetIndex, + // _index: index, + // _chart: this.chart.chart, + // _model: { + // x: 0, + // y: 0, + // }, + // }); + // } + // } + // }, + + + + // resetElements: function resetElements() { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.resetDatasetPoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (bars) + // this.resetDatasetRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { + // helpers.each(dataset.metaData, function(point, index) { + // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + // var yScalePoint; + + // if (yScale.min < 0 && yScale.max < 0) { + // // all less than 0. use the top + // yScalePoint = yScale.getPixelForValue(yScale.max); + // } else if (yScale.min > 0 && yScale.max > 0) { + // yScalePoint = yScale.getPixelForValue(yScale.min); + // } else { + // yScalePoint = yScale.getPixelForValue(0); + // } + + // helpers.extend(point, { + // // Utility + // _chart: this.chart.chart, //WTF + // _xScale: xScale, + // _yScale: yScale, + // _datasetIndex: datasetIndex, + // _index: index, + + // // Desired view properties + // _model: { + // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // y: yScalePoint, + // }, + // }); + + // this.updatePointElementAppearance(point, datasetIndex, index); + // }, this); + + // this.updateBezierControlPoints(dataset); + // }, + + // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { + + // }, + + // resetElementAppearance: function(element, datasetIndex, index) { + // if (element instanceof Chart.Point) { + // this.updatePointElementAppearance(element, datasetIndex, index); + // } else if (element instanceof Chart.Rectangle) { + // this.updateRectangleElementAppearance(element, datasetIndex, index); + // } + // }, + + // updateElements: function updateElements() { + // // Update the lines + // this.updateLines(); + + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.updatePoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (bars) + // this.updateRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + // updateLines: function updateLines() { + // this.eachLine(function(dataset, datasetIndex) { + // var yScale = this.getScaleForId(dataset.yAxisID); + // var scaleBase; + + // if (yScale.min < 0 && yScale.max < 0) { + // scaleBase = yScale.getPixelForValue(yScale.max); + // } else if (yScale.min > 0 && yScale.max > 0) { + // scaleBase = yScale.getPixelForValue(yScale.min); + // } else { + // scaleBase = yScale.getPixelForValue(0); + // } + + // helpers.extend(dataset.metaDataset, { + // // Utility + // _scale: yScale, + // _datasetIndex: datasetIndex, + // // Data + // _children: dataset.metaData, + // // Model + // _model: { + // // Appearance + // tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chart.options.elements.line.tension), + // backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chart.options.elements.line.backgroundColor), + // borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chart.options.elements.line.borderWidth), + // borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chart.options.elements.line.borderColor), + // fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chart.options.elements.line.fill), + // skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chart.options.elements.line.skipNull, + // drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chart.options.elements.line.drawNull, + // // Scale + // scaleTop: yScale.top, + // scaleBottom: yScale.bottom, + // scaleZero: scaleBase, + // }, + // }); + + // dataset.metaDataset.pivot(); + // }); + // }, + + // updatePoints: function updatePoints(dataset, datasetIndex) { + // helpers.each(dataset.metaData, function(point, index) { + // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + // helpers.extend(point, { + // // Utility + // _chart: this.chart.chart, + // _xScale: xScale, + // _yScale: yScale, + // _datasetIndex: datasetIndex, + // _index: index, + + // // Desired view properties + // _model: { + // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // y: yScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // }, + // }); + + // this.updatePointElementAppearance(point, datasetIndex, index); + // }, this); + + // this.updateBezierControlPoints(dataset); + // }, + + // updatePointElementAppearance: function updatePointElementAppearance(point, datasetIndex, index) { + // helpers.extend(point._model, { + // // Appearance + // tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + // radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), + // backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + // borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), + // borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + // skip: this.chart.data.datasets[datasetIndex].data[index] === null, + + // // Tooltip + // hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), + // }); + // }, + + + + // setElementHoverStyle: function setElementHoverStyle(element) { + // if (element instanceof Chart.Point) { + // this.setPointHoverStyle(element); + // } else if (element instanceof Chart.Rectangle) { + // this.setRectangleHoverStyle(element); + // } + // }, + + // setPointHoverStyle: function setPointHoverStyle(point) { + // var dataset = this.chart.data.datasets[point._datasetIndex]; + // var index = point._index; + + // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + // }, + + // setRectangleHoverStyle: function(rectangle) { + // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + // var index = rectangle._index; + + // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + // }, + + // updateBezierControlPoints: function updateBezierControlPoints(dataset) { + // // Update control points for the bezier curve + // helpers.each(dataset.metaData, function(point, index) { + // var controlPoints = helpers.splineCurve( + // this.previousPoint(dataset.metaData, index)._model, + // point._model, + // this.nextPoint(dataset.metaData, index)._model, + // point._model.tension + // ); + + // point._model.controlPointPreviousX = controlPoints.previous.x; + // point._model.controlPointNextX = controlPoints.next.x; + + // // Prevent the bezier going outside of the bounds of the graph + + // // Cap puter bezier handles to the upper/lower scale bounds + // if (controlPoints.next.y > this.chart.chartArea.bottom) { + // point._model.controlPointNextY = this.chart.chartArea.bottom; + // } else if (controlPoints.next.y < this.chart.chartArea.top) { + // point._model.controlPointNextY = this.chart.chartArea.top; + // } else { + // point._model.controlPointNextY = controlPoints.next.y; + // } + + // // Cap inner bezier handles to the upper/lower scale bounds + // if (controlPoints.previous.y > this.chart.chartArea.bottom) { + // point._model.controlPointPreviousY = this.chart.chartArea.bottom; + // } else if (controlPoints.previous.y < this.chart.chartArea.top) { + // point._model.controlPointPreviousY = this.chart.chartArea.top; + // } else { + // point._model.controlPointPreviousY = controlPoints.previous.y; + // } + + // // Now pivot the point for animation + // point.pivot(); + // }, this); + // }, + + // getElementsAtEvent: function(e) { + // var elementsArray = [], + // eventPosition = helpers.getRelativePosition(e), + // datasetIterator = function(dataset) { + // elementsArray.push(dataset.metaData[elementIndex]); + // }, + // elementIndex; + + // for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { + // for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { + // if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + // helpers.each(this.chart.data.datasets, datasetIterator); + // } + // } + // } + + // return elementsArray.length ? elementsArray : []; + // }, + + // // Get the single element that was clicked on + // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + // getElementAtEvent: function(e) { + // var element = []; + // var eventPosition = helpers.getRelativePosition(e); + + // for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { + // for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + // if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + // element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); + // return element; + // } + // } + // } + + // return []; + // }, + }); + + + +}).call(this); diff --git a/src/controllers/controller.canvas.rectangular.js b/src/controllers/controller.canvas.rectangular.js deleted file mode 100644 index 80da709a44e..00000000000 --- a/src/controllers/controller.canvas.rectangular.js +++ /dev/null @@ -1,9 +0,0 @@ -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - -}).call(this); diff --git a/src/controllers/controller.elements.rectangular.js b/src/controllers/controller.elements.rectangular.js deleted file mode 100644 index 469aa018874..00000000000 --- a/src/controllers/controller.elements.rectangular.js +++ /dev/null @@ -1,427 +0,0 @@ -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.RectangularElementController = function(chart) { - this.chartInstance = chart; - }; - - Chart.RectangularElementController.prototype.getScaleForId = function getScaleForId(scaleID) { - return this.chartInstance.scales[scaleID]; - }; - - // 2 helper functions to get points in collections - Chart.RectangularElementController.prototype.nextPoint = function nextPoint(collection, index) { - return collection[index + 1] || collection[index]; - }; - Chart.RectangularElementController.prototype.previousPoint = function previousPoint(collection, index) { - return collection[index - 1] || collection[index]; - }; - - Chart.RectangularElementController.prototype.eachLine = function eachLine(callback) { - helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { - if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { - callback.call(this, dataset, datasetIndex) - } - }, this); - }; - - Chart.RectangularElementController.prototype.eachRectangle = function(callback) { - helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, function(element, index) { - if (element instanceof Chart.Rectangle) { - callback(element, index, dataset, datasetIndex); - } - }, this); - }, this); - }; - - Chart.RectangularElementController.prototype.addLine = function addLine(dataset, datasetIndex) { - if (dataset) { - dataset.metaDataset = new Chart.Line({ - _chart: this.chartInstance.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - } - } - - Chart.RectangularElementController.prototype.addPoint = function addPoint(dataset, datasetIndex, index) { - if (dataset) { - dataset.metaData = dataset.metaData || new Array(this.chartInstance.data.datasets[datasetIndex].data.length); - - if (index < dataset.metaData.length) { - dataset.metaData[index] = new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chartInstance.chart, - _model: { - x: 0, - y: 0, - }, - }) - } - } - }; - - Chart.RectangularElementController.prototype.addRectangle = function(dataset, datasetIndex, index) { - if (dataset) { - dataset.metaData = dataset.metaData || new Array(this.chartInstance.data.datasets[datasetIndex].data.length); - - if (index < dataset.metaData.length) { - dataset.metaData[index] = new Chart.Rectangle({ - _chart: this.chartInstance.chart, - _datasetIndex: datasetIndex, - _index: index, - }); - } - } - }; - - Chart.RectangularElementController.prototype.resetElements = function resetElements() { - helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { - // All elements must be the same type for the given dataset so we are fine to check just the first one - if (dataset.metaData[0] instanceof Chart.Point) { - // Have points. Update all of them - this.resetDatasetPoints(dataset, datasetIndex); - } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // Have rectangles (bars) - this.resetDatasetRectangles(dataset, datasetIndex); - } - }, this); - }; - - Chart.RectangularElementController.prototype.resetDatasetPoints = function resetDatasetPoints(dataset, datasetIndex) { - helpers.each(dataset.metaData, function(point, index){ - var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); - var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chartInstance.chart, //WTF - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.chartInstance.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScalePoint, - }, - }); - - this.updatePointElementAppearance(point, datasetIndex, index); - }, this); - - this.updateBezierControlPoints(dataset); - }; - - Chart.RectangularElementController.prototype.resetDatasetRectangles = function resetDatasetRectangles(dataset, datasetIndex) { - helpers.each(dataset.metaData, function(rectangle, index) { - var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); - var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(rectangle, { - // Utility - _chart: this.chartInstance.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.chartInstance.data.datasets.length, datasetIndex, index), - y: yScalePoint, - - // Tooltip - label: this.chartInstance.data.labels[index], - datasetLabel: this.chartInstance.data.datasets[datasetIndex].label, - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.chartInstance.data.datasets.length), - }, - }); - - this.updateRectangleElementAppearance(rectangle, datasetIndex, index); - rectangle.pivot(); - }, this); - }; - - Chart.RectangularElementController.prototype.resetElementAppearance = function(element, datasetIndex, index) { - if (element instanceof Chart.Point) { - this.updatePointElementAppearance(element, datasetIndex, index); - } else if (element instanceof Chart.Rectangle) { - this.updateRectangleElementAppearance(element, datasetIndex, index); - } - }; - - Chart.RectangularElementController.prototype.updateElements = function updateElements() { - // Update the lines - this.updateLines(); - - helpers.each(this.chartInstance.data.datasets, function(dataset, datasetIndex) { - // All elements must be the same type for the given dataset so we are fine to check just the first one - if (dataset.metaData[0] instanceof Chart.Point) { - // Have points. Update all of them - this.updatePoints(dataset, datasetIndex); - } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // Have rectangles (bars) - this.updateRectangles(dataset, datasetIndex); - } - }, this); - }; - - Chart.RectangularElementController.prototype.updateLines = function updateLines() { - this.eachLine(function(dataset, datasetIndex) { - var yScale = this.getScaleForId(dataset.yAxisID); - var scaleBase; - - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chartInstance.options.elements.line.tension), - backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chartInstance.options.elements.line.backgroundColor), - borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chartInstance.options.elements.line.borderWidth), - borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chartInstance.options.elements.line.borderColor), - fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chartInstance.options.elements.line.fill), - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chartInstance.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chartInstance.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - }; - - Chart.RectangularElementController.prototype.updatePoints = function updatePoints(dataset, datasetIndex) { - helpers.each(dataset.metaData, function(point, index) { - var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); - var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); - - helpers.extend(point, { - // Utility - _chart: this.chartInstance.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.chartInstance.data.datasets[datasetIndex].data[index], index, datasetIndex), - y: yScale.getPointPixelForValue(this.chartInstance.data.datasets[datasetIndex].data[index], index, datasetIndex), - }, - }); - - this.updatePointElementAppearance(point, datasetIndex, index); - }, this); - - this.updateBezierControlPoints(dataset); - }; - - Chart.RectangularElementController.prototype.updatePointElementAppearance = function updatePointElementAppearance(point, datasetIndex, index) { - helpers.extend(point._model, { - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chartInstance.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].radius, index, this.chartInstance.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].pointBackgroundColor, index, this.chartInstance.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].pointBorderColor, index, this.chartInstance.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].pointBorderWidth, index, this.chartInstance.options.elements.point.borderWidth), - skip: this.chartInstance.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].hitRadius, index, this.chartInstance.options.elements.point.hitRadius), - }); - }; - - Chart.RectangularElementController.prototype.updateRectangles = function updateRectangles(dataset, datasetIndex) { - helpers.each(dataset.metaData, function(rectangle, index){ - var xScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].xAxisID); - var yScale = this.getScaleForId(this.chartInstance.data.datasets[datasetIndex].yAxisID); - - helpers.extend(rectangle, { - // Utility - _chart: this.chartInstance.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.chartInstance.data.datasets.length, datasetIndex, index), - y: yScale.calculateBarY(datasetIndex, index), - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.chartInstance.data.datasets.length), - - // Tooltip - label: this.chartInstance.data.labels[index], - datasetLabel: this.chartInstance.data.datasets[datasetIndex].label, - }, - }); - - this.updateRectangleElementAppearance(rectangle, datasetIndex, index); - rectangle.pivot(); - }, this); - }; - - Chart.RectangularElementController.prototype.updateRectangleElementAppearance = function updateRectangleElementAppearance(rectangle, datasetIndex, index) { - helpers.extend(rectangle._model, { - // Appearance - backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].backgroundColor, index, this.chartInstance.options.elements.rectangle.backgroundColor), - borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].borderColor, index, this.chartInstance.options.elements.rectangle.borderColor), - borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chartInstance.data.datasets[datasetIndex].borderWidth, index, this.chartInstance.options.elements.rectangle.borderWidth), - }); - }; - - Chart.RectangularElementController.prototype.setElementHoverStyle = function setElementHoverStyle(element) { - if (element instanceof Chart.Point) { - this.setPointHoverStyle(element); - } else if (element instanceof Chart.Rectangle) { - this.setRectangleHoverStyle(element); - } - }; - - Chart.RectangularElementController.prototype.setPointHoverStyle = function setPointHoverStyle(point) { - var dataset = this.chartInstance.data.datasets[point._datasetIndex]; - var index = point._index; - - point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chartInstance.options.elements.point.hoverRadius); - point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); - }; - - Chart.RectangularElementController.prototype.setRectangleHoverStyle = function(rectangle) { - var dataset = this.chartInstance.data.datasets[rectangle._datasetIndex]; - var index = rectangle._index; - - rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); - }; - - Chart.RectangularElementController.prototype.updateBezierControlPoints = function updateBezierControlPoints(dataset) { - // Update control points for the bezier curve - helpers.each(dataset.metaData, function(point, index) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset.metaData, index)._model, - point._model, - this.nextPoint(dataset.metaData, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartInstance.chartArea.bottom) { - point._model.controlPointNextY = this.chartInstance.chartArea.bottom; - } else if (controlPoints.next.y < this.chartInstance.chartArea.top) { - point._model.controlPointNextY = this.chartInstance.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartInstance.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartInstance.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartInstance.chartArea.top) { - point._model.controlPointPreviousY = this.chartInstance.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - }; - - Chart.RectangularElementController.prototype.getElementsAtEvent = function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.chartInstance.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.chartInstance.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.chartInstance.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.chartInstance.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; - }; - - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - Chart.RectangularElementController.prototype.getElementAtEvent = function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.chartInstance.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.chartInstance.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.chartInstance.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.chartInstance.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } - - return []; - }; - -}).call(this); diff --git a/src/core/core.controller.js b/src/core/core.controller.js index dd2a023405f..4c2535ddd45 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -15,22 +15,21 @@ //Destroy method on the chart will remove the instance of the chart from this reference. Chart.instances = {}; + // Controllers available for dataset visualization eg. bar, line, slice, etc. + Chart.controllers = {}; + + // The main controller of a chart Chart.Controller = function(instance) { this.chart = instance; - var config = instance.config; - this.data = config.data; - this.options = config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[config.type], config.options || {}); + this.config = instance.config; + this.data = this.config.data; + this.options = this.config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[this.config.type], this.config.options || {}); this.id = helpers.uid(); - console.log(this.options); - //Add the chart instance to the global namespace Chart.instances[this.id] = this; - // Initialize is always called when a chart type is created - // By default it is a no op, but it should be extended - if (this.options.responsive) { this.resize(); } @@ -44,12 +43,19 @@ initialize: function initialize() { + // TODO + // If BeforeInit(this) doesn't return false, proceed + this.bindEvents(); this.buildScales(); + this.buildControllers(); this.resetElements(); this.initToolTip(); this.update(); + // TODO + // If AfterInit(this) doesn't return false, proceed + return this; }, @@ -111,12 +117,30 @@ Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); }, + buildControllers: function() { + this.eachDataset(function(dataset, datasetIndex) { + var type = dataset.type || this.config.type; + if (dataset.controller) { + dataset.controller.updateIndex(datasetIndex); + return; + } + dataset.controller = new Chart.controllers[type](this, datasetIndex); + }); + }, + resetElements: function resetElements() { - // This will loop through any data and do the appropriate element reset for the type + this.eachDataset(function(dataset, datasetIndex) { + dataset.controller.reset(); + }); }, + + update: function update(animationDuration) { // This will loop through any data and do the appropriate element update for the type Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + this.eachDataset(function(dataset, datasetIndex) { + dataset.controller.update(); + }); this.render(animationDuration); }, @@ -148,6 +172,25 @@ return this; }, + draw: function(ease) { + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + // Draw each dataset via its respective controller + // TODO: needs support for reverse stacking (line chart) + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.controller.draw(ease); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + eachValue: function eachValue(callback) { helpers.each(this.data.datasets, function(dataset, datasetIndex) { helpers.each(dataset.data, callback, this, datasetIndex); @@ -164,6 +207,20 @@ helpers.each(this.data.datasets, callback, this); }, + // 2 helper functions to get next/previous elements in datasets + nextElement: function nextElement(datasets, index, loop) { + if (this.loop) { + return dataset[index + 1] || dataset[0]; + } + return datasets[index + 1] || datasets[index]; + }, + previousElement: function previousElement(datasets, index, loop) { + if (this.loop) { + return dataset[index - 1] || dataset[dataset.length - 1]; + } + return datasets[index - 1] || datasets[index]; + }, + // Get the single element that was clicked on // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw getElementAtEvent: function getElementAtEvent(e) { diff --git a/src/core/core.element.js b/src/core/core.element.js index d787a633674..bd7b8ad6be4 100644 --- a/src/core/core.element.js +++ b/src/core/core.element.js @@ -7,6 +7,7 @@ previous = root.Chart, helpers = Chart.helpers; + Chart.elements = {}; Chart.Element = function(configuration) { helpers.extend(this, configuration); diff --git a/src/core/core.js b/src/core/core.js index d8037c6111d..e64f98d2b3a 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -58,12 +58,14 @@ //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. Chart.helpers.retinaScale(this); - this.controller = new Chart.Controller(this); + if (config) { + this.controller = new Chart.Controller(this); + return this.controller; + } - return this.controller; - }; + return this; - var defaultColor = 'rgba(0,0,0,0.1)'; + }; //Globally expose the defaults to allow for user updating/changing Chart.defaults = { @@ -77,7 +79,7 @@ animationDuration: 400, }, onClick: null, - defaultColor: defaultColor, + defaultColor: 'rgba(0,0,0,0.1)', // Element defaults defined in element extensions elements: {} diff --git a/src/elements/element.rectangle.js b/src/elements/element.rectangle.js index 7c35df01d3e..f4b71a38058 100644 --- a/src/elements/element.rectangle.js +++ b/src/elements/element.rectangle.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 - */ - - (function() { "use strict"; @@ -23,7 +12,7 @@ borderColor: Chart.defaults.global.defaultColor, }; - Chart.Rectangle = Chart.Element.extend({ + Chart.elements.Rectangle = Chart.Element.extend({ draw: function() { var ctx = this._chart.ctx; @@ -92,4 +81,6 @@ }, }); + + }).call(this); From 257bdb2dbbb769da36d0703e2d3b91a920cb2bee Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 15:27:56 -0600 Subject: [PATCH 167/424] Hybrid Line and Bar chart - Line Now drawing --- Chart.js | 11026 ++++++++++++--------------- Chart.min.js | 38 +- samples/combo-bar-line.html | 63 + src/controllers/controller.bar.js | 76 +- src/controllers/controller.line.js | 371 + src/core/core.controller.js | 6 + src/core/core.helpers.js | 12 + src/elements/element.line.js | 22 +- src/elements/element.point.js | 2 +- 9 files changed, 5212 insertions(+), 6404 deletions(-) create mode 100644 samples/combo-bar-line.html create mode 100644 src/controllers/controller.line.js diff --git a/Chart.js b/Chart.js index 88b54859aed..4ab301d1518 100644 --- a/Chart.js +++ b/Chart.js @@ -11,3186 +11,4335 @@ (function() { - "use strict"; - - //Declare root variable - window in the browser, global on the server - var root = this, - previous = root.Chart; - - //Occupy the global variable of Chart, and create a simple base class - var Chart = function(context) { - var chart = this; - this.canvas = context.canvas; - - this.ctx = context; - - //Variables global to the chart - var computeDimension = function(element, dimension) { - if (element['offset' + dimension]) { - return element['offset' + dimension]; - } else { - return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); - } - }; - - var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; - var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; - - // Firefox requires this to work correctly - context.canvas.width = width; - context.canvas.height = height; - - width = this.width = context.canvas.width; - height = this.height = context.canvas.height; - this.aspectRatio = this.width / this.height; - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. - helpers.retinaScale(this); - - return this; - }; - - var defaultColor = 'rgba(0,0,0,0.1)'; - - //Globally expose the defaults to allow for user updating/changing - Chart.defaults = { - global: { - responsive: true, - maintainAspectRatio: true, - events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], - hover: { - onHover: null, - mode: 'single', - animationDuration: 400, - }, - onClick: null, - defaultColor: defaultColor, - - // Element defaults defined in element extensions - elements: {} - }, - }; - - //Create a dictionary of chart types, to allow for extension of existing types - Chart.types = {}; - - //Global Chart helpers object for utility methods and classes - var helpers = Chart.helpers = {}; - - //-- Basic js utility methods - var each = helpers.each = function(loopable, callback, self) { - var additionalArgs = Array.prototype.slice.call(arguments, 3); - // Check to see if null or undefined firstly. - if (loopable) { - if (loopable.length === +loopable.length) { - var i; - for (i = 0; i < loopable.length; i++) { - callback.apply(self, [loopable[i], i].concat(additionalArgs)); - } - } else { - for (var item in loopable) { - callback.apply(self, [loopable[item], item].concat(additionalArgs)); - } - } - } - }, - clone = helpers.clone = function(obj) { - var objClone = {}; - each(obj, function(value, key) { - if (obj.hasOwnProperty(key)) { - objClone[key] = value; - } - }); - return objClone; - }, - extend = helpers.extend = function(base) { - each(Array.prototype.slice.call(arguments, 1), function(extensionObject) { - each(extensionObject, function(value, key) { - if (extensionObject.hasOwnProperty(key)) { - base[key] = value; - } - }); - }); - return base; - }, - merge = helpers.merge = function(base, master) { - //Merge properties in left object over to a shallow clone of object right. - var args = Array.prototype.slice.call(arguments, 0); - args.unshift({}); - return extend.apply(null, args); - }, - // Need a special merge function to chart configs since they are now grouped - configMerge = helpers.configMerge = function(_base) { - var base = clone(_base); - helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { - helpers.each(extension, function(value, key) { - if (extension.hasOwnProperty(key)) { - if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { - // In this case we have an array of objects replacing another array. Rather than doing a strict replace, - // merge. This allows easy scale option merging - var baseArray = base[key]; - - helpers.each(value, function(valueObj, index) { - if (index < baseArray.length) { - baseArray[index] = helpers.configMerge(baseArray[index], valueObj); - } else { - baseArray.push(valueObj); // nothing to merge - } - }); - } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { - // If we are overwriting an object with an object, do a merge of the properties. - base[key] = helpers.configMerge(base[key], value); - } else { - // can just overwrite the value in this case - base[key] = value; - } - } - }); - }); - - return base; - }, - getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { - if (!value) { - return defaultValue; - } - - if (helpers.isArray(value) && index < value.length) { - return value[index]; - } - - return value; - }, - indexOf = helpers.indexOf = function(arrayToSearch, item) { - if (Array.prototype.indexOf) { - return arrayToSearch.indexOf(item); - } else { - for (var i = 0; i < arrayToSearch.length; i++) { - if (arrayToSearch[i] === item) return i; - } - return -1; - } - }, - where = helpers.where = function(collection, filterCallback) { - var filtered = []; - - helpers.each(collection, function(item) { - if (filterCallback(item)) { - filtered.push(item); - } - }); - - return filtered; - }, - findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { - // Default to start of the array - if (!startIndex) { - startIndex = -1; - } - for (var i = startIndex + 1; i < arrayToSearch.length; i++) { - var currentItem = arrayToSearch[i]; - if (filterCallback(currentItem)) { - return currentItem; - } - } - }, - findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { - // Default to end of the array - if (!startIndex) { - startIndex = arrayToSearch.length; - } - for (var i = startIndex - 1; i >= 0; i--) { - var currentItem = arrayToSearch[i]; - if (filterCallback(currentItem)) { - return currentItem; - } - } - }, - inherits = helpers.inherits = function(extensions) { - //Basic javascript inheritance based on the model created in Backbone.js - var parent = this; - var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() { - return parent.apply(this, arguments); - }; - - var Surrogate = function() { - this.constructor = ChartElement; - }; - Surrogate.prototype = parent.prototype; - ChartElement.prototype = new Surrogate(); - - ChartElement.extend = inherits; - - if (extensions) extend(ChartElement.prototype, extensions); - - ChartElement.__super__ = parent.prototype; - - return ChartElement; - }, - noop = helpers.noop = function() {}, - uid = helpers.uid = (function() { - var id = 0; - return function() { - return "chart-" + id++; - }; - })(), - warn = helpers.warn = function(str) { - //Method for warning of errors - if (window.console && typeof window.console.warn === "function") console.warn(str); - }, - amd = helpers.amd = (typeof define === 'function' && define.amd), - //-- Math methods - isNumber = helpers.isNumber = function(n) { - return !isNaN(parseFloat(n)) && isFinite(n); - }, - max = helpers.max = function(array) { - return Math.max.apply(Math, array); - }, - min = helpers.min = function(array) { - return Math.min.apply(Math, array); - }, - sign = helpers.sign = function(x) { - if (Math.sign) { - return Math.sign(x); - } else { - x = +x; // convert to a number - if (x === 0 || isNaN(x)) { - return x; - } - return x > 0 ? 1 : -1; - } - }, - log10 = helpers.log10 = function(x) { - if (Math.log10) { - return Math.log10(x) - } else { - return Math.log(x) / Math.LN10; - } - }, - cap = helpers.cap = function(valueToCap, maxValue, minValue) { - if (isNumber(maxValue)) { - if (valueToCap > maxValue) { - return maxValue; - } - } else if (isNumber(minValue)) { - if (valueToCap < minValue) { - return minValue; - } - } - return valueToCap; - }, - getDecimalPlaces = helpers.getDecimalPlaces = function(num) { - if (num % 1 !== 0 && isNumber(num)) { - var s = num.toString(); - if (s.indexOf("e-") < 0) { - // no exponent, e.g. 0.01 - return s.split(".")[1].length; - } else if (s.indexOf(".") < 0) { - // no decimal point, e.g. 1e-9 - return parseInt(s.split("e-")[1]); - } else { - // exponent and decimal point, e.g. 1.23e-9 - var parts = s.split(".")[1].split("e-"); - return parts[0].length + parseInt(parts[1]); - } - } else { - return 0; - } - }, - toRadians = helpers.toRadians = function(degrees) { - return degrees * (Math.PI / 180); - }, - toDegrees = helpers.toDegrees = function(radians) { - return radians * (180 / Math.PI); - }, - // Gets the angle from vertical upright to the point about a centre. - getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { - var distanceFromXCenter = anglePoint.x - centrePoint.x, - distanceFromYCenter = anglePoint.y - centrePoint.y, - radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); - - var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); - - if (angle < (-0.5 * Math.PI)) { - angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2] - } - - return { - angle: angle, - distance: radialDistanceFromCenter - }; - }, - aliasPixel = helpers.aliasPixel = function(pixelWidth) { - return (pixelWidth % 2 === 0) ? 0 : 0.5; - }, - splineCurve = helpers.splineCurve = function(FirstPoint, MiddlePoint, AfterPoint, t) { - //Props to Rob Spencer at scaled innovation for his post on splining between points - //http://scaledinnovation.com/analytics/splines/aboutSplines.html - var d01 = Math.sqrt(Math.pow(MiddlePoint.x - FirstPoint.x, 2) + Math.pow(MiddlePoint.y - FirstPoint.y, 2)), - d12 = Math.sqrt(Math.pow(AfterPoint.x - MiddlePoint.x, 2) + Math.pow(AfterPoint.y - MiddlePoint.y, 2)), - fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta - fb = t * d12 / (d01 + d12); - return { - previous: { - x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), - y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) - }, - next: { - x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), - y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) - } - }; - }, - calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { - return Math.floor(Math.log(val) / Math.LN10); - }, - calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { - - //Set a minimum step of two - a point at the top of the graph, and a point at the base - var minSteps = 2, - maxSteps = Math.floor(drawingSize / (textSize * 1.5)), - skipFitting = (minSteps >= maxSteps); - - var maxValue = max(valuesArray), - minValue = min(valuesArray); - - // We need some degree of seperation here to calculate the scales if all the values are the same - // Adding/minusing 0.5 will give us a range of 1. - if (maxValue === minValue) { - maxValue += 0.5; - // So we don't end up with a graph with a negative start value if we've said always start from zero - if (minValue >= 0.5 && !startFromZero) { - minValue -= 0.5; - } else { - // Make up a whole number above the values - maxValue += 0.5; - } - } - - var valueRange = Math.abs(maxValue - minValue), - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphRange = graphMax - graphMin, - stepValue = Math.pow(10, rangeOrderOfMagnitude), - numberOfSteps = Math.round(graphRange / stepValue); - - //If we have more space on the graph we'll use it to give more definition to the data - while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { - if (numberOfSteps > maxSteps) { - stepValue *= 2; - numberOfSteps = Math.round(graphRange / stepValue); - // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. - if (numberOfSteps % 1 !== 0) { - skipFitting = true; - } - } - //We can fit in double the amount of scale points on the scale - else { - //If user has declared ints only, and the step value isn't a decimal - if (integersOnly && rangeOrderOfMagnitude >= 0) { - //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float - if (stepValue / 2 % 1 === 0) { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - //If it would make it a float break out of the loop - else { - break; - } - } - //If the scale doesn't have to be an int, make the scale more granular anyway. - else { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - - } - } - - if (skipFitting) { - numberOfSteps = minSteps; - stepValue = graphRange / numberOfSteps; - } - return { - steps: numberOfSteps, - stepValue: stepValue, - min: graphMin, - max: graphMin + (numberOfSteps * stepValue) - }; - - }, - // Implementation of the nice number algorithm used in determining where axis labels will go - niceNum = helpers.niceNum = function(range, round) { - var exponent = Math.floor(helpers.log10(range)); - var fraction = range / Math.pow(10, exponent); - var niceFraction; - - if (round) { - if (fraction < 1.5) { - niceFraction = 1; - } else if (fraction < 3) { - niceFraction = 2; - } else if (fraction < 7) { - niceFraction = 5; - } else { - niceFraction = 10; - } - } else { - if (fraction <= 1.0) { - niceFraction = 1; - } else if (fraction <= 2) { - niceFraction = 2; - } else if (fraction <= 5) { - niceFraction = 5; - } else { - niceFraction = 10; - } - } - - return niceFraction * Math.pow(10, exponent); - }, - /* jshint ignore:start */ - // Blows up jshint errors based on the new Function constructor - //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 instanceof Function) { - return templateString(valuesObject); - } - - var cache = {}; - - function tmpl(str, data) { - // Figure out if we're getting a template, or if we need to - // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] : - - // Generate a reusable function that will serve as a template - // generator (and which will be cached). - new Function("obj", - "var p=[],print=function(){p.push.apply(p,arguments);};" + - - // Introduce the data as local variables using with(){} - "with(obj){p.push('" + - - // Convert the template into pure JavaScript - str - .replace(/[\r\t\n]/g, " ") - .split("<%").join("\t") - .replace(/((^|%>)[^\t]*)'/g, "$1\r") - .replace(/\t=(.*?)%>/g, "',$1,'") - .split("\t").join("');") - .split("%>").join("p.push('") - .split("\r").join("\\'") + - "');}return p.join('');" - ); - - // Provide some basic currying to the user - return data ? fn(data) : fn; - } - return tmpl(templateString, valuesObject); - }, - /* jshint ignore:end */ - generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { - var labelsArray = new Array(numberOfSteps); - if (templateString) { - each(labelsArray, function(val, index) { - labelsArray[index] = template(templateString, { - value: (graphMin + (stepValue * (index + 1))) - }); - }); - } - return labelsArray; - }, - //--Animation methods - //Easing functions adapted from Robert Penner's easing equations - //http://www.robertpenner.com/easing/ - easingEffects = helpers.easingEffects = { - linear: function(t) { - return t; - }, - easeInQuad: function(t) { - return t * t; - }, - easeOutQuad: function(t) { - return -1 * t * (t - 2); - }, - easeInOutQuad: function(t) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t; - } - return -1 / 2 * ((--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) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t * t; - } - return 1 / 2 * ((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) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t * t * t; - } - return -1 / 2 * ((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) { - if ((t /= 1 / 2) < 1) { - return 1 / 2 * t * t * t * t * t; - } - return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); - }, - easeInExpo: function(t) { - return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); - }, - easeOutExpo: function(t) { - return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); - }, - easeInOutExpo: function(t) { - if (t === 0) { - return 0; - } - if (t === 1) { - return 1; - } - if ((t /= 1 / 2) < 1) { - return 1 / 2 * Math.pow(2, 10 * (t - 1)); - } - return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); - }, - easeInCirc: function(t) { - if (t >= 1) { - return t; - } - return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); - }, - easeOutCirc: function(t) { - return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); - }, - easeInOutCirc: function(t) { - if ((t /= 1 / 2) < 1) { - return -1 / 2 * (Math.sqrt(1 - t * t) - 1); - } - return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); - }, - easeInElastic: function(t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0) { - return 0; - } - if ((t /= 1) == 1) { - return 1; - } - if (!p) { - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); - }, - easeOutElastic: function(t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0) { - return 0; - } - if ((t /= 1) == 1) { - return 1; - } - if (!p) { - p = 1 * 0.3; - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; - }, - easeInOutElastic: function(t) { - var s = 1.70158; - var p = 0; - var a = 1; - if (t === 0) { - return 0; - } - if ((t /= 1 / 2) == 2) { - return 1; - } - if (!p) { - p = 1 * (0.3 * 1.5); - } - if (a < Math.abs(1)) { - a = 1; - s = p / 4; - } else { - s = p / (2 * Math.PI) * Math.asin(1 / a); - } - if (t < 1) { - return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); - } - return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; - }, - easeInBack: function(t) { - var s = 1.70158; - return 1 * (t /= 1) * t * ((s + 1) * t - s); - }, - easeOutBack: function(t) { - var s = 1.70158; - return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); - }, - easeInOutBack: function(t) { - var s = 1.70158; - if ((t /= 1 / 2) < 1) { - return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); - } - return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); - }, - easeInBounce: function(t) { - return 1 - easingEffects.easeOutBounce(1 - t); - }, - easeOutBounce: function(t) { - if ((t /= 1) < (1 / 2.75)) { - return 1 * (7.5625 * t * t); - } else if (t < (2 / 2.75)) { - return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); - } else if (t < (2.5 / 2.75)) { - return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); - } else { - return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); - } - }, - easeInOutBounce: function(t) { - if (t < 1 / 2) { - return easingEffects.easeInBounce(t * 2) * 0.5; - } - return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; - } - }, - //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ - requestAnimFrame = helpers.requestAnimFrame = (function() { - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - return window.setTimeout(callback, 1000 / 60); - }; - })(), - cancelAnimFrame = helpers.cancelAnimFrame = (function() { - return window.cancelAnimationFrame || - window.webkitCancelAnimationFrame || - window.mozCancelAnimationFrame || - window.oCancelAnimationFrame || - window.msCancelAnimationFrame || - function(callback) { - return window.clearTimeout(callback, 1000 / 60); - }; - })(), - animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { - - var currentStep = 0, - easingFunction = easingEffects[easingString] || easingEffects.linear; - - var animationFrame = function() { - currentStep++; - var stepDecimal = currentStep / totalSteps; - var easeDecimal = easingFunction(stepDecimal); - - callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); - onProgress.call(chartInstance, easeDecimal, stepDecimal); - if (currentStep < totalSteps) { - chartInstance.animationFrame = requestAnimFrame(animationFrame); - } else { - onComplete.apply(chartInstance); - } - }; - requestAnimFrame(animationFrame); - }, - //-- DOM methods - getRelativePosition = helpers.getRelativePosition = function(evt) { - var mouseX, mouseY; - var e = evt.originalEvent || evt, - canvas = evt.currentTarget || evt.srcElement, - boundingRect = canvas.getBoundingClientRect(); - - if (e.touches) { - mouseX = e.touches[0].clientX - boundingRect.left; - mouseY = e.touches[0].clientY - boundingRect.top; - - } else { - mouseX = e.clientX - boundingRect.left; - mouseY = e.clientY - boundingRect.top; - } - - return { - x: mouseX, - y: mouseY - }; - - }, - addEvent = helpers.addEvent = function(node, eventType, method) { - if (node.addEventListener) { - node.addEventListener(eventType, method); - } else if (node.attachEvent) { - node.attachEvent("on" + eventType, method); - } else { - node["on" + eventType] = method; - } - }, - removeEvent = helpers.removeEvent = function(node, eventType, handler) { - if (node.removeEventListener) { - node.removeEventListener(eventType, handler, false); - } else if (node.detachEvent) { - node.detachEvent("on" + eventType, handler); - } else { - node["on" + eventType] = noop; - } - }, - bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) { - // Create the events object if it's not already present - if (!chartInstance.events) chartInstance.events = {}; - - each(arrayOfEvents, function(eventName) { - chartInstance.events[eventName] = function() { - handler.apply(chartInstance, arguments); - }; - addEvent(chartInstance.chart.canvas, eventName, chartInstance.events[eventName]); - }); - }, - unbindEvents = helpers.unbindEvents = function(chartInstance, arrayOfEvents) { - each(arrayOfEvents, function(handler, eventName) { - removeEvent(chartInstance.chart.canvas, eventName, handler); - }); - }, - getMaximumWidth = helpers.getMaximumWidth = function(domNode) { - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); - // TODO = check cross browser stuff with this. - return container.clientWidth - padding; - }, - getMaximumHeight = helpers.getMaximumHeight = function(domNode) { - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); - // TODO = check cross browser stuff with this. - return container.clientHeight - padding; - }, - getStyle = helpers.getStyle = function(el, property) { - return el.currentStyle ? - el.currentStyle[property] : - document.defaultView.getComputedStyle(el, null).getPropertyValue(property); - }, - getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support - retinaScale = helpers.retinaScale = function(chart) { - var ctx = chart.ctx, - width = chart.canvas.width, - height = chart.canvas.height; - - if (window.devicePixelRatio) { - ctx.canvas.style.width = width + "px"; - ctx.canvas.style.height = height + "px"; - ctx.canvas.height = height * window.devicePixelRatio; - ctx.canvas.width = width * window.devicePixelRatio; - ctx.scale(window.devicePixelRatio, window.devicePixelRatio); - } - }, - //-- Canvas methods - clear = helpers.clear = function(chart) { - chart.ctx.clearRect(0, 0, chart.width, chart.height); - }, - fontString = helpers.fontString = function(pixelSize, fontStyle, fontFamily) { - return fontStyle + " " + pixelSize + "px " + fontFamily; - }, - longestText = helpers.longestText = function(ctx, font, arrayOfStrings) { - ctx.font = font; - var longest = 0; - each(arrayOfStrings, function(string) { - var textWidth = ctx.measureText(string).width; - longest = (textWidth > longest) ? textWidth : longest; - }); - return longest; - }, - drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx, x, y, width, height, radius) { - ctx.beginPath(); - ctx.moveTo(x + radius, y); - ctx.lineTo(x + width - radius, y); - ctx.quadraticCurveTo(x + width, y, x + width, y + radius); - ctx.lineTo(x + width, y + height - radius); - ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); - ctx.lineTo(x + radius, y + height); - ctx.quadraticCurveTo(x, y + height, x, y + height - radius); - ctx.lineTo(x, y + radius); - ctx.quadraticCurveTo(x, y, x + radius, y); - ctx.closePath(); - }, - color = helpers.color = function(color) { - if (!window.Color) { - console.log('Color.js not found!'); - return color; - } - return window.Color(color); - }, - isArray = helpers.isArray = function(obj) { - if (!Array.isArray) { - return Object.prototype.toString.call(arg) === '[object Array]'; - } - return Array.isArray(obj); - }; - - //Store a reference to each instance - allowing us to globally resize chart instances on window resize. - //Destroy method on the chart will remove the instance of the chart from this reference. - Chart.instances = {}; - - Chart.Type = function(config, instance) { - this.data = config.data; - this.options = config.options; - this.chart = instance; - this.id = uid(); - //Add the chart instance to the global namespace - Chart.instances[this.id] = this; - - // Initialize is always called when a chart type is created - // By default it is a no op, but it should be extended - if (this.options.responsive) { - this.resize(); - } - this.initialize.call(this); - }; - - //Core methods that'll be a part of every chart type - extend(Chart.Type.prototype, { - initialize: function() { - return this; - }, - clear: function() { - clear(this.chart); - return this; - }, - stop: function() { - // Stops any current animation loop occuring - Chart.animationService.cancelAnimation(this); - return this; - }, - resize: function() { - this.stop(); - var canvas = this.chart.canvas, - newWidth = getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); - - canvas.width = this.chart.width = newWidth; - canvas.height = this.chart.height = newHeight; - - retinaScale(this.chart); - - return this; - }, - redraw: noop, - render: function(duration) { - - if (this.options.animation.duration !== 0 || duration) { - var animation = new Chart.Animation(); - animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps - animation.easing = this.options.animation.easing; - - // render function - animation.render = function(chartInstance, animationObject) { - var easingFunction = helpers.easingEffects[animationObject.easing]; - var stepDecimal = animationObject.currentStep / animationObject.numSteps; - var easeDecimal = easingFunction(stepDecimal); - - chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); - }; - - // user events - animation.onAnimationProgress = this.options.onAnimationProgress; - animation.onAnimationComplete = this.options.onAnimationComplete; - - Chart.animationService.addAnimation(this, animation, duration); - } else { - this.draw(); - this.options.onAnimationComplete.call(this); - } - return this; - }, - eachElement: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - }, this); - }, - eachValue: function(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, callback, this, datasetIndex); - }, this); - }, - eachDataset: function(callback) { - helpers.each(this.data.datasets, callback, this); - }, - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; - }, - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } - - return []; - }, - generateLegend: function() { - return template(this.options.legendTemplate, this); - }, - 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]; - }, - toBase64Image: function() { - return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); - } - }); - - Chart.Type.extend = function(extensions) { - - var parent = this; - - var ChartType = function() { - return parent.apply(this, arguments); - }; - - //Copy the prototype object of the this class - ChartType.prototype = clone(parent.prototype); - //Now overwrite some of the properties in the base class with the new extensions - extend(ChartType.prototype, extensions); - - ChartType.extend = Chart.Type.extend; - - if (extensions.name || parent.prototype.name) { - - var chartName = extensions.name || parent.prototype.name; - //Assign any potential default values of the new chart type - - //If none are defined, we'll use a clone of the chart type this is being extended from. - //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart - //doesn't define some defaults of their own. - - var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {}; - - Chart.defaults[chartName] = helpers.configMerge(baseDefaults, extensions.defaults); - - Chart.types[chartName] = ChartType; - - //Register this new chart type in the Chart prototype - Chart.prototype[chartName] = function(config) { - config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[chartName], config.options || {}); - return new ChartType(config, this); - }; - } else { - warn("Name not provided for this chart, so it hasn't been registered"); - } - return parent; - }; - - Chart.Element = function(configuration) { - extend(this, configuration); - this.initialize.apply(this, arguments); - }; - extend(Chart.Element.prototype, { - initialize: function() {}, - pivot: function() { - if (!this._view) { - this._view = clone(this._model); - } - this._start = clone(this._view); - return this; - }, - transition: function(ease) { - if (!this._view) { - this._view = clone(this._model); - } - if (!this._start) { - this.pivot(); - } - - each(this._model, function(value, key) { - - if (key[0] === '_' || !this._model.hasOwnProperty(key)) { - // Only non-underscored properties - } - - // Init if doesn't exist - else if (!this._view[key]) { - if (typeof value === 'number') { - this._view[key] = value * ease; - } else { - this._view[key] = value || null; - } - } - - // No unnecessary computations - else if (this._model[key] === this._view[key]) { - // It's the same! Woohoo! - } - - // Color transitions if possible - else if (typeof value === 'string') { - try { - var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); - this._view[key] = color.rgbString(); - } catch (err) { - this._view[key] = value; - } - } - // Number transitions - else if (typeof value === 'number') { - var startVal = this._start[key] !== undefined ? this._start[key] : 0; - this._view[key] = ((this._model[key] - startVal) * ease) + startVal; - } - // Everything else - else { - this._view[key] = value; - } - - }, this); - - if (ease === 1) { - delete this._start; - } - return this; - }, - tooltipPosition: function() { - return { - x: this._model.x, - y: this._model.y - }; - }, - hasValue: function() { - return isNumber(this._model.x) && isNumber(this._model.y); - } - }); - - Chart.Element.extend = inherits; - - - // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function() { - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function() { - clearTimeout(timeout); - timeout = setTimeout(function() { - each(Chart.instances, function(instance) { - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive) { - instance.resize(); - instance.update(); - instance.render(); - } - }); - }, 50); - }; - })()); - - - if (amd) { - define(function() { - return Chart; - }); - } else if (typeof module === 'object' && module.exports) { - module.exports = Chart; - } - - root.Chart = Chart; - - Chart.noConflict = function() { - root.Chart = previous; - return Chart; - }; + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart; + + //Occupy the global variable of Chart, and create a simple base class + var Chart = function(context, config) { + var chart = this; + this.config = config; + + // Support a jQuery'd canvas element + if (context.length && context[0].getContext) { + context = context[0]; + } + + // Support a canvas domnode + if (context.getContext) { + context = context.getContext("2d"); + } + + this.canvas = context.canvas; + + this.ctx = context; + + //Variables global to the chart + var computeDimension = function(element, dimension) { + if (element['offset' + dimension]) { + return element['offset' + dimension]; + } else { + return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); + } + }; + + var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; + var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; + + // Firefox requires this to work correctly + context.canvas.width = width; + context.canvas.height = height; + + width = this.width = context.canvas.width; + height = this.height = context.canvas.height; + this.aspectRatio = this.width / this.height; + //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. + Chart.helpers.retinaScale(this); + + if (config) { + this.controller = new Chart.Controller(this); + return this.controller; + } + + return this; + + }; + + //Globally expose the defaults to allow for user updating/changing + Chart.defaults = { + global: { + responsive: true, + maintainAspectRatio: true, + events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], + hover: { + onHover: null, + mode: 'single', + animationDuration: 400, + }, + onClick: null, + defaultColor: 'rgba(0,0,0,0.1)', + + // Element defaults defined in element extensions + elements: {} + }, + }; + + if (typeof amd !== 'undefined') { + define(function() { + return Chart; + }); + } else if (typeof module === 'object' && module.exports) { + module.exports = Chart; + } + + root.Chart = Chart; + + Chart.noConflict = function() { + root.Chart = previous; + return Chart; + }; }).call(this); -/*! - * Chart.js - * http://chartjs.org/ - * Version: 2.0.0-alpha - * - * Copyright 2015 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ - - (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.animation = { - duration: 1000, - easing: "easeOutQuart", - onProgress: function() {}, - onComplete: function() {}, - }; - - Chart.Animation = Chart.Element.extend({ - currentStep: null, // the current animation step - numSteps: 60, // default number of steps - easing: "", // the easing to use for this animation - render: null, // render function used by the animation service - - onAnimationProgress: null, // user specified callback to fire on each step of the animation - onAnimationComplete: null, // user specified callback to fire when the animation finishes - }); - - Chart.animationService = { - frameDuration: 17, - animations: [], - dropFrames: 0, - addAnimation: function(chartInstance, animationObject, duration) { - - if (!duration) { - chartInstance.animating = true; - } - - for (var index = 0; index < this.animations.length; ++index) { - if (this.animations[index].chartInstance === chartInstance) { - // replacing an in progress animation - this.animations[index].animationObject = animationObject; - return; - } - } - - this.animations.push({ - chartInstance: chartInstance, - animationObject: animationObject - }); - - // If there are no animations queued, manually kickstart a digest, for lack of a better word - if (this.animations.length == 1) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - }, - // Cancel the animation for a given chart instance - cancelAnimation: function(chartInstance) { - var index = helpers.findNextWhere(this.animations, function(animationWrapper) { - return animationWrapper.chartInstance === chartInstance; - }); - - if (index) { - this.animations.splice(index, 1); - chartInstance.animating = false; - } - }, - // calls startDigest with the proper context - digestWrapper: function() { - Chart.animationService.startDigest.call(Chart.animationService); - }, - startDigest: function() { - - var startTime = Date.now(); - var framesToDrop = 0; - - if (this.dropFrames > 1) { - framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; - } - - for (var i = 0; i < this.animations.length; i++) { - - if (this.animations[i].animationObject.currentStep === null) { - this.animations[i].animationObject.currentStep = 0; - } - - this.animations[i].animationObject.currentStep += 1 + framesToDrop; - if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { - this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; - } - - this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); - - if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { - // executed the last frame. Remove the animation. - this.animations[i].chartInstance.animating = false; - this.animations.splice(i, 1); - // Keep the index in place to offset the splice - i--; - } - } - - var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; - - if (frameDelay > 1) { - this.dropFrames += frameDelay; - } - - // Do we have more stuff to animate? - if (this.animations.length > 0) { - helpers.requestAnimFrame.call(window, this.digestWrapper); - } - } - }; + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart; + + //Global Chart helpers object for utility methods and classes + var helpers = Chart.helpers = {}; + + //-- Basic js utility methods + var each = helpers.each = function(loopable, callback, self) { + var additionalArgs = Array.prototype.slice.call(arguments, 3); + // Check to see if null or undefined firstly. + if (loopable) { + if (loopable.length === +loopable.length) { + var i; + for (i = 0; i < loopable.length; i++) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } + } else { + for (var item in loopable) { + callback.apply(self, [loopable[item], item].concat(additionalArgs)); + } + } + } + }, + clone = helpers.clone = function(obj) { + var objClone = {}; + each(obj, function(value, key) { + if (obj.hasOwnProperty(key)) { + if (helpers.isArray(value)) { + objClone[key] = value.slice(0); + } else if (typeof value === 'object' && value !== null) { + objClone[key] = clone(value); + } else { + objClone[key] = value; + } + } + }); + return objClone; + }, + extend = helpers.extend = function(base) { + each(Array.prototype.slice.call(arguments, 1), function(extensionObject) { + each(extensionObject, function(value, key) { + if (extensionObject.hasOwnProperty(key)) { + base[key] = value; + } + }); + }); + return base; + }, + merge = helpers.merge = function(base, master) { + //Merge properties in left object over to a shallow clone of object right. + var args = Array.prototype.slice.call(arguments, 0); + args.unshift({}); + return extend.apply(null, args); + }, + // Need a special merge function to chart configs since they are now grouped + configMerge = helpers.configMerge = function(_base) { + var base = clone(_base); + helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) { + helpers.each(extension, function(value, key) { + if (extension.hasOwnProperty(key)) { + if (key === 'scales') { + // Scale config merging is complex. Add out own function here for that + base[key] = helpers.scaleMerge(base.hasOwnProperty(key) ? base[key] : {}, value); + + } else if (key === 'scale') { + // Used in polar area & radar charts since there is only one scale + base[key] = helpers.configMerge(base.hasOwnProperty(key) ? base[key] : {}, Chart.scaleService.getScaleDefaults(value.type), value); + } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) { + // In this case we have an array of objects replacing another array. Rather than doing a strict replace, + // merge. This allows easy scale option merging + var baseArray = base[key]; + + helpers.each(value, function(valueObj, index) { + + if (index < baseArray.length) { + baseArray[index] = helpers.configMerge(baseArray[index], valueObj); + } else { + baseArray.push(valueObj); // nothing to merge + } + }); + + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { + // If we are overwriting an object with an object, do a merge of the properties. + base[key] = helpers.configMerge(base[key], value); + + } else { + // can just overwrite the value in this case + base[key] = value; + } + } + }); + }); + + return base; + }, + scaleMerge = helpers.scaleMerge = function(_base, extension) { + var base = clone(_base); + + helpers.each(extension, function(value, key) { + if (extension.hasOwnProperty(key)) { + if (key === 'xAxes' || key === 'yAxes') { + // These properties are arrays of items + if (base.hasOwnProperty(key)) { + helpers.each(value, function(valueObj, index) { + if (index >= base[key].length || !base[key][index].type) { + base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj)); + } else if (valueObj.type !== base[key][index].type) { + // Type changed. Bring in the new defaults before we bring in valueObj so that valueObj can override the correct scale defaults + base[key][index] = helpers.configMerge(base[key][index], valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj) + } else { + // Type is the same + base[key][index] = helpers.configMerge(base[key][index], valueObj); + } + }); + } else { + base[key] = []; + helpers.each(value, function(valueObj) { + base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj)); + }); + } + } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") { + // If we are overwriting an object with an object, do a merge of the properties. + base[key] = helpers.configMerge(base[key], value); + + } else { + // can just overwrite the value in this case + base[key] = value; + } + } + }); + + return base; + }, + getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { + if (!value) { + return defaultValue; + } + + if (helpers.isArray(value) && index < value.length) { + return value[index]; + } + + return value; + }, + indexOf = helpers.indexOf = function(arrayToSearch, item) { + if (Array.prototype.indexOf) { + return arrayToSearch.indexOf(item); + } else { + for (var i = 0; i < arrayToSearch.length; i++) { + if (arrayToSearch[i] === item) return i; + } + return -1; + } + }, + where = helpers.where = function(collection, filterCallback) { + var filtered = []; + + helpers.each(collection, function(item) { + if (filterCallback(item)) { + filtered.push(item); + } + }); + + return filtered; + }, + findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to start of the array + if (!startIndex) { + startIndex = -1; + } + for (var i = startIndex + 1; i < arrayToSearch.length; i++) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { + // Default to end of the array + if (!startIndex) { + startIndex = arrayToSearch.length; + } + for (var i = startIndex - 1; i >= 0; i--) { + var currentItem = arrayToSearch[i]; + if (filterCallback(currentItem)) { + return currentItem; + } + } + }, + inherits = helpers.inherits = function(extensions) { + //Basic javascript inheritance based on the model created in Backbone.js + var parent = this; + var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() { + return parent.apply(this, arguments); + }; + + var Surrogate = function() { + this.constructor = ChartElement; + }; + Surrogate.prototype = parent.prototype; + ChartElement.prototype = new Surrogate(); + + ChartElement.extend = inherits; + + if (extensions) extend(ChartElement.prototype, extensions); + + ChartElement.__super__ = parent.prototype; + + return ChartElement; + }, + noop = helpers.noop = function() {}, + uid = helpers.uid = (function() { + var id = 0; + return function() { + return "chart-" + id++; + }; + })(), + warn = helpers.warn = function(str) { + //Method for warning of errors + if (window.console && typeof window.console.warn === "function") console.warn(str); + }, + amd = helpers.amd = (typeof define === 'function' && define.amd), + //-- Math methods + isNumber = helpers.isNumber = function(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + }, + max = helpers.max = function(array) { + return Math.max.apply(Math, array); + }, + min = helpers.min = function(array) { + return Math.min.apply(Math, array); + }, + sign = helpers.sign = function(x) { + if (Math.sign) { + return Math.sign(x); + } else { + x = +x; // convert to a number + if (x === 0 || isNaN(x)) { + return x; + } + return x > 0 ? 1 : -1; + } + }, + log10 = helpers.log10 = function(x) { + if (Math.log10) { + return Math.log10(x) + } else { + return Math.log(x) / Math.LN10; + } + }, + cap = helpers.cap = function(valueToCap, maxValue, minValue) { + if (isNumber(maxValue)) { + if (valueToCap > maxValue) { + return maxValue; + } + } else if (isNumber(minValue)) { + if (valueToCap < minValue) { + return minValue; + } + } + return valueToCap; + }, + getDecimalPlaces = helpers.getDecimalPlaces = function(num) { + if (num % 1 !== 0 && isNumber(num)) { + var s = num.toString(); + if (s.indexOf("e-") < 0) { + // no exponent, e.g. 0.01 + return s.split(".")[1].length; + } else if (s.indexOf(".") < 0) { + // no decimal point, e.g. 1e-9 + return parseInt(s.split("e-")[1]); + } else { + // exponent and decimal point, e.g. 1.23e-9 + var parts = s.split(".")[1].split("e-"); + return parts[0].length + parseInt(parts[1]); + } + } else { + return 0; + } + }, + toRadians = helpers.toRadians = function(degrees) { + return degrees * (Math.PI / 180); + }, + toDegrees = helpers.toDegrees = function(radians) { + return radians * (180 / Math.PI); + }, + // Gets the angle from vertical upright to the point about a centre. + getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) { + var distanceFromXCenter = anglePoint.x - centrePoint.x, + distanceFromYCenter = anglePoint.y - centrePoint.y, + radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + + var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); + + if (angle < (-0.5 * Math.PI)) { + angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2] + } + + return { + angle: angle, + distance: radialDistanceFromCenter + }; + }, + aliasPixel = helpers.aliasPixel = function(pixelWidth) { + return (pixelWidth % 2 === 0) ? 0 : 0.5; + }, + splineCurve = helpers.splineCurve = function(FirstPoint, MiddlePoint, AfterPoint, t) { + //Props to Rob Spencer at scaled innovation for his post on splining between points + //http://scaledinnovation.com/analytics/splines/aboutSplines.html + var d01 = Math.sqrt(Math.pow(MiddlePoint.x - FirstPoint.x, 2) + Math.pow(MiddlePoint.y - FirstPoint.y, 2)), + d12 = Math.sqrt(Math.pow(AfterPoint.x - MiddlePoint.x, 2) + Math.pow(AfterPoint.y - MiddlePoint.y, 2)), + fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta + fb = t * d12 / (d01 + d12); + return { + previous: { + x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y) + }, + next: { + x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x), + y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y) + } + }; + }, + nextItem = helpers.nextItem = function(collection, index, loop) { + if (loop) { + return collection[index + 1] || collection[0]; + } + return collection[index + 1] || collection[collection.length - 1]; + }, + previousItem = helpers.previousItem = function(collection, index, loop) { + if (loop) { + return collection[index - 1] || collection[collection.length - 1]; + } + return collection[index - 1] || collection[0]; + }, + calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { + return Math.floor(Math.log(val) / Math.LN10); + }, + calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { + + //Set a minimum step of two - a point at the top of the graph, and a point at the base + var minSteps = 2, + maxSteps = Math.floor(drawingSize / (textSize * 1.5)), + skipFitting = (minSteps >= maxSteps); + + var maxValue = max(valuesArray), + minValue = min(valuesArray); + + // We need some degree of seperation here to calculate the scales if all the values are the same + // Adding/minusing 0.5 will give us a range of 1. + if (maxValue === minValue) { + maxValue += 0.5; + // So we don't end up with a graph with a negative start value if we've said always start from zero + if (minValue >= 0.5 && !startFromZero) { + minValue -= 0.5; + } else { + // Make up a whole number above the values + maxValue += 0.5; + } + } + + var valueRange = Math.abs(maxValue - minValue), + rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), + graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), + graphRange = graphMax - graphMin, + stepValue = Math.pow(10, rangeOrderOfMagnitude), + numberOfSteps = Math.round(graphRange / stepValue); + + //If we have more space on the graph we'll use it to give more definition to the data + while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { + if (numberOfSteps > maxSteps) { + stepValue *= 2; + numberOfSteps = Math.round(graphRange / stepValue); + // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. + if (numberOfSteps % 1 !== 0) { + skipFitting = true; + } + } + //We can fit in double the amount of scale points on the scale + else { + //If user has declared ints only, and the step value isn't a decimal + if (integersOnly && rangeOrderOfMagnitude >= 0) { + //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float + if (stepValue / 2 % 1 === 0) { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + //If it would make it a float break out of the loop + else { + break; + } + } + //If the scale doesn't have to be an int, make the scale more granular anyway. + else { + stepValue /= 2; + numberOfSteps = Math.round(graphRange / stepValue); + } + + } + } + + if (skipFitting) { + numberOfSteps = minSteps; + stepValue = graphRange / numberOfSteps; + } + return { + steps: numberOfSteps, + stepValue: stepValue, + min: graphMin, + max: graphMin + (numberOfSteps * stepValue) + }; + + }, + // Implementation of the nice number algorithm used in determining where axis labels will go + niceNum = helpers.niceNum = function(range, round) { + var exponent = Math.floor(helpers.log10(range)); + var fraction = range / Math.pow(10, exponent); + var niceFraction; + + if (round) { + if (fraction < 1.5) { + niceFraction = 1; + } else if (fraction < 3) { + niceFraction = 2; + } else if (fraction < 7) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } else { + if (fraction <= 1.0) { + niceFraction = 1; + } else if (fraction <= 2) { + niceFraction = 2; + } else if (fraction <= 5) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } + + return niceFraction * Math.pow(10, exponent); + }, + /* jshint ignore:start */ + // Blows up jshint errors based on the new Function constructor + //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 instanceof Function) { + return templateString(valuesObject); + } + + var cache = {}; + + function tmpl(str, data) { + // Figure out if we're getting a template, or if we need to + // load the template - and be sure to cache the result. + var fn = !/\W/.test(str) ? + cache[str] = cache[str] : + + // Generate a reusable function that will serve as a template + // generator (and which will be cached). + new Function("obj", + "var p=[],print=function(){p.push.apply(p,arguments);};" + + + // Introduce the data as local variables using with(){} + "with(obj){p.push('" + + + // Convert the template into pure JavaScript + str + .replace(/[\r\t\n]/g, " ") + .split("<%").join("\t") + .replace(/((^|%>)[^\t]*)'/g, "$1\r") + .replace(/\t=(.*?)%>/g, "',$1,'") + .split("\t").join("');") + .split("%>").join("p.push('") + .split("\r").join("\\'") + + "');}return p.join('');" + ); + + // Provide some basic currying to the user + return data ? fn(data) : fn; + } + return tmpl(templateString, valuesObject); + }, + /* jshint ignore:end */ + generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { + var labelsArray = new Array(numberOfSteps); + if (templateString) { + each(labelsArray, function(val, index) { + labelsArray[index] = template(templateString, { + value: (graphMin + (stepValue * (index + 1))) + }); + }); + } + return labelsArray; + }, + //--Animation methods + //Easing functions adapted from Robert Penner's easing equations + //http://www.robertpenner.com/easing/ + easingEffects = helpers.easingEffects = { + linear: function(t) { + return t; + }, + easeInQuad: function(t) { + return t * t; + }, + easeOutQuad: function(t) { + return -1 * t * (t - 2); + }, + easeInOutQuad: function(t) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t; + } + return -1 / 2 * ((--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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t; + } + return 1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t; + } + return -1 / 2 * ((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) { + if ((t /= 1 / 2) < 1) { + return 1 / 2 * t * t * t * t * t; + } + return 1 / 2 * ((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 -1 / 2 * (Math.cos(Math.PI * t / 1) - 1); + }, + easeInExpo: function(t) { + return (t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)); + }, + easeOutExpo: function(t) { + return (t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1); + }, + easeInOutExpo: function(t) { + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if ((t /= 1 / 2) < 1) { + return 1 / 2 * Math.pow(2, 10 * (t - 1)); + } + return 1 / 2 * (-Math.pow(2, -10 * --t) + 2); + }, + easeInCirc: function(t) { + if (t >= 1) { + return t; + } + return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1); + }, + easeOutCirc: function(t) { + return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t); + }, + easeInOutCirc: function(t) { + if ((t /= 1 / 2) < 1) { + return -1 / 2 * (Math.sqrt(1 - t * t) - 1); + } + return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1); + }, + easeInElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + }, + easeOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1) == 1) { + return 1; + } + if (!p) { + p = 1 * 0.3; + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1; + }, + easeInOutElastic: function(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 1 / 2) == 2) { + return 1; + } + if (!p) { + p = 1 * (0.3 * 1.5); + } + if (a < Math.abs(1)) { + a = 1; + s = p / 4; + } else { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1) { + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1; + }, + easeInBack: function(t) { + var s = 1.70158; + return 1 * (t /= 1) * t * ((s + 1) * t - s); + }, + easeOutBack: function(t) { + var s = 1.70158; + return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1); + }, + easeInOutBack: function(t) { + var s = 1.70158; + if ((t /= 1 / 2) < 1) { + return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)); + } + return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2); + }, + easeInBounce: function(t) { + return 1 - easingEffects.easeOutBounce(1 - t); + }, + easeOutBounce: function(t) { + if ((t /= 1) < (1 / 2.75)) { + return 1 * (7.5625 * t * t); + } else if (t < (2 / 2.75)) { + return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75); + } else if (t < (2.5 / 2.75)) { + return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375); + } else { + return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375); + } + }, + easeInOutBounce: function(t) { + if (t < 1 / 2) { + return easingEffects.easeInBounce(t * 2) * 0.5; + } + return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5; + } + }, + //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ + requestAnimFrame = helpers.requestAnimFrame = (function() { + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function(callback) { + return window.setTimeout(callback, 1000 / 60); + }; + })(), + cancelAnimFrame = helpers.cancelAnimFrame = (function() { + return window.cancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.mozCancelAnimationFrame || + window.oCancelAnimationFrame || + window.msCancelAnimationFrame || + function(callback) { + return window.clearTimeout(callback, 1000 / 60); + }; + })(), + animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { + + var currentStep = 0, + easingFunction = easingEffects[easingString] || easingEffects.linear; + + var animationFrame = function() { + currentStep++; + var stepDecimal = currentStep / totalSteps; + var easeDecimal = easingFunction(stepDecimal); + + callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); + onProgress.call(chartInstance, easeDecimal, stepDecimal); + if (currentStep < totalSteps) { + chartInstance.animationFrame = requestAnimFrame(animationFrame); + } else { + onComplete.apply(chartInstance); + } + }; + requestAnimFrame(animationFrame); + }, + //-- DOM methods + getRelativePosition = helpers.getRelativePosition = function(evt) { + var mouseX, mouseY; + var e = evt.originalEvent || evt, + canvas = evt.currentTarget || evt.srcElement, + boundingRect = canvas.getBoundingClientRect(); + + if (e.touches) { + mouseX = e.touches[0].clientX - boundingRect.left; + mouseY = e.touches[0].clientY - boundingRect.top; + + } else { + mouseX = e.clientX - boundingRect.left; + mouseY = e.clientY - boundingRect.top; + } + + return { + x: mouseX, + y: mouseY + }; + + }, + addEvent = helpers.addEvent = function(node, eventType, method) { + if (node.addEventListener) { + node.addEventListener(eventType, method); + } else if (node.attachEvent) { + node.attachEvent("on" + eventType, method); + } else { + node["on" + eventType] = method; + } + }, + removeEvent = helpers.removeEvent = function(node, eventType, handler) { + if (node.removeEventListener) { + node.removeEventListener(eventType, handler, false); + } else if (node.detachEvent) { + node.detachEvent("on" + eventType, handler); + } else { + node["on" + eventType] = noop; + } + }, + bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) { + // Create the events object if it's not already present + if (!chartInstance.events) chartInstance.events = {}; + + each(arrayOfEvents, function(eventName) { + chartInstance.events[eventName] = function() { + handler.apply(chartInstance, arguments); + }; + addEvent(chartInstance.chart.canvas, eventName, chartInstance.events[eventName]); + }); + }, + unbindEvents = helpers.unbindEvents = function(chartInstance, arrayOfEvents) { + each(arrayOfEvents, function(handler, eventName) { + removeEvent(chartInstance.chart.canvas, eventName, handler); + }); + }, + getMaximumWidth = helpers.getMaximumWidth = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); + // TODO = check cross browser stuff with this. + return container.clientWidth - padding; + }, + getMaximumHeight = helpers.getMaximumHeight = function(domNode) { + var container = domNode.parentNode, + padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); + // TODO = check cross browser stuff with this. + return container.clientHeight - padding; + }, + getStyle = helpers.getStyle = function(el, property) { + return el.currentStyle ? + el.currentStyle[property] : + document.defaultView.getComputedStyle(el, null).getPropertyValue(property); + }, + getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support + retinaScale = helpers.retinaScale = function(chart) { + var ctx = chart.ctx, + width = chart.canvas.width, + height = chart.canvas.height; + + if (window.devicePixelRatio) { + ctx.canvas.style.width = width + "px"; + ctx.canvas.style.height = height + "px"; + ctx.canvas.height = height * window.devicePixelRatio; + ctx.canvas.width = width * window.devicePixelRatio; + ctx.scale(window.devicePixelRatio, window.devicePixelRatio); + } + }, + //-- Canvas methods + clear = helpers.clear = function(chart) { + chart.ctx.clearRect(0, 0, chart.width, chart.height); + }, + fontString = helpers.fontString = function(pixelSize, fontStyle, fontFamily) { + return fontStyle + " " + pixelSize + "px " + fontFamily; + }, + longestText = helpers.longestText = function(ctx, font, arrayOfStrings) { + ctx.font = font; + var longest = 0; + each(arrayOfStrings, function(string) { + var textWidth = ctx.measureText(string).width; + longest = (textWidth > longest) ? textWidth : longest; + }); + return longest; + }, + drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx, x, y, width, height, radius) { + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + }, + color = helpers.color = function(color) { + if (!window.Color) { + console.log('Color.js not found!'); + return color; + } + return window.Color(color); + }, + isArray = helpers.isArray = function(obj) { + if (!Array.isArray) { + return Object.prototype.toString.call(arg) === '[object Array]'; + } + return Array.isArray(obj); + }; }).call(this); (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - // The scale service is used to resize charts along with all of their axes. We make this as - // a service where scales are registered with their respective charts so that changing the - // scales does not require - Chart.scaleService = { - // The interesting function - fitScalesForChart: function(chartInstance, width, height) { - var xPadding = width > 30 ? 5 : 2; - var yPadding = height > 30 ? 5 : 2; - - if (chartInstance) { - var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "left"; - }); - var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "right"; - }); - var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "top"; - }); - var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "bottom"; - }); - - var visibleLeftScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "left"; - }); - var visibleRightScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "right"; - }); - var visibleTopScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "top"; - }); - var visibleBottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { - return scaleInstance.options.position == "bottom"; - }); - - // // Adjust the padding to take into account displaying labels - // if (topScales.length === 0 || bottomScales.length === 0) { - // var maxFontHeight = 0; - - // var maxFontHeightFunction = function(scaleInstance) { - // if (scaleInstance.options.labels.show) { - // // Only consider font sizes for axes that actually show labels - // maxFontHeight = Math.max(maxFontHeight, scaleInstance.options.labels.fontSize); - // } - // }; - - // helpers.each(leftScales, maxFontHeightFunction); - // helpers.each(rightScales, maxFontHeightFunction); - - // if (topScales.length === 0) { - // // Add padding so that we can handle drawing the top nicely - // yPadding += 0.75 * maxFontHeight; // 0.75 since padding added on both sides - // } - - // if (bottomScales.length === 0) { - // // Add padding so that we can handle drawing the bottom nicely - // yPadding += 1.5 * maxFontHeight; - // } - // } - - // Essentially we now have any number of scales on each of the 4 sides. - // Our canvas looks like the following. - // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and - // B1 is the bottom axis - // |------------------------------------------------------| - // | | T1 | | - // |----|-----|-------------------------------------|-----| - // | | | | | - // | L1 | L2 | Chart area | R1 | - // | | | | | - // | | | | | - // |----|-----|-------------------------------------|-----| - // | | B1 | | - // | | | | - // |------------------------------------------------------| - - // What we do to find the best sizing, we do the following - // 1. Determine the minimum size of the chart area. - // 2. Split the remaining width equally between each vertical axis - // 3. Split the remaining height equally between each horizontal axis - // 4. Give each scale the maximum size it can be. The scale will return it's minimum size - // 5. Adjust the sizes of each axis based on it's minimum reported size. - // 6. Refit each axis - // 7. Position each axis in the final location - // 8. Tell the chart the final location of the chart area - - // Step 1 - var chartWidth = width / 2; // min 50% - var chartHeight = height / 2; // min 50% - - chartWidth -= (2 * xPadding); - chartHeight -= (2 * yPadding); - - - // Step 2 - var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); - - // Step 3 - var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); - - // Step 4; - var minimumScaleSizes = []; - - var verticalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); - minimumScaleSizes.push({ - horizontal: false, - minSize: minSize, - scale: scaleInstance, - }); - }; - - var horizontalScaleMinSizeFunction = function(scaleInstance) { - var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); - minimumScaleSizes.push({ - horizontal: true, - minSize: minSize, - scale: scaleInstance, - }); - }; - - // vertical scales - helpers.each(leftScales, verticalScaleMinSizeFunction); - helpers.each(rightScales, verticalScaleMinSizeFunction); - - // horizontal scales - helpers.each(topScales, horizontalScaleMinSizeFunction); - helpers.each(bottomScales, horizontalScaleMinSizeFunction); - - // Step 5 - var maxChartHeight = height - (2 * yPadding); - var maxChartWidth = width - (2 * xPadding); - - helpers.each(minimumScaleSizes, function(wrapper) { - if (wrapper.horizontal) { - maxChartHeight -= wrapper.minSize.height; - } else { - maxChartWidth -= wrapper.minSize.width; - } - }); - - // At this point, maxChartHeight and maxChartWidth are the size the chart area could - // be if the axes are drawn at their minimum sizes. - - // Step 6 - var verticalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight); - } - }; - - var horizontalScaleFitFunction = function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - var scaleMargin = { - left: totalLeftWidth, - right: totalRightWidth, - top: 0, - bottom: 0, - }; - - if (wrapper) { - scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); - } - }; - - var totalLeftWidth = xPadding; - var totalRightWidth = xPadding; - var totalTopHeight = yPadding; - var totalBottomHeight = yPadding; - - helpers.each(leftScales, verticalScaleFitFunction); - helpers.each(rightScales, verticalScaleFitFunction); - - // Figure out how much margin is on the left and right of the horizontal axes - helpers.each(leftScales, function(scaleInstance) { - totalLeftWidth += scaleInstance.width; - }); - - helpers.each(rightScales, function(scaleInstance) { - totalRightWidth += scaleInstance.width; - }); - - helpers.each(topScales, horizontalScaleFitFunction); - helpers.each(bottomScales, horizontalScaleFitFunction); - - helpers.each(topScales, function(scaleInstance) { - totalTopHeight += scaleInstance.height; - }); - helpers.each(bottomScales, function(scaleInstance) { - totalBottomHeight += scaleInstance.height; - }); - - // Let the left scale know the final margin - helpers.each(leftScales, function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - var scaleMargin = { - left: 0, - right: 0, - top: totalTopHeight, - bottom: totalBottomHeight - }; - - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); - } - }); - - helpers.each(rightScales, function(scaleInstance) { - var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { - return wrapper.scale === scaleInstance; - }); - - var scaleMargin = { - left: 0, - right: 0, - top: totalTopHeight, - bottom: totalBottomHeight - }; - - if (wrapper) { - scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); - } - }); - - // Step 7 - // Position the scales - var left = xPadding; - var top = yPadding; - var right = 0; - var bottom = 0; - - var verticalScalePlacer = function(scaleInstance) { - scaleInstance.left = left; - scaleInstance.right = left + scaleInstance.width; - scaleInstance.top = totalTopHeight; - scaleInstance.bottom = totalTopHeight + maxChartHeight; - - // Move to next point - left = scaleInstance.right; - }; - - var horizontalScalePlacer = function(scaleInstance) { - scaleInstance.left = totalLeftWidth; - scaleInstance.right = totalLeftWidth + maxChartWidth; - scaleInstance.top = top; - scaleInstance.bottom = top + scaleInstance.height; - - // Move to next point - top = scaleInstance.bottom; - }; - - helpers.each(leftScales, verticalScalePlacer); - helpers.each(topScales, horizontalScalePlacer); - - // Account for chart width and height - left += maxChartWidth; - top += maxChartHeight; - - helpers.each(rightScales, verticalScalePlacer); - helpers.each(bottomScales, horizontalScalePlacer); - - // Step 8 - chartInstance.chartArea = { - left: totalLeftWidth, - top: totalTopHeight, - right: totalLeftWidth + maxChartWidth, - bottom: totalTopHeight + maxChartHeight, - }; - } - } - }; - - // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then - // use the new chart options to grab the correct scale - Chart.scales = { - constructors: {}, - // Use a registration function so that we can move to an ES6 map when we no longer need to support - // old browsers - registerScaleType: function(type, scaleConstructor) { - this.constructors[type] = scaleConstructor; - }, - getScaleConstructor: function(type) { - return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; - } - }; -}).call(this); - -/*! - * Chart.js - * http://chartjs.org/ - * Version: 2.0.0-alpha - * - * Copyright 2015 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart, + helpers = Chart.helpers; + + Chart.elements = {}; + + Chart.Element = function(configuration) { + helpers.extend(this, configuration); + this.initialize.apply(this, arguments); + }; + helpers.extend(Chart.Element.prototype, { + initialize: function() {}, + pivot: function() { + if (!this._view) { + this._view = helpers.clone(this._model); + } + this._start = helpers.clone(this._view); + return this; + }, + transition: function(ease) { + if (!this._view) { + this._view = helpers.clone(this._model); + } + if (!this._start) { + this.pivot(); + } + + helpers.each(this._model, function(value, key) { + + if (key[0] === '_' || !this._model.hasOwnProperty(key)) { + // Only non-underscored properties + } + + // Init if doesn't exist + else if (!this._view[key]) { + if (typeof value === 'number') { + this._view[key] = value * ease; + } else { + this._view[key] = value || null; + } + } + + // No unnecessary computations + else if (this._model[key] === this._view[key]) { + // It's the same! Woohoo! + } + + // Color transitions if possible + else if (typeof value === 'string') { + try { + var color = helpers.color(this._start[key]).mix(helpers.color(this._model[key]), ease); + this._view[key] = color.rgbString(); + } catch (err) { + this._view[key] = value; + } + } + // Number transitions + else if (typeof value === 'number') { + var startVal = this._start[key] !== undefined ? this._start[key] : 0; + this._view[key] = ((this._model[key] - startVal) * ease) + startVal; + } + // Everything else + else { + this._view[key] = value; + } + + }, this); + + if (ease === 1) { + delete this._start; + } + return this; + }, + tooltipPosition: function() { + return { + x: this._model.x, + y: this._model.y + }; + }, + hasValue: function() { + return helpers.isNumber(this._model.x) && helpers.isNumber(this._model.y); + } + }); + + Chart.Element.extend = helpers.inherits; +}).call(this); (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.tooltips = { - enabled: true, - custom: null, - backgroundColor: "rgba(0,0,0,0.8)", - fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - fontSize: 10, - fontStyle: "normal", - fontColor: "#fff", - titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - titleFontSize: 12, - titleFontStyle: "bold", - titleFontColor: "#fff", - yPadding: 6, - xPadding: 6, - caretSize: 8, - cornerRadius: 6, - xOffset: 10, - template: [ - '<% if(label){ %>', - '<%=label %>: ', - '<% } %>', - '<%=value %>', - ].join(''), - multiTemplate: [ - '<%if (datasetLabel){ %>', - '<%=datasetLabel %>: ', - '<% } %>', - '<%=value %>' - ].join(''), - multiKeyBackground: '#fff', - }; - - Chart.Tooltip = Chart.Element.extend({ - initialize: function() { - var options = this._options; - helpers.extend(this, { - _model: { - // Positioning - xPadding: options.tooltips.xPadding, - yPadding: options.tooltips.yPadding, - xOffset: options.tooltips.xOffset, - - // Labels - textColor: options.tooltips.fontColor, - _fontFamily: options.tooltips.fontFamily, - _fontStyle: options.tooltips.fontStyle, - fontSize: options.tooltips.fontSize, - - // Title - titleTextColor: options.tooltips.titleFontColor, - _titleFontFamily: options.tooltips.titleFontFamily, - _titleFontStyle: options.tooltips.titleFontStyle, - titleFontSize: options.tooltips.titleFontSize, - - // Appearance - caretHeight: options.tooltips.caretSize, - cornerRadius: options.tooltips.cornerRadius, - backgroundColor: options.tooltips.backgroundColor, - opacity: 0, - legendColorBackground: options.tooltips.multiKeyBackground, - }, - }); - }, - update: function() { - - var ctx = this._chart.ctx; - - switch (this._options.hover.mode) { - case 'single': - helpers.extend(this._model, { - text: helpers.template(this._options.tooltips.template, { - // These variables are available in the template function. Add others here - element: this._active[0], - value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], - label: this._data.labels ? this._data.labels[this._active[0]._index] : '', - }), - }); - - var tooltipPosition = this._active[0].tooltipPosition(); - helpers.extend(this._model, { - x: Math.round(tooltipPosition.x), - y: Math.round(tooltipPosition.y), - caretPadding: tooltipPosition.padding - }); - - break; - - case 'label': - - // Tooltip Content - - var dataArray, - dataIndex; - - var labels = [], - colors = []; - - for (var i = this._data.datasets.length - 1; i >= 0; i--) { - dataArray = this._data.datasets[i].metaData; - dataIndex = helpers.indexOf(dataArray, this._active[0]); - if (dataIndex !== -1) { - break; - } - } - - var medianPosition = (function(index) { - // Get all the points at that particular index - var elements = [], - dataCollection, - xPositions = [], - yPositions = [], - xMax, - yMax, - xMin, - yMin; - helpers.each(this._data.datasets, function(dataset) { - dataCollection = dataset.metaData; - if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { - elements.push(dataCollection[dataIndex]); - } - }, this); - - // Reverse labels if stacked - helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { - xPositions.push(element._view.x); - yPositions.push(element._view.y); - - //Include any colour information about the element - labels.push(helpers.template(this._options.tooltips.multiTemplate, { - // These variables are available in the template function. Add others here - element: element, - datasetLabel: this._data.datasets[element._datasetIndex].label, - value: this._data.datasets[element._datasetIndex].data[element._index], - })); - colors.push({ - fill: element._view.backgroundColor, - stroke: element._view.borderColor - }); - - }, this); - - yMin = helpers.min(yPositions); - yMax = helpers.max(yPositions); - - xMin = helpers.min(xPositions); - xMax = helpers.max(xPositions); - - return { - x: (xMin > this._chart.width / 2) ? xMin : xMax, - y: (yMin + yMax) / 2, - }; - }).call(this, dataIndex); - - // Apply for now - helpers.extend(this._model, { - x: medianPosition.x, - y: medianPosition.y, - labels: labels, - title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', - legendColors: colors, - legendBackgroundColor: this._options.tooltips.multiKeyBackground, - }); - - - // Calculate Appearance Tweaks - - this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; - - var titleWidth = ctx.measureText(this.title).width, - //Label has a legend square as well so account for this. - labelWidth = helpers.longestText(ctx, this.font, labels) + this._model.fontSize + 3, - longestTextWidth = helpers.max([labelWidth, titleWidth]); - - this._model.width = longestTextWidth + (this._model.xPadding * 2); - - - var halfHeight = this._model.height / 2; - - //Check to ensure the height will fit on the canvas - if (this._model.y - halfHeight < 0) { - this._model.y = halfHeight; - } else if (this._model.y + halfHeight > this._chart.height) { - this._model.y = this._chart.height - halfHeight; - } - - //Decide whether to align left or right based on position on canvas - if (this._model.x > this._chart.width / 2) { - this._model.x -= this._model.xOffset + this._model.width; - } else { - this._model.x += this._model.xOffset; - } - break; - } - - return this; - }, - draw: function() { - - var ctx = this._chart.ctx; - var vm = this._view; - - switch (this._options.hover.mode) { - case 'single': - - ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - - vm.xAlign = "center"; - vm.yAlign = "above"; - - //Distance between the actual element.y position and the start of the tooltip caret - var caretPadding = vm.caretPadding || 2; - - var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, - tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, - tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; - - if (vm.x + tooltipWidth / 2 > this._chart.width) { - vm.xAlign = "left"; - } else if (vm.x - tooltipWidth / 2 < 0) { - vm.xAlign = "right"; - } - - if (vm.y - tooltipHeight < 0) { - vm.yAlign = "below"; - } - - var tooltipX = vm.x - tooltipWidth / 2, - tooltipY = vm.y - tooltipHeight; - - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - - // Custom Tooltips - if (this._custom) { - this._custom(this._view); - } else { - switch (vm.yAlign) { - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } - - switch (vm.xAlign) { - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } - - helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); - - ctx.fill(); - - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); - - } - break; - case 'label': - - helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); - ctx.fill(); - ctx.closePath(); - - ctx.textAlign = "left"; - ctx.textBaseline = "middle"; - ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); - ctx.font = helpers.fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); - ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); - - ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); - helpers.each(vm.labels, function(label, index) { - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); - - //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) - //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); - //Instead we'll make a white filled block to put the legendColour palette over. - - ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); - - ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); - ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); - - - }, this); - break; - } - }, - getLineHeight: function(index) { - var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, - afterTitleIndex = index - 1; - - //If the index is zero, we're getting the title - if (index === 0) { - return baseLineHeight + this._view.titleFontSize / 2; - } else { - return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; - } - - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.animation = { + duration: 1000, + easing: "easeOutQuart", + onProgress: function() {}, + onComplete: function() {}, + }; + + Chart.Animation = Chart.Element.extend({ + currentStep: null, // the current animation step + numSteps: 60, // default number of steps + easing: "", // the easing to use for this animation + render: null, // render function used by the animation service + + onAnimationProgress: null, // user specified callback to fire on each step of the animation + onAnimationComplete: null, // user specified callback to fire when the animation finishes + }); + + Chart.animationService = { + frameDuration: 17, + animations: [], + dropFrames: 0, + addAnimation: function(chartInstance, animationObject, duration) { + + if (!duration) { + chartInstance.animating = true; + } + + for (var index = 0; index < this.animations.length; ++index) { + if (this.animations[index].chartInstance === chartInstance) { + // replacing an in progress animation + this.animations[index].animationObject = animationObject; + return; + } + } + + this.animations.push({ + chartInstance: chartInstance, + animationObject: animationObject + }); + + // If there are no animations queued, manually kickstart a digest, for lack of a better word + if (this.animations.length == 1) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + }, + // Cancel the animation for a given chart instance + cancelAnimation: function(chartInstance) { + var index = helpers.findNextWhere(this.animations, function(animationWrapper) { + return animationWrapper.chartInstance === chartInstance; + }); + + if (index) { + this.animations.splice(index, 1); + chartInstance.animating = false; + } + }, + // calls startDigest with the proper context + digestWrapper: function() { + Chart.animationService.startDigest.call(Chart.animationService); + }, + startDigest: function() { + + var startTime = Date.now(); + var framesToDrop = 0; + + if (this.dropFrames > 1) { + framesToDrop = Math.floor(this.dropFrames); + this.dropFrames -= framesToDrop; + } + + for (var i = 0; i < this.animations.length; i++) { + + if (this.animations[i].animationObject.currentStep === null) { + this.animations[i].animationObject.currentStep = 0; + } + + this.animations[i].animationObject.currentStep += 1 + framesToDrop; + if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { + this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; + } + + this.animations[i].animationObject.render(this.animations[i].chartInstance, this.animations[i].animationObject); + + if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) { + // executed the last frame. Remove the animation. + this.animations[i].chartInstance.animating = false; + this.animations.splice(i, 1); + // Keep the index in place to offset the splice + i--; + } + } + + var endTime = Date.now(); + var delay = endTime - startTime - this.frameDuration; + var frameDelay = delay / this.frameDuration; + + if (frameDelay > 1) { + this.dropFrames += frameDelay; + } + + // Do we have more stuff to animate? + if (this.animations.length > 0) { + helpers.requestAnimFrame.call(window, this.digestWrapper); + } + } + }; }).call(this); (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var DatasetScale = Chart.Element.extend({ - // overridden in the chart. Will set min and max as properties of the scale for later use. Min will always be 0 when using a dataset and max will be the number of items in the dataset - calculateRange: helpers.noop, - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - getPixelForValue: function(value, index, includeOffset) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - if (this.isHorizontal()) { - var isRotated = (this.labelRotation > 0); - var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.max - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; - - if (this.options.gridLines.offsetGridLines && includeOffset) { - valueOffset += (valueWidth / 2); - } - - return this.left + Math.round(valueOffset); - } else { - return this.top + (index * (this.height / this.max)); - } - }, - calculateLabelRotation: function(maxHeight, margins) { - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - this.ctx.font = labelFont; - - var firstWidth = this.ctx.measureText(this.labels[0]).width; - var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; - var firstRotated; - var lastRotated; - - this.paddingRight = lastWidth / 2 + 3; - this.paddingLeft = firstWidth / 2 + 3; - - this.labelRotation = 0; - - if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - var cosRotation; - var sinRotation; - var firstRotatedWidth; - - this.labelWidth = originalLabelWidth; - - //Allow 3 pixels x2 padding either side for label readability - // only the index matters for a dataset scale, but we want a consistent interface between scales - var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; - - //Max label rotate should be 90 - also act as a loop counter - while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { - cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); - sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); - - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; - - // We're right aligning the text now. - if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { - this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; - } - - this.paddingRight = this.options.labels.fontSize / 2; - - if (sinRotation * originalLabelWidth > maxHeight) { - // go back one step - this.labelRotation--; - break; - } - - this.labelRotation++; - this.labelWidth = cosRotation * originalLabelWidth; - - } - } else { - this.labelWidth = 0; - this.paddingRight = 0; - this.paddingLeft = 0; - } - - if (margins) { - this.paddingLeft -= margins.left; - this.paddingRight -= margins.right; - - this.paddingLeft = Math.max(this.paddingLeft, 0); - this.paddingRight = Math.max(this.paddingRight, 0); - } - - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight, margins) { - this.calculateRange(); - this.calculateLabelRotation(maxHeight, margins); - - var minSize = { - width: 0, - height: 0, - }; - - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - // Width - if (this.isHorizontal()) { - minSize.width = maxWidth; - this.width = maxWidth; - } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } - - // Height - if (this.isHorizontal()) { - var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); - } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - setContextLineSettings = true; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; - var isRotated = this.labelRotation !== 0; - - helpers.each(this.labels, function(label, index) { - var xLineValue = this.getPixelForValue(label, index, false); // xvalues for grid lines - var xLabelValue = this.getPixelForValue(label, index, true); // x values for labels (need to consider offsetLabel option) - - if (this.options.gridLines.show) { - if (index === 0) { - // Draw the first index specially - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xLineValue, yTickStart); - this.ctx.lineTo(xLineValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xLineValue, chartArea.top); - this.ctx.lineTo(xLineValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - } - - if (this.options.labels.show) { - this.ctx.save(); - this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); - this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); - this.ctx.font = this.font; - this.ctx.textAlign = (isRotated) ? "right" : "center"; - this.ctx.textBaseline = (isRotated) ? "middle" : "top"; - this.ctx.fillText(label, 0, 0); - this.ctx.restore(); - } - }, this); - } else { - // Vertical - if (this.options.gridLines.show) {} - - if (this.options.labels.show) { - // Draw the labels - } - } - } - } - }); - Chart.scales.registerScaleType("category", DatasetScale); + "use strict"; + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart, + helpers = Chart.helpers; -}).call(this); -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var LinearScale = Chart.Element.extend({ - calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - generateTicks: function(width, height) { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw - - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; - - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); - } - } else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph - - var maxTicks; - - if (this.isHorizontal()) { - maxTicks = Math.min(11, Math.ceil(width / 50)); - } else { - // The factor of 2 used to scale the font size has been experimentally determined. - maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); - } - - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } - - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; - - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - } - } - - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } - - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, - buildLabels: function() { - // We assume that this has been run after ticks have been generated. We try to figure out - // a label for each tick. - this.labels = []; - - helpers.each(this.ticks, function(tick, index, ticks) { - var label; - - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.lables.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick - }); - } - - this.labels.push(label ? label : ""); // empty string will not render so we're good - }, this); - }, - getPixelForValue: function(value) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - var pixel; - var range = this.max - this.min; - - if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.min)); - } else { - // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.min)); - } - - return pixel; - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { - this.calculateRange(); - this.generateTicks(maxWidth, maxHeight); - this.buildLabels(); - - var minSize = { - width: 0, - height: 0, - }; - - // In a horizontal axis, we need some room for the scale to be drawn - // - // ----------------------------------------------------- - // | | | | | - // - // In a vertical axis, we need some room for the scale to be drawn. - // The actual grid lines will be drawn on the chart area, however, we need to show - // ticks where the axis actually is. - // We will allocate 25px for this width - // | - // -| - // | - // | - // -| - // | - // | - // -| - - - // Width - if (this.isHorizontal()) { - minSize.width = maxWidth; // fill all the width - } else { - minSize.width = this.options.gridLines.show && this.options.display ? 10 : 0; - } - - // height - if (this.isHorizontal()) { - minSize.height = this.options.gridLines.show && this.options.display ? 10 : 0; - } else { - minSize.height = maxHeight; // fill all the height - } - - - - if (this.options.labels.show && this.options.display) { - // Don't bother fitting the labels if we are not showing them - var labelFont = helpers.fontString(this.options.labels.fontSize, - this.options.labels.fontStyle, this.options.labels.fontFamily); - - if (this.isHorizontal()) { - // A horizontal axis is more constrained by the height. - var maxLabelHeight = maxHeight - minSize.height; - var labelHeight = 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(maxHeight, minSize.height + labelHeight); - } else { - // A vertical axis is more constrained by the width. Labels are the dominant factor - // here, so get that length first - var maxLabelWidth = maxWidth - minSize.width; - var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - if (largestTextWidth < maxLabelWidth) { - // We don't need all the room - minSize.width += largestTextWidth; - } else { - // Expand to max size - minSize.width = maxWidth; - } - } - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - var hasZero; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - if (this.options.gridLines.show) { - // Draw the horizontal line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { - return tick === 0; - }) !== undefined; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; - var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; - - helpers.each(this.ticks, function(tick, index) { - // Grid lines are vertical - var xValue = this.getPixelForValue(tick); - - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the left if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xValue, yTickStart); - this.ctx.lineTo(xValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xValue, chartArea.top); - this.ctx.lineTo(xValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - }, this); - } - - if (this.options.labels.show) { - // Draw the labels - - var labelStartY; - - if (this.options.position == "top") { - labelStartY = this.bottom - 10; - this.ctx.textBaseline = "bottom"; - } else { - // bottom side - labelStartY = this.top + 10; - this.ctx.textBaseline = "top"; - } - - this.ctx.textAlign = "center"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - helpers.each(this.labels, function(label, index) { - var xValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, xValue, labelStartY); - }, this); - } - } else { - // Vertical - if (this.options.gridLines.show) { - - // Draw the vertical line - setContextLineSettings = true; - hasZero = helpers.findNextWhere(this.ticks, function(tick) { - return tick === 0; - }) !== undefined; - var xTickStart = this.options.position == "right" ? this.left : this.right - 5; - var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; - - helpers.each(this.ticks, function(tick, index) { - // Grid lines are horizontal - var yValue = this.getPixelForValue(tick); - - if (tick === 0 || (!hasZero && index === 0)) { - // Draw the 0 point specially or the bottom if there is no 0 - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; // use boolean to indicate that we only want to do this once - } - - yValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xTickStart, yValue); - this.ctx.lineTo(xTickEnd, yValue); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(chartArea.left, yValue); - this.ctx.lineTo(chartArea.right, yValue); - } - - this.ctx.stroke(); - }, this); - } - - if (this.options.labels.show) { - // Draw the labels - - var labelStartX; - - if (this.options.position == "left") { - labelStartX = this.right - 10; - this.ctx.textAlign = "right"; - } else { - // right side - labelStartX = this.left + 5; - this.ctx.textAlign = "left"; - } - - this.ctx.textBaseline = "middle"; - this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - helpers.each(this.labels, function(label, index) { - var yValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, labelStartX, yValue); - }, this); - } - } - } - } - }); - Chart.scales.registerScaleType("linear", LinearScale); + //Create a dictionary of chart types, to allow for extension of existing types + Chart.types = {}; + //Store a reference to each instance - allowing us to globally resize chart instances on window resize. + //Destroy method on the chart will remove the instance of the chart from this reference. + Chart.instances = {}; -}).call(this); + // Controllers available for dataset visualization eg. bar, line, slice, etc. + Chart.controllers = {}; -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var LinearRadialScale = Chart.Element.extend({ - initialize: function() { - this.size = helpers.min([this.height, this.width]); - this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); - }, - calculateCenterOffset: function(value) { - // Take into account half font size + the yPadding of the top value - var scalingFactor = this.drawingArea / (this.max - this.min); - return (value - this.min) * scalingFactor; - }, - update: function() { - if (!this.options.lineArc) { - this.setScaleSize(); - } else { - this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); - } - - this.buildYLabels(); - }, - calculateRange: helpers.noop, // overridden in chart - generateTicks: function() { - // We need to decide how many ticks we are going to have. Each tick draws a grid line. - // There are two possibilities. The first is that the user has manually overridden the scale - // calculations in which case the job is easy. The other case is that we have to do it ourselves - // - // We assume at this point that the scale object has been updated with the following values - // by the chart. - // min: this is the minimum value of the scale - // max: this is the maximum value of the scale - // options: contains the options for the scale. This is referenced from the user settings - // rather than being cloned. This ensures that updates always propogate to a redraw - - // Reset the ticks array. Later on, we will draw a grid line at these positions - // The array simply contains the numerical value of the spots where ticks will be - this.ticks = []; - - if (this.options.override) { - // The user has specified the manual override. We use <= instead of < so that - // we get the final line - for (var i = 0; i <= this.options.override.steps; ++i) { - var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); - } - } else { - // Figure out what the max number of ticks we can support it is based on the size of - // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 - // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on - // the graph - - var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); - - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } - - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; - - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - } - } - - if (this.options.position == "left" || this.options.position == "right") { - // We are in a vertical orientation. The top value is the highest. So reverse the array - this.ticks.reverse(); - } - - // At this point, we need to update our max and min given the tick values since we have expanded the - // range of the scale - this.max = helpers.max(this.ticks); - this.min = helpers.min(this.ticks); - }, - buildYLabels: function() { - this.yLabels = []; - - helpers.each(this.ticks, function(tick, index, ticks) { - var label; - - if (this.options.labels.userCallback) { - // If the user provided a callback for label generation, use that as first priority - label = this.options.labels.userCallback(tick, index, ticks); - } else if (this.options.labels.template) { - // else fall back to the template string - label = helpers.template(this.options.labels.template, { - value: tick - }); - } - - this.yLabels.push(label ? label : ""); - }, this); - }, - getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); - }, - setScaleSize: function() { - /* - * Right, this is really confusing and there is a lot of maths going on here - * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 - * - * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif - * - * Solution: - * - * We assume the radius of the polygon is half the size of the canvas at first - * at each index we check if the text overlaps. - * - * Where it does, we store that angle and that index. - * - * After finding the largest index and angle we calculate how much we need to remove - * from the shape radius to move the point inwards by that x. - * - * We average the left and right distances to get the maximum shape radius that can fit in the box - * along with labels. - * - * Once we have that, we can find the centre point for the chart, by taking the x text protrusion - * on each side, removing that from the size, halving it and adding the left x protrusion width. - * - * This will mean we have a shape fitted to the canvas, as large as it can be with the labels - * and position it in the most space efficient manner - * - * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - */ - - - // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points - var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), - pointPosition, - i, - textWidth, - halfTextWidth, - furthestRight = this.width, - furthestRightIndex, - furthestRightAngle, - furthestLeft = 0, - furthestLeftIndex, - furthestLeftAngle, - xProtrusionLeft, - xProtrusionRight, - radiusReductionRight, - radiusReductionLeft, - maxWidthRadius; - this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - for (i = 0; i < this.valuesCount; i++) { - // 5px to space the text slightly out - similar to what we do in the draw function. - pointPosition = this.getPointPosition(i, largestPossibleRadius); - textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { - value: this.labels[i] - })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { - // If we're at index zero, or exactly the middle, we're at exactly the top/bottom - // of the radar chart, so text will be aligned centrally, so we'll half it and compare - // w/left and right text sizes - halfTextWidth = textWidth / 2; - if (pointPosition.x + halfTextWidth > furthestRight) { - furthestRight = pointPosition.x + halfTextWidth; - furthestRightIndex = i; - } - if (pointPosition.x - halfTextWidth < furthestLeft) { - furthestLeft = pointPosition.x - halfTextWidth; - furthestLeftIndex = i; - } - } else if (i < this.valuesCount / 2) { - // Less than half the values means we'll left align the text - if (pointPosition.x + textWidth > furthestRight) { - furthestRight = pointPosition.x + textWidth; - furthestRightIndex = i; - } - } else if (i > this.valuesCount / 2) { - // More than half the values means we'll right align the text - if (pointPosition.x - textWidth < furthestLeft) { - furthestLeft = pointPosition.x - textWidth; - furthestLeftIndex = i; - } - } - } - - xProtrusionLeft = furthestLeft; - - xProtrusionRight = Math.ceil(furthestRight - this.width); - - furthestRightAngle = this.getIndexAngle(furthestRightIndex); - - furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); - - radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); - - radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); - - // Ensure we actually need to reduce the size of the chart - radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; - radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; - - this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; - - //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) - this.setCenterPoint(radiusReductionLeft, radiusReductionRight); - - }, - setCenterPoint: function(leftMovement, rightMovement) { - - var maxRight = this.width - rightMovement - this.drawingArea, - maxLeft = leftMovement + this.drawingArea; - - this.xCenter = (maxLeft + maxRight) / 2; - // Always vertically in the centre as the text height doesn't change - this.yCenter = (this.height / 2); - }, - - getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; - // Start from the top instead of right, so remove a quarter of the circle - - return index * angleMultiplier - (Math.PI / 2); - }, - getPointPosition: function(index, distanceFromCenter) { - var thisAngle = this.getIndexAngle(index); - return { - x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, - y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter - }; - }, - draw: function() { - if (this.options.display) { - var ctx = this.ctx; - helpers.each(this.yLabels, function(label, index) { - // Don't draw a centre value - if (index > 0) { - var yCenterOffset = index * (this.drawingArea / Math.max(this.ticks.length, 1)), - yHeight = this.yCenter - yCenterOffset, - pointPosition; - - // Draw circular lines around the scale - if (this.options.gridLines.show) { - ctx.strokeStyle = this.options.gridLines.color; - ctx.lineWidth = this.options.gridLines.lineWidth; - - if (this.options.lineArc) { - ctx.beginPath(); - ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); - ctx.closePath(); - ctx.stroke(); - } else { - ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { - pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.ticks[index])); - if (i === 0) { - ctx.moveTo(pointPosition.x, pointPosition.y); - } else { - ctx.lineTo(pointPosition.x, pointPosition.y); - } - } - ctx.closePath(); - ctx.stroke(); - } - } - - if (this.options.labels.show) { - ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - - if (this.showLabelBackdrop) { - var labelWidth = ctx.measureText(label).width; - ctx.fillStyle = this.options.labels.backdropColor; - ctx.fillRect( - this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, - yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, - labelWidth + this.options.labels.backdropPaddingX * 2, - this.options.labels.fontSize + this.options.lables.backdropPaddingY * 2 - ); - } - - ctx.textAlign = 'center'; - ctx.textBaseline = "middle"; - ctx.fillStyle = this.options.labels.fontColor; - ctx.fillText(label, this.xCenter, yHeight); - } - } - }, this); - - if (!this.options.lineArc) { - ctx.lineWidth = this.options.angleLines.lineWidth; - ctx.strokeStyle = this.options.angleLines.color; - - for (var i = this.valuesCount - 1; i >= 0; i--) { - if (this.options.angleLines.show) { - var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max)); - ctx.beginPath(); - ctx.moveTo(this.xCenter, this.yCenter); - ctx.lineTo(outerPosition.x, outerPosition.y); - ctx.stroke(); - ctx.closePath(); - } - // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); - ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - ctx.fillStyle = this.options.pointLabels.fontColor; - - var labelsCount = this.labels.length, - halfLabelsCount = this.labels.length / 2, - quarterLabelsCount = halfLabelsCount / 2, - upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), - exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); - if (i === 0) { - ctx.textAlign = 'center'; - } else if (i === halfLabelsCount) { - ctx.textAlign = 'center'; - } else if (i < halfLabelsCount) { - ctx.textAlign = 'left'; - } else { - ctx.textAlign = 'right'; - } - - // Set the correct text baseline based on outer positioning - if (exactQuarter) { - ctx.textBaseline = 'middle'; - } else if (upperHalf) { - ctx.textBaseline = 'bottom'; - } else { - ctx.textBaseline = 'top'; - } - - ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); - } - } - } - } - }); - Chart.scales.registerScaleType("radialLinear", LinearRadialScale); + // The main controller of a chart + Chart.Controller = function(instance) { + this.chart = instance; + this.config = instance.config; + this.data = this.config.data; + this.options = this.config.options = helpers.configMerge(Chart.defaults.global, Chart.defaults[this.config.type], this.config.options || {}); + this.id = helpers.uid(); + + //Add the chart instance to the global namespace + Chart.instances[this.id] = this; -}).call(this); + if (this.options.responsive) { + this.resize(); + } -/*! - * Chart.js - * http://chartjs.org/ - * Version: 2.0.0-alpha - * - * Copyright 2015 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ + this.initialize.call(this); + return this; + }; + + helpers.extend(Chart.Controller.prototype, { + + initialize: function initialize() { + + // TODO + // If BeforeInit(this) doesn't return false, proceed -(function() { + this.bindEvents(); + this.buildScales(); + this.buildControllers(); + this.resetElements(); + this.initToolTip(); + this.update(); + + // TODO + // If AfterInit(this) doesn't return false, proceed + + return this; + }, + + clear: function clear() { + helpers.clear(this.chart); + return this; + }, + + stop: function stop() { + // Stops any current animation loop occuring + Chart.animationService.cancelAnimation(this); + return this; + }, + + resize: function resize() { + this.stop(); + var canvas = this.chart.canvas, + newWidth = helpers.getMaximumWidth(this.chart.canvas), + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + + canvas.width = this.chart.width = newWidth; + canvas.height = this.chart.height = newHeight; + + helpers.retinaScale(this.chart); + + return this; + }, + + buildScales: function buildScales() { + // Map of scale ID to scale object so we can lookup later + this.scales = {}; + + // Build the x axes + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); - "use strict"; + this.scales[scale.id] = scale; + }, this); - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + }, + + buildControllers: function() { + this.eachDataset(function(dataset, datasetIndex) { + var type = dataset.type || this.config.type; + if (dataset.controller) { + dataset.controller.updateIndex(datasetIndex); + return; + } + dataset.controller = new Chart.controllers[type](this, datasetIndex); + }); + }, + + resetElements: function resetElements() { + this.eachDataset(function(dataset, datasetIndex) { + dataset.controller.reset(); + }); + }, + + + update: function update(animationDuration) { + // This will loop through any data and do the appropriate element update for the type + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + this.eachDataset(function(dataset, datasetIndex) { + dataset.controller.update(); + }); + this.render(animationDuration); + }, + + render: function render(duration) { + + if (this.options.animation.duration !== 0 || duration) { + var animation = new Chart.Animation(); + animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps + animation.easing = this.options.animation.easing; + + // render function + animation.render = function(chartInstance, animationObject) { + var easingFunction = helpers.easingEffects[animationObject.easing]; + var stepDecimal = animationObject.currentStep / animationObject.numSteps; + var easeDecimal = easingFunction(stepDecimal); + + chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); + }; + + // user events + animation.onAnimationProgress = this.options.onAnimationProgress; + animation.onAnimationComplete = this.options.onAnimationComplete; + + Chart.animationService.addAnimation(this, animation, duration); + } else { + this.draw(); + this.options.onAnimationComplete.call(this); + } + return this; + }, + + draw: function(ease) { + var easingDecimal = ease || 1; + this.clear(); + + // Draw all the scales + helpers.each(this.scales, function(scale) { + scale.draw(this.chartArea); + }, this); + + // Draw each dataset via its respective controller + // TODO: needs support for reverse stacking (line chart) + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.controller.draw(ease); + }, this); + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); + }, + + + + + + + + eachValue: function eachValue(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.data, callback, this, datasetIndex); + }, this); + }, + + eachElement: function eachElement(callback) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); + }, this); + }, + + eachDataset: function eachDataset(callback) { + helpers.each(this.data.datasets, callback, this); + }, + + // 2 helper functions to get next/previous elements in datasets + nextElement: function nextElement(datasets, index, loop) { + if (this.loop) { + return dataset[index + 1] || dataset[0]; + } + return datasets[index + 1] || datasets[index]; + }, + previousElement: function previousElement(datasets, index, loop) { + if (this.loop) { + return dataset[index - 1] || dataset[dataset.length - 1]; + } + return datasets[index - 1] || datasets[index]; + }, + + // Get the single element that was clicked on + // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw + getElementAtEvent: function getElementAtEvent(e) { + + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + + getElementsAtEvent: function getElementsAtEvent(e) { + + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + + getDatasetAtEvent: function getDatasetAtEvent(e) { + + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + + generateLegend: function generateLegend() { + return template(this.options.legendTemplate, this); + }, + + destroy: function destroy() { + this.clear(); + helpers.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]; + }, + + toBase64Image: function toBase64Image() { + return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments); + }, + + initToolTip: function initToolTip() { + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + }, + + bindEvents: function bindEvents() { + helpers.bindEvents(this, this.options.events, function(evt) { + this.eventHandler(evt); + }); + }, + eventHandler: function eventHandler(e) { + this.lastActive = this.lastActive || []; + + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.elementController.getElementAtEvent(e); + case 'label': + return this.elementController.getElementsAtEvent(e); + case 'dataset': + return this.elementController.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + this.elementController.resetElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + this.elementController.resetElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + this.elementController.setElementHoverStyle(this.active[0]); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + this.elementController.setElementHoverStyle(this.active[i]); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + }); - Chart.defaults.global.elements.arc = { - backgroundColor: Chart.defaults.global.defaultColor, - borderColor: "#fff", - borderWidth: 2 - }; +}).call(this); - Chart.Arc = Chart.Element.extend({ - inGroupRange: function(mouseX) { - var vm = this._view; +(function() { + + "use strict"; + + //Declare root variable - window in the browser, global on the server + var root = this, + previous = root.Chart, + helpers = Chart.helpers; + + + // Attach global event to resize each chart instance when the browser resizes + helpers.addEvent(window, "resize", (function() { + // Basic debounce of resize function so it doesn't hurt performance when resizing browser. + var timeout; + return function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + each(Chart.instances, function(instance) { + // If the responsive flag is set in the chart instance config + // Cascade the resize event down to the chart. + if (instance.options.responsive) { + instance.resize(); + instance.update(); + } + }); + }, 50); + }; + })()); - if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); - } else { - return false; - } - }, - inRange: function(chartX, chartY) { +}).call(this); - var vm = this._view; +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + // The scale service is used to resize charts along with all of their axes. We make this as + // a service where scales are registered with their respective charts so that changing the + // scales does not require + Chart.scaleService = { + // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then + // use the new chart options to grab the correct scale + constructors: {}, + // Use a registration function so that we can move to an ES6 map when we no longer need to support + // old browsers + // Scale config defaults + defaults: {}, + registerScaleType: function(type, scaleConstructor, defaults) { + this.constructors[type] = scaleConstructor; + this.defaults[type] = defaults; + }, + getScaleConstructor: function(type) { + return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; + }, + getScaleDefaults: function(type) { + return this.defaults.hasOwnProperty(type) ? this.defaults[type] : {}; + }, + // The interesting function + fitScalesForChart: function(chartInstance, width, height) { + var xPadding = width > 30 ? 5 : 2; + var yPadding = height > 30 ? 5 : 2; + + if (chartInstance) { + var leftScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "left"; + }); + var rightScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "right"; + }); + var topScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "top"; + }); + var bottomScales = helpers.where(chartInstance.scales, function(scaleInstance) { + return scaleInstance.options.position == "bottom"; + }); + + // Essentially we now have any number of scales on each of the 4 sides. + // Our canvas looks like the following. + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and + // B1 is the bottom axis + // |------------------------------------------------------| + // | | T1 | | + // |----|-----|-------------------------------------|-----| + // | | | | | + // | L1 | L2 | Chart area | R1 | + // | | | | | + // | | | | | + // |----|-----|-------------------------------------|-----| + // | | B1 | | + // | | | | + // |------------------------------------------------------| + + // What we do to find the best sizing, we do the following + // 1. Determine the minimum size of the chart area. + // 2. Split the remaining width equally between each vertical axis + // 3. Split the remaining height equally between each horizontal axis + // 4. Give each scale the maximum size it can be. The scale will return it's minimum size + // 5. Adjust the sizes of each axis based on it's minimum reported size. + // 6. Refit each axis + // 7. Position each axis in the final location + // 8. Tell the chart the final location of the chart area + + // Step 1 + var chartWidth = width / 2; // min 50% + var chartHeight = height / 2; // min 50% + + chartWidth -= (2 * xPadding); + chartHeight -= (2 * yPadding); + + + // Step 2 + var verticalScaleWidth = (width - chartWidth) / (leftScales.length + rightScales.length); + + // Step 3 + var horizontalScaleHeight = (height - chartHeight) / (topScales.length + bottomScales.length); + + // Step 4; + var minimumScaleSizes = []; + + var verticalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(verticalScaleWidth, chartHeight); + minimumScaleSizes.push({ + horizontal: false, + minSize: minSize, + scale: scaleInstance, + }); + }; + + var horizontalScaleMinSizeFunction = function(scaleInstance) { + var minSize = scaleInstance.fit(chartWidth, horizontalScaleHeight); + minimumScaleSizes.push({ + horizontal: true, + minSize: minSize, + scale: scaleInstance, + }); + }; + + // vertical scales + helpers.each(leftScales, verticalScaleMinSizeFunction); + helpers.each(rightScales, verticalScaleMinSizeFunction); + + // horizontal scales + helpers.each(topScales, horizontalScaleMinSizeFunction); + helpers.each(bottomScales, horizontalScaleMinSizeFunction); + + // Step 5 + var maxChartHeight = height - (2 * yPadding); + var maxChartWidth = width - (2 * xPadding); + + helpers.each(minimumScaleSizes, function(wrapper) { + if (wrapper.horizontal) { + maxChartHeight -= wrapper.minSize.height; + } else { + maxChartWidth -= wrapper.minSize.width; + } + }); + + // At this point, maxChartHeight and maxChartWidth are the size the chart area could + // be if the axes are drawn at their minimum sizes. + + // Step 6 + var verticalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight); + } + }; + + var horizontalScaleFitFunction = function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: totalLeftWidth, + right: totalRightWidth, + top: 0, + bottom: 0, + }; + + if (wrapper) { + scaleInstance.fit(maxChartWidth, wrapper.minSize.height, scaleMargin); + } + }; + + var totalLeftWidth = xPadding; + var totalRightWidth = xPadding; + var totalTopHeight = yPadding; + var totalBottomHeight = yPadding; + + helpers.each(leftScales, verticalScaleFitFunction); + helpers.each(rightScales, verticalScaleFitFunction); + + // Figure out how much margin is on the left and right of the horizontal axes + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); + + helpers.each(rightScales, function(scaleInstance) { + totalRightWidth += scaleInstance.width; + }); + + helpers.each(topScales, horizontalScaleFitFunction); + helpers.each(bottomScales, horizontalScaleFitFunction); + + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; + }); + helpers.each(bottomScales, function(scaleInstance) { + totalBottomHeight += scaleInstance.height; + }); + + // Let the left scale know the final margin + helpers.each(leftScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + + helpers.each(rightScales, function(scaleInstance) { + var wrapper = helpers.findNextWhere(minimumScaleSizes, function(wrapper) { + return wrapper.scale === scaleInstance; + }); + + var scaleMargin = { + left: 0, + right: 0, + top: totalTopHeight, + bottom: totalBottomHeight + }; + + if (wrapper) { + scaleInstance.fit(wrapper.minSize.width, maxChartHeight, scaleMargin); + } + }); + + // Step 7 + // Position the scales + var left = xPadding; + var top = yPadding; + var right = 0; + var bottom = 0; + + var verticalScalePlacer = function(scaleInstance) { + scaleInstance.left = left; + scaleInstance.right = left + scaleInstance.width; + scaleInstance.top = totalTopHeight; + scaleInstance.bottom = totalTopHeight + maxChartHeight; + + // Move to next point + left = scaleInstance.right; + }; + + var horizontalScalePlacer = function(scaleInstance) { + scaleInstance.left = totalLeftWidth; + scaleInstance.right = totalLeftWidth + maxChartWidth; + scaleInstance.top = top; + scaleInstance.bottom = top + scaleInstance.height; + + // Move to next point + top = scaleInstance.bottom; + }; + + helpers.each(leftScales, verticalScalePlacer); + helpers.each(topScales, horizontalScalePlacer); + + // Account for chart width and height + left += maxChartWidth; + top += maxChartHeight; + + helpers.each(rightScales, verticalScalePlacer); + helpers.each(bottomScales, horizontalScalePlacer); + + // Step 8 + chartInstance.chartArea = { + left: totalLeftWidth, + top: totalTopHeight, + right: totalLeftWidth + maxChartWidth, + bottom: totalTopHeight + maxChartHeight, + }; + } + } + }; +}).call(this); - var pointRelativePosition = helpers.getAngleFromPoint(vm, { - x: chartX, - y: chartY - }); +(function() { - // Put into the range of (-PI/2, 3PI/2] - var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; - var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.tooltips = { + enabled: true, + custom: null, + backgroundColor: "rgba(0,0,0,0.8)", + fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + fontSize: 10, + fontStyle: "normal", + fontColor: "#fff", + titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + titleFontSize: 12, + titleFontStyle: "bold", + titleFontColor: "#fff", + yPadding: 6, + xPadding: 6, + caretSize: 8, + cornerRadius: 6, + xOffset: 10, + template: [ + '<% if(label){ %>', + '<%=label %>: ', + '<% } %>', + '<%=value %>', + ].join(''), + multiTemplate: [ + '<%if (datasetLabel){ %>', + '<%=datasetLabel %>: ', + '<% } %>', + '<%=value %>' + ].join(''), + multiKeyBackground: '#fff', + }; + + Chart.Tooltip = Chart.Element.extend({ + initialize: function() { + var options = this._options; + helpers.extend(this, { + _model: { + // Positioning + xPadding: options.tooltips.xPadding, + yPadding: options.tooltips.yPadding, + xOffset: options.tooltips.xOffset, + + // Labels + textColor: options.tooltips.fontColor, + _fontFamily: options.tooltips.fontFamily, + _fontStyle: options.tooltips.fontStyle, + fontSize: options.tooltips.fontSize, + + // Title + titleTextColor: options.tooltips.titleFontColor, + _titleFontFamily: options.tooltips.titleFontFamily, + _titleFontStyle: options.tooltips.titleFontStyle, + titleFontSize: options.tooltips.titleFontSize, + + // Appearance + caretHeight: options.tooltips.caretSize, + cornerRadius: options.tooltips.cornerRadius, + backgroundColor: options.tooltips.backgroundColor, + opacity: 0, + legendColorBackground: options.tooltips.multiKeyBackground, + }, + }); + }, + update: function() { + + var ctx = this._chart.ctx; + + switch (this._options.hover.mode) { + case 'single': + helpers.extend(this._model, { + text: helpers.template(this._options.tooltips.template, { + // These variables are available in the template function. Add others here + element: this._active[0], + value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], + label: this._data.labels ? this._data.labels[this._active[0]._index] : '', + }), + }); + + var tooltipPosition = this._active[0].tooltipPosition(); + helpers.extend(this._model, { + x: Math.round(tooltipPosition.x), + y: Math.round(tooltipPosition.y), + caretPadding: tooltipPosition.padding + }); + + break; + + case 'label': + + // Tooltip Content + + var dataArray, + dataIndex; + + var labels = [], + colors = []; + + for (var i = this._data.datasets.length - 1; i >= 0; i--) { + dataArray = this._data.datasets[i].metaData; + dataIndex = helpers.indexOf(dataArray, this._active[0]); + if (dataIndex !== -1) { + break; + } + } + + var medianPosition = (function(index) { + // Get all the points at that particular index + var elements = [], + dataCollection, + xPositions = [], + yPositions = [], + xMax, + yMax, + xMin, + yMin; + helpers.each(this._data.datasets, function(dataset) { + dataCollection = dataset.metaData; + if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) { + elements.push(dataCollection[dataIndex]); + } + }, this); + + // Reverse labels if stacked + helpers.each(this._options.stacked ? elements.reverse() : elements, function(element) { + xPositions.push(element._view.x); + yPositions.push(element._view.y); + + //Include any colour information about the element + labels.push(helpers.template(this._options.tooltips.multiTemplate, { + // These variables are available in the template function. Add others here + element: element, + datasetLabel: this._data.datasets[element._datasetIndex].label, + value: this._data.datasets[element._datasetIndex].data[element._index], + })); + colors.push({ + fill: element._view.backgroundColor, + stroke: element._view.borderColor + }); + + }, this); + + yMin = helpers.min(yPositions); + yMax = helpers.max(yPositions); + + xMin = helpers.min(xPositions); + xMax = helpers.max(xPositions); + + return { + x: (xMin > this._chart.width / 2) ? xMin : xMax, + y: (yMin + yMax) / 2, + }; + }).call(this, dataIndex); + + // Apply for now + helpers.extend(this._model, { + x: medianPosition.x, + y: medianPosition.y, + labels: labels, + title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', + legendColors: colors, + legendBackgroundColor: this._options.tooltips.multiKeyBackground, + }); + + + // Calculate Appearance Tweaks + + this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; + + var titleWidth = ctx.measureText(this.title).width, + //Label has a legend square as well so account for this. + labelWidth = helpers.longestText(ctx, this.font, labels) + this._model.fontSize + 3, + longestTextWidth = helpers.max([labelWidth, titleWidth]); + + this._model.width = longestTextWidth + (this._model.xPadding * 2); + + + var halfHeight = this._model.height / 2; + + //Check to ensure the height will fit on the canvas + if (this._model.y - halfHeight < 0) { + this._model.y = halfHeight; + } else if (this._model.y + halfHeight > this._chart.height) { + this._model.y = this._chart.height - halfHeight; + } + + //Decide whether to align left or right based on position on canvas + if (this._model.x > this._chart.width / 2) { + this._model.x -= this._model.xOffset + this._model.width; + } else { + this._model.x += this._model.xOffset; + } + break; + } + + return this; + }, + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._view; + + switch (this._options.hover.mode) { + case 'single': + + ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + + vm.xAlign = "center"; + vm.yAlign = "above"; + + //Distance between the actual element.y position and the start of the tooltip caret + var caretPadding = vm.caretPadding || 2; + + var tooltipWidth = ctx.measureText(vm.text).width + 2 * vm.xPadding, + tooltipRectHeight = vm.fontSize + 2 * vm.yPadding, + tooltipHeight = tooltipRectHeight + vm.caretHeight + caretPadding; + + if (vm.x + tooltipWidth / 2 > this._chart.width) { + vm.xAlign = "left"; + } else if (vm.x - tooltipWidth / 2 < 0) { + vm.xAlign = "right"; + } + + if (vm.y - tooltipHeight < 0) { + vm.yAlign = "below"; + } + + var tooltipX = vm.x - tooltipWidth / 2, + tooltipY = vm.y - tooltipHeight; + + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + + // Custom Tooltips + if (this._custom) { + this._custom(this._view); + } else { + switch (vm.yAlign) { + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } + + switch (vm.xAlign) { + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } + + helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); + + ctx.fill(); + + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); + + } + break; + case 'label': + + helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); + ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); + ctx.fill(); + ctx.closePath(); + + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillStyle = helpers.color(vm.titleTextColor).alpha(vm.opacity).rgbString(); + ctx.font = helpers.fontString(vm.fontSize, vm._titleFontStyle, vm._titleFontFamily); + ctx.fillText(vm.title, vm.x + vm.xPadding, this.getLineHeight(0)); + + ctx.font = helpers.fontString(vm.fontSize, vm._fontStyle, vm._fontFamily); + helpers.each(vm.labels, function(label, index) { + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.fillText(label, vm.x + vm.xPadding + vm.fontSize + 3, this.getLineHeight(index + 1)); + + //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas) + //ctx.clearRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize/2, vm.fontSize, vm.fontSize); + //Instead we'll make a white filled block to put the legendColour palette over. + + ctx.fillStyle = helpers.color(vm.legendColors[index].stroke).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding - 1, this.getLineHeight(index + 1) - vm.fontSize / 2 - 1, vm.fontSize + 2, vm.fontSize + 2); + + ctx.fillStyle = helpers.color(vm.legendColors[index].fill).alpha(vm.opacity).rgbString(); + ctx.fillRect(vm.x + vm.xPadding, this.getLineHeight(index + 1) - vm.fontSize / 2, vm.fontSize, vm.fontSize); + + + }, this); + break; + } + }, + getLineHeight: function(index) { + var baseLineHeight = this._view.y - (this._view.height / 2) + this._view.yPadding, + afterTitleIndex = index - 1; + + //If the index is zero, we're getting the title + if (index === 0) { + return baseLineHeight + this._view.titleFontSize / 2; + } else { + return baseLineHeight + ((this._view.fontSize * 1.5 * afterTitleIndex) + this._view.fontSize / 2) + this._view.titleFontSize * 1.5; + } + + }, + }); - //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), - withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); +}).call(this); - return (betweenAngles && withinRadius); - //Ensure within the outside of the arc centre, but inside arc outer - }, - tooltipPosition: function() { - var vm = this._view; +(function() { - var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), - rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; - return { - x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), - y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) - }; - }, - draw: function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.controllers.bar = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; + + helpers.extend(Chart.controllers.bar.prototype, { - var ctx = this._chart.ctx; - var vm = this._view; + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, + + linkScales: function() { + if (!this.getDataset().xAxisID) { + this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; + } + + if (!this.getDataset().yAxisID) { + this.getDataset().yAxisID = this.chart.options.scales.yAxes[0].id; + } + }, + + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, + + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + + addElements: function() { + this.getDataset().metaData = this.getDataset().metaData || []; + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Rectangle({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + }, this); + }, + + reset: function() { + this.update(true); + }, + + update: function(reset) { + + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var yScale = this.getScaleForId(this.getDataset().yAxisID); + helpers.each(this.getDataset().metaData, function(rectangle, index) { + + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } + + helpers.extend(rectangle, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), + y: reset ? yScalePoint : yScale.getPixelForValue(this.getDataset().data[index]), + + // Tooltip + label: this.chart.data.labels[index], + datasetLabel: this.getDataset().label, + + // Appearance + base: yScale.calculateBarBase(this.index, index), + width: xScale.calculateBarWidth(this.chart.data.datasets.length), + backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), + borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), + borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), + }, + }); + rectangle.pivot(); + }, this); + }, + + draw: function(ease) { + var easingDecimal = ease || 1; + helpers.each(this.getDataset().metaData, function(rectangle, index) { + rectangle.transition(easingDecimal).draw(); + }, this); + }, + + + + + + + + + // eachLine: function eachLine(callback) { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { + // callback.call(this, dataset, datasetIndex); + // } + // }, this); + // }, + + // addLine: function addLine(dataset, datasetIndex) { + // if (dataset) { + // dataset.metaDataset = new Chart.Line({ + // _chart: this.chart.chart, + // _datasetIndex: datasetIndex, + // _points: dataset.metaData, + // }); + // } + // }, + + // addPoint: function addPoint(dataset, datasetIndex, index) { + // if (dataset) { + // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); + + // if (index < dataset.metaData.length) { + // dataset.metaData[index] = new Chart.Point({ + // _datasetIndex: datasetIndex, + // _index: index, + // _chart: this.chart.chart, + // _model: { + // x: 0, + // y: 0, + // }, + // }); + // } + // } + // }, + + + + // resetElements: function resetElements() { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.resetDatasetPoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (bars) + // this.resetDatasetRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { + // helpers.each(dataset.metaData, function(point, index) { + // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + // var yScalePoint; + + // if (yScale.min < 0 && yScale.max < 0) { + // // all less than 0. use the top + // yScalePoint = yScale.getPixelForValue(yScale.max); + // } else if (yScale.min > 0 && yScale.max > 0) { + // yScalePoint = yScale.getPixelForValue(yScale.min); + // } else { + // yScalePoint = yScale.getPixelForValue(0); + // } + + // helpers.extend(point, { + // // Utility + // _chart: this.chart.chart, //WTF + // _xScale: xScale, + // _yScale: yScale, + // _datasetIndex: datasetIndex, + // _index: index, + + // // Desired view properties + // _model: { + // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // y: yScalePoint, + // }, + // }); + + // this.updatePointElementAppearance(point, datasetIndex, index); + // }, this); + + // this.updateBezierControlPoints(dataset); + // }, + + // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { + + // }, + + // resetElementAppearance: function(element, datasetIndex, index) { + // if (element instanceof Chart.Point) { + // this.updatePointElementAppearance(element, datasetIndex, index); + // } else if (element instanceof Chart.Rectangle) { + // this.updateRectangleElementAppearance(element, datasetIndex, index); + // } + // }, + + // updateElements: function updateElements() { + // // Update the lines + // this.updateLines(); + + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.updatePoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (bars) + // this.updateRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + // updateLines: function updateLines() { + // this.eachLine(function(dataset, datasetIndex) { + // var yScale = this.getScaleForId(dataset.yAxisID); + // var scaleBase; + + // if (yScale.min < 0 && yScale.max < 0) { + // scaleBase = yScale.getPixelForValue(yScale.max); + // } else if (yScale.min > 0 && yScale.max > 0) { + // scaleBase = yScale.getPixelForValue(yScale.min); + // } else { + // scaleBase = yScale.getPixelForValue(0); + // } + + // helpers.extend(dataset.metaDataset, { + // // Utility + // _scale: yScale, + // _datasetIndex: datasetIndex, + // // Data + // _children: dataset.metaData, + // // Model + // _model: { + // // Appearance + // tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chart.options.elements.line.tension), + // backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chart.options.elements.line.backgroundColor), + // borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chart.options.elements.line.borderWidth), + // borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chart.options.elements.line.borderColor), + // fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chart.options.elements.line.fill), + // skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chart.options.elements.line.skipNull, + // drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chart.options.elements.line.drawNull, + // // Scale + // scaleTop: yScale.top, + // scaleBottom: yScale.bottom, + // scaleZero: scaleBase, + // }, + // }); + + // dataset.metaDataset.pivot(); + // }); + // }, + + // updatePoints: function updatePoints(dataset, datasetIndex) { + // helpers.each(dataset.metaData, function(point, index) { + // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + // helpers.extend(point, { + // // Utility + // _chart: this.chart.chart, + // _xScale: xScale, + // _yScale: yScale, + // _datasetIndex: datasetIndex, + // _index: index, + + // // Desired view properties + // _model: { + // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // y: yScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // }, + // }); + + // this.updatePointElementAppearance(point, datasetIndex, index); + // }, this); + + // this.updateBezierControlPoints(dataset); + // }, + + // updatePointElementAppearance: function updatePointElementAppearance(point, datasetIndex, index) { + // helpers.extend(point._model, { + // // Appearance + // tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + // radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), + // backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + // borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), + // borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + // skip: this.chart.data.datasets[datasetIndex].data[index] === null, + + // // Tooltip + // hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), + // }); + // }, + + + // setElementHoverStyle: function setElementHoverStyle(element) { + // if (element instanceof Chart.Point) { + // this.setPointHoverStyle(element); + // } else if (element instanceof Chart.Rectangle) { + // this.setRectangleHoverStyle(element); + // } + // }, + + // setPointHoverStyle: function setPointHoverStyle(point) { + // var dataset = this.chart.data.datasets[point._datasetIndex]; + // var index = point._index; + + // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + // }, + + // setHoverStyle: function(rectangle) { + // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + // var index = rectangle._index; + + // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + // }, + + // updateBezierControlPoints: function updateBezierControlPoints(dataset) { + // // Update control points for the bezier curve + // helpers.each(dataset.metaData, function(point, index) { + // var controlPoints = helpers.splineCurve( + // this.previousPoint(dataset.metaData, index)._model, + // point._model, + // this.nextPoint(dataset.metaData, index)._model, + // point._model.tension + // ); + + // point._model.controlPointPreviousX = controlPoints.previous.x; + // point._model.controlPointNextX = controlPoints.next.x; + + // // Prevent the bezier going outside of the bounds of the graph + + // // Cap puter bezier handles to the upper/lower scale bounds + // if (controlPoints.next.y > this.chart.chartArea.bottom) { + // point._model.controlPointNextY = this.chart.chartArea.bottom; + // } else if (controlPoints.next.y < this.chart.chartArea.top) { + // point._model.controlPointNextY = this.chart.chartArea.top; + // } else { + // point._model.controlPointNextY = controlPoints.next.y; + // } + + // // Cap inner bezier handles to the upper/lower scale bounds + // if (controlPoints.previous.y > this.chart.chartArea.bottom) { + // point._model.controlPointPreviousY = this.chart.chartArea.bottom; + // } else if (controlPoints.previous.y < this.chart.chartArea.top) { + // point._model.controlPointPreviousY = this.chart.chartArea.top; + // } else { + // point._model.controlPointPreviousY = controlPoints.previous.y; + // } + + // // Now pivot the point for animation + // point.pivot(); + // }, this); + // }, + + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.chart.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + + // // Get the single element that was clicked on + // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + }); - ctx.beginPath(); - ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); - ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); +}).call(this); - ctx.closePath(); - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; +(function() { - ctx.fillStyle = vm.backgroundColor; + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.controllers.line = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; + + helpers.extend(Chart.controllers.line.prototype, { + + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, + + linkScales: function() { + if (!this.getDataset().xAxisID) { + this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; + } + + if (!this.getDataset().yAxisID) { + this.getDataset().yAxisID = this.chart.options.scales.yAxes[0].id; + } + }, + + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, + + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + + addElements: function() { + + this.getDataset().metaData = this.getDataset().metaData || []; + + this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _points: this.getDataset().metaData, + }); + + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + }, this); + }, + + reset: function() { + this.update(true); + }, + + update: function(reset) { + + var line = this.getDataset().metaDataset; + var points = this.getDataset().metaData; + + var yScale = this.getScaleForId(this.getDataset().yAxisID); + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + + // Update Line + helpers.extend(line, { + // Utility + _scale: yScale, + _datasetIndex: this.index, + // Data + _children: points, + // Model + _model: { + // Appearance + tension: line.custom && line.custom.tension ? line.custom.tension : (this.getDataset().tension || this.chart.options.elements.line.tension), + backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor), + borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth), + borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor), + fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill), + skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, + drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: scaleBase, + }, + }); + line.pivot(); + + // Update Points + helpers.each(points, function(point, index) { + helpers.extend(point, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + + }); + }, this); + + // Update bezier control points + helpers.each(this.getDataset().metaData, function(point, index) { + var controlPoints = helpers.splineCurve( + helpers.previousItem(this.getDataset().metaData, index)._model, + point._model, + helpers.nextItem(this.getDataset().metaData, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chart.chartArea.bottom) { + point._model.controlPointNextY = this.chart.chartArea.bottom; + } else if (controlPoints.next.y < this.chart.chartArea.top) { + point._model.controlPointNextY = this.chart.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chart.chartArea.bottom) { + point._model.controlPointPreviousY = this.chart.chartArea.bottom; + } else if (controlPoints.previous.y < this.chart.chartArea.top) { + point._model.controlPointPreviousY = this.chart.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + }, + + draw: function(ease) { + var easingDecimal = ease || 1; + + // Transition Point Locations + helpers.each(this.getDataset().metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + this.getDataset().metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(this.getDataset().metaData, function(point) { + point.draw(); + }); + }, + + + + + + + + + // eachLine: function eachLine(callback) { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { + // callback.call(this, dataset, datasetIndex); + // } + // }, this); + // }, + + // addPoint: function addPoint(dataset, datasetIndex, index) { + // if (dataset) { + // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); + + // if (index < dataset.metaData.length) { + // dataset.metaData[index] = new Chart.Point({ + // _datasetIndex: datasetIndex, + // _index: index, + // _chart: this.chart.chart, + // _model: { + // x: 0, + // y: 0, + // }, + // }); + // } + // } + // }, + + + + // resetElements: function resetElements() { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.resetDatasetPoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (lines) + // this.resetDatasetRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { + // helpers.each(dataset.metaData, function(point, index) { + // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + // var yScalePoint; + + // if (yScale.min < 0 && yScale.max < 0) { + // // all less than 0. use the top + // yScalePoint = yScale.getPixelForValue(yScale.max); + // } else if (yScale.min > 0 && yScale.max > 0) { + // yScalePoint = yScale.getPixelForValue(yScale.min); + // } else { + // yScalePoint = yScale.getPixelForValue(0); + // } + + // helpers.extend(point, { + // // Utility + // _chart: this.chart.chart, //WTF + // _xScale: xScale, + // _yScale: yScale, + // _datasetIndex: datasetIndex, + // _index: index, + + // // Desired view properties + // _model: { + // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // y: yScalePoint, + // }, + // }); + + // this.updatePointElementAppearance(point, datasetIndex, index); + // }, this); + + // this.updateBezierControlPoints(dataset); + // }, + + // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { + + // }, + + // resetElementAppearance: function(element, datasetIndex, index) { + // if (element instanceof Chart.Point) { + // this.updatePointElementAppearance(element, datasetIndex, index); + // } else if (element instanceof Chart.Rectangle) { + // this.updateRectangleElementAppearance(element, datasetIndex, index); + // } + // }, + + // updateElements: function updateElements() { + // // Update the lines + // this.updateLines(); + + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.updatePoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (lines) + // this.updateRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + + // setElementHoverStyle: function setElementHoverStyle(element) { + // if (element instanceof Chart.Point) { + // this.setPointHoverStyle(element); + // } else if (element instanceof Chart.Rectangle) { + // this.setRectangleHoverStyle(element); + // } + // }, + + // setPointHoverStyle: function setPointHoverStyle(point) { + // var dataset = this.chart.data.datasets[point._datasetIndex]; + // var index = point._index; + + // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + // }, + + // setHoverStyle: function(rectangle) { + // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + // var index = rectangle._index; + + // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + // }, + + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.chart.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + + // // Get the single element that was clicked on + // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + }); - ctx.fill(); - ctx.lineJoin = 'bevel'; - if (vm.borderWidth) { - ctx.stroke(); - } - } - }); +}).call(this); +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + // Default config for a category scale + var defaultConfig = { + display: true, + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, + + // label settings + labels: { + show: true, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }; + + var DatasetScale = Chart.Element.extend({ + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + getPixelForValue: function(value, index, datasetIndex, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.data.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.data.labels.length)); + } + }, + getPointPixelForValue: function(value, index, datasetIndex) { + return this.getPixelForValue(value, index, datasetIndex, true); + }, + + // Functions needed for bar charts + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); + + if (this.options.stacked) { + return baseWidth; + } + return (baseWidth / datasetCount); + }, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); + + if (this.options.stacked) { + return xAbsolute + barWidth / 2; + } + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; + }, + + calculateLabelRotation: function(maxHeight, margins) { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstWidth = this.ctx.measureText(this.data.labels[0]).width; + var lastWidth = this.ctx.measureText(this.data.labels[this.data.labels.length - 1]).width; + var firstRotated; + var lastRotated; + + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; + + this.labelRotation = 0; + + if (this.options.display) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; + + this.labelWidth = originalLabelWidth; + + //Allow 3 pixels x2 padding either side for label readability + // only the index matters for a dataset scale, but we want a consistent interface between scales + var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + + //Max label rotate should be 90 - also act as a loop counter + while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; + } + + this.paddingRight = this.options.labels.fontSize / 2; + + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } + + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; + + } + } else { + this.labelWidth = 0; + this.paddingRight = 0; + this.paddingLeft = 0; + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + } + + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight, margins) { + this.calculateLabelRotation(maxHeight, margins); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; + this.width = maxWidth; + } else if (this.options.display) { + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + // Height + if (this.isHorizontal() && this.options.display) { + var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else if (this.options.display) { + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + + helpers.each(this.data.labels, function(label, index) { + var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } + + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) {} + + if (this.options.labels.show) { + // Draw the labels + } + } + } + } + }); + Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig); }).call(this); -/*! - * Chart.js - * http://chartjs.org/ - * Version: 2.0.0-alpha - * - * Copyright 2015 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + display: true, + position: "left", + id: "y-axis-1", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + beginAtZero: false, + override: null, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + } + }; + + var LinearScale = Chart.Element.extend({ + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + generateTicks: function(width, height) { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks; + + if (this.isHorizontal()) { + maxTicks = Math.min(11, Math.ceil(width / 50)); + } else { + // The factor of 2 used to scale the font size has been experimentally determined. + maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); + } + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + this.labels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.labels.push(label ? label : ""); // empty string will not render so we're good + }, this); + }, + // Get the correct value. If the value type is object get the x or y based on whether we are horizontal or not + getRightValue: function(rawValue) { + return typeof rawValue === "object" ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; + }, + getPixelForValue: function(value) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + var pixel; + var range = this.max - this.min; + + if (this.isHorizontal()) { + pixel = this.left + (this.width / range * (value - this.min)); + } else { + // Bottom - top since pixels increase downard on a screen + pixel = this.bottom - (this.height / range * (value - this.min)); + } + + return pixel; + }, + + // Functions needed for line charts + calculateRange: function() { + this.min = null; + this.max = null; + + var positiveValues = []; + var negativeValues = []; + + if (this.options.stacked) { + helpers.each(this.data.datasets, function(dataset) { + if (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(rawValue, index) { + + var value = this.getRightValue(rawValue); + + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + + if (this.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); + } + }, this); + + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); + + } else { + helpers.each(this.data.datasets, function(dataset) { + if (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(rawValue, index) { + var value = this.getRightValue(rawValue); + + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + }, + + getPointPixelForValue: function(rawValue, index, datasetIndex) { + var value = this.getRightValue(rawValue); + + if (this.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + + for (var i = 0; i < datasetIndex; ++i) { + if (this.data.datasets[i].data[index] < 0) { + offsetNeg += this.data.datasets[i].data[index]; + } else { + offsetPos += this.data.datasets[i].data[index]; + } + } + + if (value < 0) { + return this.getPixelForValue(offsetNeg + value); + } else { + return this.getPixelForValue(offsetPos + value); + } + } else { + return this.getPixelForValue(value); + } + }, + + // Functions needed for bar charts + calculateBarBase: function(datasetIndex, index) { + var base = 0; + + if (this.options.stacked) { + + var value = this.data.datasets[datasetIndex].data[index]; + + if (value < 0) { + for (var i = 0; i < datasetIndex; i++) { + if (this.data.datasets[i].yAxisID === this.id) { + base += this.data.datasets[i].data[index] < 0 ? this.data.datasets[i].data[index] : 0; + } + } + } else { + for (var j = 0; j < datasetIndex; j++) { + if (this.data.datasets[j].yAxisID === this.id) { + base += this.data.datasets[j].data[index] > 0 ? this.data.datasets[j].data[index] : 0; + } + } + } + + return this.getPixelForValue(base); + } + + base = this.getPixelForValue(this.min); + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.getPixelForValue(0); + base += this.options.gridLines.lineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.getPixelForValue(this.max); + } + + return base; + + }, + calculateBarY: function(datasetIndex, index) { + var value = this.data.datasets[datasetIndex].data[index]; + + if (this.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (this.data.datasets[i].data[index] < 0) { + sumNeg += this.data.datasets[i].data[index] || 0; + } else { + sumPos += this.data.datasets[i].data[index] || 0; + } + } + + if (value < 0) { + return this.getPixelForValue(sumNeg + value); + } else { + return this.getPixelForValue(sumPos + value); + } + + return this.getPixelForValue(value); + } + + var offset = 0; + + for (var j = datasetIndex; j < this.data.datasets.length; j++) { + if (j === datasetIndex && value) { + offset += value; + } else { + offset = offset + value; + } + } + + return this.getPixelForValue(value); + }, + + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight) { + this.calculateRange(); + this.generateTicks(maxWidth, maxHeight); + this.buildLabels(); + + var minSize = { + width: 0, + height: 0, + }; + + // In a horizontal axis, we need some room for the scale to be drawn + // + // ----------------------------------------------------- + // | | | | | + // + // In a vertical axis, we need some room for the scale to be drawn. + // The actual grid lines will be drawn on the chart area, however, we need to show + // ticks where the axis actually is. + // We will allocate 25px for this width + // | + // -| + // | + // | + // -| + // | + // | + // -| + + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; // fill all the width + } else { + minSize.width = this.options.gridLines.show && this.options.display ? 10 : 0; + } + + // height + if (this.isHorizontal()) { + minSize.height = this.options.gridLines.show && this.options.display ? 10 : 0; + } else { + minSize.height = maxHeight; // fill all the height + } + + + + if (this.options.labels.show && this.options.display) { + // Don't bother fitting the labels if we are not showing them + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.isHorizontal()) { + // A horizontal axis is more constrained by the height. + var maxLabelHeight = maxHeight - minSize.height; + var labelHeight = 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + } else { + // A vertical axis is more constrained by the width. Labels are the dominant factor + // here, so get that length first + var maxLabelWidth = maxWidth - minSize.width; + var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (largestTextWidth < maxLabelWidth) { + // We don't need all the room + minSize.width += largestTextWidth; + } else { + // Expand to max size + minSize.width = maxWidth; + } + } + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + var hasZero; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + if (this.options.gridLines.show) { + // Draw the horizontal line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; + var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are vertical + var xValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the left if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xValue, chartArea.top); + this.ctx.lineTo(xValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartY; + + if (this.options.position == "top") { + labelStartY = this.bottom - 10; + this.ctx.textBaseline = "bottom"; + } else { + // bottom side + labelStartY = this.top + 10; + this.ctx.textBaseline = "top"; + } + + this.ctx.textAlign = "center"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var xValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, xValue, labelStartY); + }, this); + } + } else { + // Vertical + if (this.options.gridLines.show) { + + // Draw the vertical line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var xTickStart = this.options.position == "right" ? this.left : this.right - 5; + var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are horizontal + var yValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the bottom if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; // use boolean to indicate that we only want to do this once + } + + yValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(chartArea.left, yValue); + this.ctx.lineTo(chartArea.right, yValue); + } + + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartX; + + if (this.options.position == "left") { + labelStartX = this.right - 10; + this.ctx.textAlign = "right"; + } else { + // right side + labelStartX = this.left + 5; + this.ctx.textAlign = "left"; + } + + this.ctx.textBaseline = "middle"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var yValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, labelStartX, yValue); + }, this); + } + } + } + } + }); + Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig); +}).call(this); (function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + display: true, + + //Boolean - Whether to animate scaling the chart from the centre + animate: false, + + lineArc: false, + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + }, + + angleLines: { + show: true, + color: "rgba(0,0,0, 0.1)", + lineWidth: 1 + }, + + // scale numbers + beginAtZero: true, + + // label settings + labels: { + show: true, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + + //Boolean - Show a backdrop to the scale label + showLabelBackdrop: true, + + //String - The colour of the label backdrop + backdropColor: "rgba(255,255,255,0.75)", + + //Number - The backdrop padding above & below the label in pixels + backdropPaddingY: 2, + + //Number - The backdrop padding to the side of the label in pixels + backdropPaddingX: 2, + }, + + pointLabels: { + //String - Point label font declaration + fontFamily: "'Arial'", + + //String - Point label font weight + fontStyle: "normal", + + //Number - Point label font size in pixels + fontSize: 10, + + //String - Point label font colour + fontColor: "#666", + }, + }; + + var LinearRadialScale = Chart.Element.extend({ + initialize: function() { + this.size = helpers.min([this.height, this.width]); + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); + }, + update: function() { + if (!this.options.lineArc) { + this.setScaleSize(); + } else { + this.drawingArea = (this.options.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2); + } + + this.buildYLabels(); + }, + calculateRange: function() { + this.min = null; + this.max = null; + + helpers.each(this.data.datasets, function(dataset) { + helpers.each(dataset.data, function(value, index) { + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + }, this); + }, + generateTicks: function() { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (2 * this.options.labels.fontSize))); + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + } + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + }, + buildYLabels: function() { + this.yLabels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.yLabels.push(label ? label : ""); + }, this); + }, + getCircumference: function() { + return ((Math.PI * 2) / this.valuesCount); + }, + setScaleSize: function() { + /* + * Right, this is really confusing and there is a lot of maths going on here + * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 + * + * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif + * + * Solution: + * + * We assume the radius of the polygon is half the size of the canvas at first + * at each index we check if the text overlaps. + * + * Where it does, we store that angle and that index. + * + * After finding the largest index and angle we calculate how much we need to remove + * from the shape radius to move the point inwards by that x. + * + * We average the left and right distances to get the maximum shape radius that can fit in the box + * along with labels. + * + * Once we have that, we can find the centre point for the chart, by taking the x text protrusion + * on each side, removing that from the size, halving it and adding the left x protrusion width. + * + * This will mean we have a shape fitted to the canvas, as large as it can be with the labels + * and position it in the most space efficient manner + * + * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif + */ + + + // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width. + // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points + var largestPossibleRadius = helpers.min([(this.height / 2 - this.options.pointLabels.fontSize - 5), this.width / 2]), + pointPosition, + i, + textWidth, + halfTextWidth, + furthestRight = this.width, + furthestRightIndex, + furthestRightAngle, + furthestLeft = 0, + furthestLeftIndex, + furthestLeftAngle, + xProtrusionLeft, + xProtrusionRight, + radiusReductionRight, + radiusReductionLeft, + maxWidthRadius; + this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + for (i = 0; i < this.valuesCount; i++) { + // 5px to space the text slightly out - similar to what we do in the draw function. + pointPosition = this.getPointPosition(i, largestPossibleRadius); + textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { + value: this.labels[i] + })).width + 5; + if (i === 0 || i === this.valuesCount / 2) { + // If we're at index zero, or exactly the middle, we're at exactly the top/bottom + // of the radar chart, so text will be aligned centrally, so we'll half it and compare + // w/left and right text sizes + halfTextWidth = textWidth / 2; + if (pointPosition.x + halfTextWidth > furthestRight) { + furthestRight = pointPosition.x + halfTextWidth; + furthestRightIndex = i; + } + if (pointPosition.x - halfTextWidth < furthestLeft) { + furthestLeft = pointPosition.x - halfTextWidth; + furthestLeftIndex = i; + } + } else if (i < this.valuesCount / 2) { + // Less than half the values means we'll left align the text + if (pointPosition.x + textWidth > furthestRight) { + furthestRight = pointPosition.x + textWidth; + furthestRightIndex = i; + } + } else if (i > this.valuesCount / 2) { + // More than half the values means we'll right align the text + if (pointPosition.x - textWidth < furthestLeft) { + furthestLeft = pointPosition.x - textWidth; + furthestLeftIndex = i; + } + } + } + + xProtrusionLeft = furthestLeft; + + xProtrusionRight = Math.ceil(furthestRight - this.width); + + furthestRightAngle = this.getIndexAngle(furthestRightIndex); + + furthestLeftAngle = this.getIndexAngle(furthestLeftIndex); + + radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2); + + radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2); + + // Ensure we actually need to reduce the size of the chart + radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0; + radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0; + + this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2; + + //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2]) + this.setCenterPoint(radiusReductionLeft, radiusReductionRight); + + }, + setCenterPoint: function(leftMovement, rightMovement) { + + var maxRight = this.width - rightMovement - this.drawingArea, + maxLeft = leftMovement + this.drawingArea; + + this.xCenter = (maxLeft + maxRight) / 2; + // Always vertically in the centre as the text height doesn't change + this.yCenter = (this.height / 2); + }, + + getIndexAngle: function(index) { + var angleMultiplier = (Math.PI * 2) / this.valuesCount; + // Start from the top instead of right, so remove a quarter of the circle + + return index * angleMultiplier - (Math.PI / 2); + }, + getDistanceFromCenterForValue: function(value) { + // Take into account half font size + the yPadding of the top value + var scalingFactor = this.drawingArea / (this.max - this.min); + return (value - this.min) * scalingFactor; + }, + getPointPosition: function(index, distanceFromCenter) { + var thisAngle = this.getIndexAngle(index); + return { + x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter, + y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter + }; + }, + getPointPositionForValue: function(index, value) { + return this.getPointPosition(index, this.getDistanceFromCenterForValue(value)); + }, + draw: function() { + if (this.options.display) { + var ctx = this.ctx; + helpers.each(this.yLabels, function(label, index) { + // Don't draw a centre value + if (index > 0) { + var yCenterOffset = this.getDistanceFromCenterForValue(this.ticks[index]); + var yHeight = this.yCenter - yCenterOffset; + + // Draw circular lines around the scale + if (this.options.gridLines.show) { + ctx.strokeStyle = this.options.gridLines.color; + ctx.lineWidth = this.options.gridLines.lineWidth; + + if (this.options.lineArc) { + // Draw circular arcs between the points + ctx.beginPath(); + ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2); + ctx.closePath(); + ctx.stroke(); + } else { + // Draw straight lines connecting each index + ctx.beginPath(); + for (var i = 0; i < this.valuesCount; i++) { + var pointPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.ticks[index])); + if (i === 0) { + ctx.moveTo(pointPosition.x, pointPosition.y); + } else { + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + } + } + + if (this.options.labels.show) { + ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.options.labels.showLabelBackdrop) { + var labelWidth = ctx.measureText(label).width; + ctx.fillStyle = this.options.labels.backdropColor; + ctx.fillRect( + this.xCenter - labelWidth / 2 - this.options.labels.backdropPaddingX, + yHeight - this.fontSize / 2 - this.options.labels.backdropPaddingY, + labelWidth + this.options.labels.backdropPaddingX * 2, + this.options.labels.fontSize + this.options.labels.backdropPaddingY * 2 + ); + } + + ctx.textAlign = 'center'; + ctx.textBaseline = "middle"; + ctx.fillStyle = this.options.labels.fontColor; + ctx.fillText(label, this.xCenter, yHeight); + } + } + }, this); + + if (!this.options.lineArc) { + ctx.lineWidth = this.options.angleLines.lineWidth; + ctx.strokeStyle = this.options.angleLines.color; + + for (var i = this.valuesCount - 1; i >= 0; i--) { + if (this.options.angleLines.show) { + var outerPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max)); + ctx.beginPath(); + ctx.moveTo(this.xCenter, this.yCenter); + ctx.lineTo(outerPosition.x, outerPosition.y); + ctx.stroke(); + ctx.closePath(); + } + // Extra 3px out for some label spacing + var pointLabelPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max) + 5); + ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); + ctx.fillStyle = this.options.pointLabels.fontColor; + + var labelsCount = this.labels.length, + halfLabelsCount = this.labels.length / 2, + quarterLabelsCount = halfLabelsCount / 2, + upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount), + exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount); + if (i === 0) { + ctx.textAlign = 'center'; + } else if (i === halfLabelsCount) { + ctx.textAlign = 'center'; + } else if (i < halfLabelsCount) { + ctx.textAlign = 'left'; + } else { + ctx.textAlign = 'right'; + } + + // Set the correct text baseline based on outer positioning + if (exactQuarter) { + ctx.textBaseline = 'middle'; + } else if (upperHalf) { + ctx.textBaseline = 'bottom'; + } else { + ctx.textBaseline = 'top'; + } + + ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y); + } + } + } + } + }); + Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale, defaultConfig); - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.elements.line = { - tension: 0.4, - backgroundColor: Chart.defaults.global.defaultColor, - borderWidth: 3, - borderColor: Chart.defaults.global.defaultColor, - fill: true, // do we fill in the area between the line and its base axis - skipNull: true, - drawNull: false, - }; - - - Chart.Line = Chart.Element.extend({ - draw: function() { - - var vm = this._view; - var ctx = this._chart.ctx; - var first = this._children[0]; - var last = this._children[this._children.length - 1]; - - // Draw the background first (so the border is always on top) - helpers.each(this._children, function(point, index) { - var previous = this.previousPoint(point, this._children, index); - var next = this.nextPoint(point, this._children, index); - - // First point only - if (index === 0) { - ctx.moveTo(point._view.x, point._view.y); - return; - } - - // Start Skip and drag along scale baseline - if (point._view.skip && vm.skipNull && !this._loop) { - ctx.lineTo(previous._view.x, point._view.y); - ctx.moveTo(next._view.x, point._view.y); - } - // End Skip Stright line from the base line - else if (previous._view.skip && vm.skipNull && !this._loop) { - ctx.moveTo(point._view.x, previous._view.y); - ctx.lineTo(point._view.x, point._view.y); - } - - if (previous._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, point._view.y); - } - // Normal Bezier Curve - else { - if (vm.tension > 0) { - ctx.bezierCurveTo( - previous._view.controlPointNextX, - previous._view.controlPointNextY, - point._view.controlPointPreviousX, - point._view.controlPointPreviousY, - point._view.x, - point._view.y - ); - } else { - ctx.lineTo(point._view.x, point._view.y); - } - } - }, this); - - // For radial scales, loop back around to the first point - if (this._loop) { - if (vm.tension > 0 && !first._view.skip) { - - ctx.bezierCurveTo( - last._view.controlPointNextX, - last._view.controlPointNextY, - first._view.controlPointPreviousX, - first._view.controlPointPreviousY, - first._view.x, - first._view.y - ); - } else { - ctx.lineTo(first._view.x, first._view.y); - } - } - - // If we had points and want to fill this line, do so. - if (this._children.length > 0 && vm.fill) { - //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero); - ctx.lineTo(this._children[0]._view.x, vm.scaleZero); - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; - ctx.closePath(); - ctx.fill(); - } - - - // Now draw the line between all the points with any borders - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; - ctx.beginPath(); - - helpers.each(this._children, function(point, index) { - var previous = this.previousPoint(point, this._children, index); - var next = this.nextPoint(point, this._children, index); - - // First point only - if (index === 0) { - ctx.moveTo(point._view.x, point._view.y); - return; - } - - // Start Skip and drag along scale baseline - if (point._view.skip && vm.skipNull && !this._loop) { - ctx.moveTo(previous._view.x, point._view.y); - ctx.moveTo(next._view.x, point._view.y); - return; - } - // End Skip Stright line from the base line - if (previous._view.skip && vm.skipNull && !this._loop) { - ctx.moveTo(point._view.x, previous._view.y); - ctx.moveTo(point._view.x, point._view.y); - return; - } - - if (previous._view.skip && vm.skipNull) { - ctx.moveTo(point._view.x, point._view.y); - return; - } - // Normal Bezier Curve - if (vm.tension > 0) { - ctx.bezierCurveTo( - previous._view.controlPointNextX, - previous._view.controlPointNextY, - point._view.controlPointPreviousX, - point._view.controlPointPreviousY, - point._view.x, - point._view.y - ); - } else { - ctx.lineTo(point._view.x, point._view.y); - } - }, this); - - if (this._loop && !first._view.skip) { - if (vm.tension > 0) { - - ctx.bezierCurveTo( - last._view.controlPointNextX, - last._view.controlPointNextY, - first._view.controlPointPreviousX, - first._view.controlPointPreviousY, - first._view.x, - first._view.y - ); - } else { - ctx.lineTo(first._view.x, first._view.y); - } - } - - - ctx.stroke(); - - }, - nextPoint: function(point, collection, index) { - if (this.loop) { - return collection[index + 1] || collection[0]; - } - return collection[index + 1] || collection[collection.length - 1]; - }, - previousPoint: function(point, collection, index) { - if (this.loop) { - return collection[index - 1] || collection[collection.length - 1]; - } - return collection[index - 1] || collection[0]; - }, - }); }).call(this); @@ -3207,74 +4356,83 @@ (function() { - "use strict"; + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.arc = { + backgroundColor: Chart.defaults.global.defaultColor, + borderColor: "#fff", + borderWidth: 2 + }; + + Chart.Arc = Chart.Element.extend({ + inGroupRange: function(mouseX) { + var vm = this._view; + + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2)); + } else { + return false; + } + }, + inRange: function(chartX, chartY) { - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + var vm = this._view; - Chart.defaults.global.elements.point = { - radius: 3, - backgroundColor: Chart.defaults.global.defaultColor, - borderWidth: 1, - borderColor: Chart.defaults.global.defaultColor, - // Hover - hitRadius: 1, - hoverRadius: 4, - hoverBorderWidth: 1, - }; + var pointRelativePosition = helpers.getAngleFromPoint(vm, { + x: chartX, + y: chartY + }); + // Put into the range of (-PI/2, 3PI/2] + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle - Chart.Point = Chart.Element.extend({ - inRange: function(mouseX, mouseY) { - var vm = this._view; - var hoverRange = vm.hitRadius + vm.radius; - return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); - }, - inGroupRange: function(mouseX) { - var vm = this._view; + //Check if within the range of the open/close angle + var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), + withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); - if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); - } else { - return false; - } - }, - tooltipPosition: function() { - var vm = this._view; - return { - x: vm.x, - y: vm.y, - padding: vm.radius + vm.borderWidth - }; - }, - draw: function() { + return (betweenAngles && withinRadius); + //Ensure within the outside of the arc centre, but inside arc outer + }, + tooltipPosition: function() { + var vm = this._view; - var vm = this._view; - var ctx = this._chart.ctx; + var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2), + rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius; + return { + x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), + y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) + }; + }, + draw: function() { + var ctx = this._chart.ctx; + var vm = this._view; - if (vm.skip) { - return; - } + ctx.beginPath(); - if (vm.radius > 0 || vm.borderWidth > 0) { + ctx.arc(vm.x, vm.y, vm.outerRadius, vm.startAngle, vm.endAngle); - ctx.beginPath(); + ctx.arc(vm.x, vm.y, vm.innerRadius, vm.endAngle, vm.startAngle, true); - ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); - ctx.closePath(); + ctx.closePath(); + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; - ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; + ctx.fillStyle = vm.backgroundColor; - ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; + ctx.fill(); + ctx.lineJoin = 'bevel'; - ctx.fill(); - ctx.stroke(); - } - } - }); + if (vm.borderWidth) { + ctx.stroke(); + } + } + }); }).call(this); @@ -3292,3166 +4450,416 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - Chart.defaults.global.elements.rectangle = { - backgroundColor: Chart.defaults.global.defaultColor, - borderWidth: 0, - borderColor: Chart.defaults.global.defaultColor, - }; - - Chart.Rectangle = Chart.Element.extend({ - draw: function() { - - var ctx = this._chart.ctx; - var vm = this._view; - - var halfWidth = vm.width / 2, - leftX = vm.x - halfWidth, - rightX = vm.x + halfWidth, - top = vm.base - (vm.base - vm.y), - halfStroke = vm.borderWidth / 2; - - // Canvas doesn't allow us to stroke inside the width so we can - // adjust the sizes to fit if we're setting a stroke on the line - if (vm.borderWidth) { - leftX += halfStroke; - rightX -= halfStroke; - top += halfStroke; - } - - ctx.beginPath(); - - ctx.fillStyle = vm.backgroundColor; - ctx.strokeStyle = vm.borderColor; - ctx.lineWidth = vm.borderWidth; - - // It'd be nice to keep this class totally generic to any rectangle - // and simply specify which border to miss out. - ctx.moveTo(leftX, vm.base); - ctx.lineTo(leftX, top); - ctx.lineTo(rightX, top); - ctx.lineTo(rightX, vm.base); - ctx.fill(); - if (vm.borderWidth) { - ctx.stroke(); - } - }, - height: function() { - var vm = this._view; - return vm.base - vm.y; - }, - inRange: function(mouseX, mouseY) { - var vm = this._view; - if (vm.y < vm.base) { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); - } else { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); - } - }, - inGroupRange: function(mouseX) { - var vm = this._view; - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); - }, - tooltipPosition: function() { - var vm = this._view; - if (vm.y < vm.base) { - return { - x: vm.x, - y: vm.y - }; - } else { - return { - x: vm.x, - y: vm.base - }; - } - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.line = { + tension: 0.4, + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 3, + borderColor: Chart.defaults.global.defaultColor, + fill: true, // do we fill in the area between the line and its base axis + skipNull: true, + drawNull: false, + }; + + + Chart.elements.Line = Chart.Element.extend({ + draw: function() { + + var vm = this._view; + var ctx = this._chart.ctx; + var first = this._children[0]; + var last = this._children[this._children.length - 1]; + + // Draw the background first (so the border is always on top) + helpers.each(this._children, function(point, index) { + var previous = helpers.previousItem(this._children, index); + var next = helpers.nextItem(this._children, index); + + // First point only + if (index === 0) { + ctx.moveTo(point._view.x, point._view.y); + return; + } + + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.lineTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); + } + // End Skip Stright line from the base line + else if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); + ctx.lineTo(point._view.x, point._view.y); + } + + if (previous._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, point._view.y); + } + // Normal Bezier Curve + else { + if (vm.tension > 0) { + ctx.bezierCurveTo( + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y + ); + } else { + ctx.lineTo(point._view.x, point._view.y); + } + } + }, this); + + // For radial scales, loop back around to the first point + if (this._loop) { + if (vm.tension > 0 && !first._view.skip) { + + ctx.bezierCurveTo( + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y + ); + } else { + ctx.lineTo(first._view.x, first._view.y); + } + } + + // If we had points and want to fill this line, do so. + if (this._children.length > 0 && vm.fill) { + //Round off the line by going to the base of the chart, back to the start, then fill. + ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero); + ctx.lineTo(this._children[0]._view.x, vm.scaleZero); + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; + ctx.closePath(); + ctx.fill(); + } + + + // Now draw the line between all the points with any borders + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.beginPath(); + + helpers.each(this._children, function(point, index) { + var previous = helpers.previousItem(this._children, index); + var next = helpers.nextItem(this._children, index); + + // First point only + if (index === 0) { + ctx.moveTo(point._view.x, point._view.y); + return; + } + + // Start Skip and drag along scale baseline + if (point._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(previous._view.x, point._view.y); + ctx.moveTo(next._view.x, point._view.y); + return; + } + // End Skip Stright line from the base line + if (previous._view.skip && vm.skipNull && !this._loop) { + ctx.moveTo(point._view.x, previous._view.y); + ctx.moveTo(point._view.x, point._view.y); + return; + } + + if (previous._view.skip && vm.skipNull) { + ctx.moveTo(point._view.x, point._view.y); + return; + } + // Normal Bezier Curve + if (vm.tension > 0) { + ctx.bezierCurveTo( + previous._view.controlPointNextX, + previous._view.controlPointNextY, + point._view.controlPointPreviousX, + point._view.controlPointPreviousY, + point._view.x, + point._view.y + ); + } else { + ctx.lineTo(point._view.x, point._view.y); + } + }, this); + + if (this._loop && !first._view.skip) { + if (vm.tension > 0) { + + ctx.bezierCurveTo( + last._view.controlPointNextX, + last._view.controlPointNextY, + first._view.controlPointPreviousX, + first._view.controlPointPreviousY, + first._view.x, + first._view.y + ); + } else { + ctx.lineTo(first._view.x, first._view.y); + } + } + + + ctx.stroke(); + + }, + }); }).call(this); +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.0.0-alpha + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ + + (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - - stacked: false, - valueSpacing: 5, - datasetSpacing: 1, - - hover: { - mode: "label" - }, - - scales: { - xAxes: [{ - type: "category", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: true, - }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } - }], - }, - - }; - - - Chart.Type.extend({ - name: "Bar", - defaults: defaultConfig, - initialize: function() { - - var _this = this; - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Rectangle({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - })); - }, this); - - // The bar chart only supports a single x axis because the x axis is always a dataset axis - dataset.xAxisID = this.options.scales.xAxes[0].id; - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - }, this); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // So that we animate from the baseline - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - }, - resetElements: function() { - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScalePoint, - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), - - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); - }, this); - }, - update: function(animationDuration) { - // Update the scale sizes - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the points - this.eachElement(function(bar, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(bar, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.data.datasets.length, datasetIndex, index), - y: yScale.calculateBarY(datasetIndex, index), - - // Appearance - base: yScale.calculateBarBase(datasetIndex, index), - width: xScale.calculateBarWidth(this.data.datasets.length), - backgroundColor: bar.custom && bar.custom.backgroundColor ? bar.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].backgroundColor, index, this.options.elements.rectangle.backgroundColor), - borderColor: bar.custom && bar.custom.borderColor ? bar.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderColor, index, this.options.elements.rectangle.borderColor), - borderWidth: bar.custom && bar.custom.borderWidth ? bar.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].borderWidth, index, this.options.elements.rectangle.borderWidth), - - // Tooltip - label: this.data.labels[index], - datasetLabel: this.data.datasets[datasetIndex].label, - }, - }); - bar.pivot(); - }, this); - - - this.render(animationDuration); - }, - buildScale: function(labels) { - var self = this; - - // Function to determine the range of all the - var calculateYRange = function() { - this.min = null; - this.max = null; - - var positiveValues = []; - var negativeValues = []; - - if (self.options.stacked) { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - positiveValues[index] = positiveValues[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - - if (self.options.relativePoints) { - positiveValues[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - positiveValues[index] += value; - } - } - }, this); - } - }, this); - - var values = positiveValues.concat(negativeValues); - this.min = helpers.min(values); - this.max = helpers.max(values); - - } else { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }; - - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].type); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - id: this.options.scales.xAxes[0].id, - calculateRange: function() { - this.labels = self.data.labels; - this.min = 0; - this.max = this.labels.length; - }, - calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, true) - this.getPixelForValue(null, 0, true)) - (2 * self.options.valueSpacing); - }, - calculateBarWidth: function(datasetCount) { - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * self.options.datasetSpacing); - - if (self.options.stacked) { - return baseWidth; - } - return (baseWidth / datasetCount); - }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.getPixelForValue(null, elementIndex, true) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); - - if (self.options.stacked) { - return xAbsolute + barWidth / 2; - } - - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * self.options.datasetSpacing) + barWidth / 2; - }, - }); - this.scales[xScale.id] = xScale; - - // Build up all the y scales - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - calculateRange: calculateYRange, - calculateBarBase: function(datasetIndex, index) { - var base = 0; - - if (self.options.stacked) { - - var value = self.data.datasets[datasetIndex].data[index]; - - if (value < 0) { - for (var i = 0; i < datasetIndex; i++) { - if (self.data.datasets[i].yAxisID === this.id) { - base += self.data.datasets[i].data[index] < 0 ? self.data.datasets[i].data[index] : 0; - } - } - } else { - for (var j = 0; j < datasetIndex; j++) { - if (self.data.datasets[j].yAxisID === this.id) { - base += self.data.datasets[j].data[index] > 0 ? self.data.datasets[j].data[index] : 0; - } - } - } - - return this.getPixelForValue(base); - } - - base = this.getPixelForValue(this.min); - - if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { - base = this.getPixelForValue(0); - base += this.options.gridLines.lineWidth; - } else if (this.min < 0 && this.max < 0) { - // All values are negative. Use the top as the base - base = this.getPixelForValue(this.max); - } - - return base; - - }, - calculateBarY: function(datasetIndex, index) { - - var value = self.data.datasets[datasetIndex].data[index]; - - if (self.options.stacked) { - - var sumPos = 0, - sumNeg = 0; - - for (var i = 0; i < datasetIndex; i++) { - if (self.data.datasets[i].data[index] < 0) { - sumNeg += self.data.datasets[i].data[index] || 0; - } else { - sumPos += self.data.datasets[i].data[index] || 0; - } - } - - if (value < 0) { - return this.getPixelForValue(sumNeg + value); - } else { - return this.getPixelForValue(sumPos + value); - } - - return this.getPixelForValue(value); - } - - var offset = 0; - - for (var j = datasetIndex; j < self.data.datasets.length; j++) { - if (j === datasetIndex && value) { - offset += value; - } else { - offset = offset + value; - } - } - - return this.getPixelForValue(value); - }, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - //Draw all the bars for each dataset - this.eachElement(function(bar, index, datasetIndex) { - bar.transition(easingDecimal).draw(); - }, this); - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.rectangle.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.rectangle.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.rectangle.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - this.tooltip.pivot(); - - // Hover animations - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); + "use strict"; -}).call(this); + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; - - var defaultConfig = { - - animation: { - //Boolean - Whether we animate the rotation of the Doughnut - animateRotate: true, - - //Boolean - Whether we animate scaling the Doughnut from the centre - animateScale: false, - }, - - hover: { - mode: 'single' - }, - - //The percentage of the chart that we cut out of the middle. - - cutoutPercentage: 50, - - }; - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - - }, - - calculateCircumference: function(dataset, value) { - if (dataset.total > 0) { - return (Math.PI * 2) * (value / dataset.total); - } else { - return 0; - } - }, - resetElements: function() { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // So that calculateCircumference works - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(slice, index) { - helpers.extend(slice, { - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, - innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); - - slice.pivot(); - }, this); - - }, this); - }, - update: function(animationDuration) { - - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(slice, index) { - - helpers.extend(slice, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - circumference: this.calculateCircumference(dataset, dataset.data[index]), - outerRadius: dataset.outerRadius, - innerRadius: dataset.innerRadius, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); - - if (index === 0) { - slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - } else { - slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; - } - - slice._model.endAngle = slice._model.startAngle + slice._model.circumference; - - - //Check to see if it's the last slice, if not get the next and update its start angle - if (index < dataset.data.length - 1) { - dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; - } - - slice.pivot(); - }, this); - - }, this); - - this.render(animationDuration); - }, - draw: function(easeDecimal) { - easeDecimal = easeDecimal || 1; - this.clear(); - - this.eachElement(function(slice) { - slice.transition(easeDecimal).draw(); - }, this); - - this.tooltip.transition(easeDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ - }); - - Chart.types.Doughnut.extend({ - name: "Pie", - defaults: helpers.merge(defaultConfig, { - cutoutPercentage: 0 - }) - }); + Chart.defaults.global.elements.point = { + radius: 3, + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + // Hover + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1, + }; -}).call(this); -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - - stacked: false, - - hover: { - mode: "label" - }, - - scales: { - xAxes: [{ - type: "category", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: false, - }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } - }], - }, - }; - - - Chart.Type.extend({ - name: "Line", - defaults: defaultConfig, - initialize: function() { - - var _this = this; - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - - dataset.metaData = []; - - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); - - }, this); - - // The line chart onlty supports a single x axis because the x axis is always a dataset axis - dataset.xAxisID = this.options.scales.xAxes[0].id; - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - - }, this); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[index]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[index]; - }, - resetElements: function() { - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales - y: yScalePoint, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function(animationDuration) { - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var yScale = this.scales[dataset.yAxisID]; - var scaleBase; - - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.options.elements.line.tension), - backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.options.elements.line.backgroundColor), - borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.options.elements.line.borderWidth), - borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.options.elements.line.borderColor), - fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill), - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(null, index, true), // value not used in dataset scale, but we want a consistent API between scales - y: yScale.getPointPixelForValue(this.data.datasets[datasetIndex].data[index], index, datasetIndex), - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].radius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(animationDuration); - }, - buildScale: function() { - var self = this; - - // Function to determine the range of all the - var calculateYRange = function() { - this.min = null; - this.max = null; - - var positiveValues = []; - var negativeValues = []; - - if (self.options.stacked) { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - positiveValues[index] = positiveValues[index] || 0; - negativeValues[index] = negativeValues[index] || 0; - - if (self.options.relativePoints) { - positiveValues[index] = 100; - } else { - if (value < 0) { - negativeValues[index] += value; - } else { - positiveValues[index] += value; - } - } - }, this); - } - }, this); - - var values = positiveValues.concat(negativeValues); - this.min = helpers.min(values); - this.max = helpers.max(values); - } else { - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }; - - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - // Build the x axis. The line chart only supports a single x axis - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].type); - var xScale = new ScaleClass({ - ctx: this.chart.ctx, - options: this.options.scales.xAxes[0], - calculateRange: function() { - this.labels = self.data.labels; - this.min = 0; - this.max = this.labels.length; - }, - id: this.options.scales.xAxes[0].id, - }); - this.scales[xScale.id] = xScale; - - // Build up all the y scales - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - calculateRange: calculateYRange, - getPointPixelForValue: function(value, index, datasetIndex) { - if (self.options.stacked) { - var offsetPos = 0; - var offsetNeg = 0; - - for (var i = 0; i < datasetIndex; ++i) { - if (self.data.datasets[i].data[index] < 0) { - offsetNeg += self.data.datasets[i].data[index]; - } else { - offsetPos += self.data.datasets[i].data[index]; - } - } - - if (value < 0) { - return this.getPixelForValue(offsetNeg + value); - } else { - return this.getPixelForValue(offsetPos + value); - } - } else { - return this.getPixelForValue(value); - } - }, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.radius ? this.active[0].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.radius ? this.active[i].custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.options.elements.point.hoverRadius); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); + Chart.elements.Point = Chart.Element.extend({ + inRange: function(mouseX, mouseY) { + var vm = this._view; + var hoverRange = vm.hitRadius + vm.radius; + return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + }, + inGroupRange: function(mouseX) { + var vm = this._view; + if (vm) { + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)); + } else { + return false; + } + }, + tooltipPosition: function() { + var vm = this._view; + return { + x: vm.x, + y: vm.y, + padding: vm.radius + vm.borderWidth + }; + }, + draw: function() { -}).call(this); + var vm = this._view; + var ctx = this._chart.ctx; -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - //Cache a local reference to Chart.helpers - helpers = Chart.helpers; - - var defaultConfig = { - - scale: { - type: "radialLinear", - display: true, - - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - - lineArc: true, - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, - - // scale numbers - beginAtZero: true, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - } - }, - - //Boolean - Whether to animate the rotation of the chart - animateRotate: true, - }; - - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "PolarArea", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { - - // Scale setup - var self = this; - var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleClass({ - options: this.options.scale, - lineArc: true, - width: this.chart.width, - height: this.chart.height, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - valuesCount: this.data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets[0].data, function(value) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }); - - helpers.bindEvents(this, this.options.events, this.events); - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Fit the scale before we animate - this.updateScaleRange(); - this.scale.calculateRange(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // so that we animate nicely - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - - }, - updateScaleRange: function() { - helpers.extend(this.scale, { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2 - }); - }, - resetElements: function() { - var circumference = 1 / this.data.datasets[0].data.length * 2; - - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - - var value = this.data.datasets[0].data[index]; - - helpers.extend(slice, { - _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) - }, - }); - - slice.pivot(); - }, this); - }, - update: function(animationDuration) { - - this.updateScaleRange(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - var circumference = 1 / this.data.datasets[0].data.length * 2; - - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - - var value = this.data.datasets[0].data[index]; - - var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); - - helpers.extend(slice, { - _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: this.scale.calculateCenterOffset(value), - startAngle: startAngle, - endAngle: endAngle, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) - }, - }); - slice.pivot(); - - console.log(slice); - - }, this); - - this.render(animationDuration); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - - this.clear(); - - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - slice.transition(easingDecimal).draw(); - }, this); - - this.scale.draw(); - - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ - }); -}).call(this); + if (vm.skip) { + return; + } -(function() { - "use strict"; + if (vm.radius > 0 || vm.borderWidth > 0) { - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + ctx.beginPath(); + ctx.arc(vm.x, vm.y, vm.radius || Chart.defaults.global.elements.point.radius, 0, Math.PI * 2); + ctx.closePath(); + ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.point.borderWidth; - Chart.Type.extend({ - name: "Radar", - defaults: { + ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; - scale: { - type: "radialLinear", - display: true, + ctx.fill(); + ctx.stroke(); + } + } + }); - //Boolean - Whether to animate scaling the chart from the centre - animate: false, - lineArc: false, +}).call(this); + +(function() { - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - }, + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.global.elements.rectangle = { + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 0, + borderColor: Chart.defaults.global.defaultColor, + }; + + Chart.elements.Rectangle = Chart.Element.extend({ + draw: function() { + + var ctx = this._chart.ctx; + var vm = this._view; + + var halfWidth = vm.width / 2, + leftX = vm.x - halfWidth, + rightX = vm.x + halfWidth, + top = vm.base - (vm.base - vm.y), + halfStroke = vm.borderWidth / 2; + + // Canvas doesn't allow us to stroke inside the width so we can + // adjust the sizes to fit if we're setting a stroke on the line + if (vm.borderWidth) { + leftX += halfStroke; + rightX -= halfStroke; + top += halfStroke; + } + + ctx.beginPath(); + + ctx.fillStyle = vm.backgroundColor; + ctx.strokeStyle = vm.borderColor; + ctx.lineWidth = vm.borderWidth; + + // It'd be nice to keep this class totally generic to any rectangle + // and simply specify which border to miss out. + ctx.moveTo(leftX, vm.base); + ctx.lineTo(leftX, top); + ctx.lineTo(rightX, top); + ctx.lineTo(rightX, vm.base); + ctx.fill(); + if (vm.borderWidth) { + ctx.stroke(); + } + }, + height: function() { + var vm = this._view; + return vm.base - vm.y; + }, + inRange: function(mouseX, mouseY) { + var vm = this._view; + if (vm.y < vm.base) { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); + } else { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); + } + }, + inGroupRange: function(mouseX) { + var vm = this._view; + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + }, + tooltipPosition: function() { + var vm = this._view; + if (vm.y < vm.base) { + return { + x: vm.x, + y: vm.y + }; + } else { + return { + x: vm.x, + y: vm.base + }; + } + }, + }); - angleLines: { - show: true, - color: "rgba(0,0,0,.1)", - lineWidth: 1 - }, - // scale numbers - beginAtZero: true, - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - - //Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - //String - The colour of the label backdrop - backdropColor: "rgba(255,255,255,0.75)", - - //Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - //Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - }, - - pointLabels: { - //String - Point label font declaration - fontFamily: "'Arial'", - - //String - Point label font weight - fontStyle: "normal", - - //Number - Point label font size in pixels - fontSize: 10, - - //String - Point label font colour - fontColor: "#666", - }, - }, - - elements: { - line: { - tension: 0, // no bezier in radar - } - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - - }, - - initialize: function() { - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - _loop: true - }); - - dataset.metaData = []; - - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); - - }, this); - }, this); - - // Build the scale. - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[0]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[collection.length - 1]; - }, - resetElements: function() { - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _scale: this.scale, - - // Desired view properties - _model: { - x: this.scale.xCenter, - y: this.scale.yCenter, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = this.scale.xCenter; - point._model.controlPointPreviousY = this.scale.yCenter; - point._model.controlPointNextX = this.scale.xCenter; - point._model.controlPointNextY = this.scale.yCenter; - - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function(animationDuration) { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var scaleBase; - - if (this.scale.min < 0 && this.scale.max < 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.max); - } else if (this.scale.min > 0 && this.scale.max > 0) { - scaleBase = this.scale.getPointPosition(0, this.scale.min); - } else { - scaleBase = this.scale.getPointPosition(0, 0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _datasetIndex: datasetIndex, - - // Data - _children: dataset.metaData, - - // Model - _model: { - // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - - // Scale - scaleTop: this.scale.top, - scaleBottom: this.scale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var pointPosition = this.scale.getPointPosition(index, this.scale.calculateCenterOffset(this.data.datasets[datasetIndex].data[index])); - - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: pointPosition.y, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(animationDuration); - }, - buildScale: function() { - var self = this; - - var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleConstructor({ - options: this.options.scale, - height: this.chart.height, - width: this.chart.width, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - labels: this.data.labels, - valuesCount: this.data.datasets[0].data.length, - calculateRange: function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value, index) { - if (this.min === null) { - this.min = value; - } else if (value < this.min) { - this.min = value; - } - - if (this.max === null) { - this.max = value; - } else if (value > this.max) { - this.max = value; - } - }, this); - } - }, this); - } - }); - - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - this.scale.draw(this.chartArea); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - // If exiting chart - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); }).call(this); (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - hover: { - mode: 'single', - }, - - scales: { - xAxes: [{ - type: "linear", // scatter should not use a dataset axis - display: true, - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }], - yAxes: [{ - type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance - display: true, - position: "left", - id: "y-axis-1", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.05)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, // draw ticks extending towards the label - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // scale numbers - beginAtZero: false, - integersOnly: false, - override: null, - - // label settings - labels: { - show: true, - template: "<%=value.toLocaleString()%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - } - }], - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - - tooltips: { - template: "(<%= value.x %>, <%= value.y %>)", - multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", - }, - - }; - - - Chart.Type.extend({ - name: "Scatter", - defaults: defaultConfig, - initialize: function() { - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - //Custom Point Defaults - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - }); - - dataset.metaData = []; - - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); - - }, this); - - // The line chart onlty supports a single x axis because the x axis is always a dataset axis - if (!dataset.xAxisID) { - dataset.xAxisID = this.options.scales.xAxes[0].id; - } - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - - }, this); - - // Build and fit the scale. Needs to happen after the axis IDs have been set - this.buildScale(); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Reset so that we animation from the baseline - this.resetElements(); - - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[index]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[index]; - }, - resetElements: function() { - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), // value not used in dataset scale, but we want a consistent API between scales - y: yScalePoint, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), - - // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function() { - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var yScale = this.scales[dataset.yAxisID]; - var scaleBase; - - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); - } else { - scaleBase = yScale.getPixelForValue(0); - } - - helpers.extend(dataset.metaDataset, { - // Utility - _scale: yScale, - _datasetIndex: datasetIndex, - // Data - _children: dataset.metaData, - // Model - _model: { - // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, - }); - - dataset.metaDataset.pivot(); - }); - - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var xScale = this.scales[this.data.datasets[datasetIndex].xAxisID]; - var yScale = this.scales[this.data.datasets[datasetIndex].yAxisID]; - - helpers.extend(point, { - // Utility - _chart: this.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: xScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].x), - y: yScale.getPixelForValue(this.data.datasets[datasetIndex].data[index].y), - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: (this.data.datasets[datasetIndex].data[index] === null) || (this.data.datasets[datasetIndex].data[index].x === null) || (this.data.datasets[datasetIndex].data[index].y === null), - - // Tooltip - hoverRadius: point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointHitRadius, index, this.options.elements.point.hitRadius), - }, - }); - }, this); - - - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = controlPoints.previous.x; - point._model.controlPointNextX = controlPoints.next.x; - - // Prevent the bezier going outside of the bounds of the graph - - // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; - } else { - point._model.controlPointNextY = controlPoints.next.y; - } - - // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; - } else { - point._model.controlPointPreviousY = controlPoints.previous.y; - } - - // Now pivot the point for animation - point.pivot(); - }, this); - - this.render(); - }, - buildScale: function() { - var self = this; - - var calculateXRange = function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { - // Only set the scale range for datasets that actually use this axis - if (dataset.xAxisID === this.id) { - helpers.each(dataset.data, function(value) { - if (this.min === null) { - this.min = value.x; - } else if (value.x < this.min) { - this.min = value.x; - } - - if (this.max === null) { - this.max = value.x; - } else if (value.x > this.max) { - this.max = value.x; - } - }, this); - } - }, this); - }; - - var calculateYRange = function() { - this.min = null; - this.max = null; - - helpers.each(self.data.datasets, function(dataset) { - if (dataset.yAxisID === this.id) { - helpers.each(dataset.data, function(value) { - if (this.min === null) { - this.min = value.y; - } else if (value.y < this.min) { - this.min = value.y; - } - - if (this.max === null) { - this.max = value.y; - } else if (value.y > this.max) { - this.max = value.y; - } - }, this); - } - }, this); - }; - - // Map of scale ID to scale object so we can lookup later - this.scales = {}; - - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - calculateRange: calculateXRange, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); - - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - calculateRange: calculateYRange, - id: yAxisOptions.id, - getPointPixelForValue: function(value, index, datasetIndex) { - return this.getPixelForValue(value); - } - }); - - this.scales[scale.id] = scale; - }, this); - }, - draw: function(ease) { - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - events: function(e) { - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hoverAnimationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - - }, - }); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + + Chart.defaults.bar = { + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + type: "category", + categorySpacing: 10, + spacing: 1, + + // grid line settings + gridLines: { + offsetGridLines: true, + }, + }], + yAxes: [{ + type: "linear", + }], + }, + }; + + // Chart.Type.extend({ + // name: "Bar", + // defaults: defaultConfig, + // initialize: function() { + // this.elementController = new Chart.RectangularElementController(this); + // this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); + + // //Create a new bar for each piece of data + // helpers.each(this.data.datasets, function(dataset, datasetIndex) { + // helpers.each(dataset.data, function(dataPoint, index) { + // this.elementController.addRectangle(dataset, datasetIndex, index); + // }, this); + + // // The bar chart only supports a single x axis because the x axis is always a category axis + // dataset.xAxisID = this.options.scales.xAxes[0].id; + + // if (!dataset.yAxisID) { + // dataset.yAxisID = this.options.scales.yAxes[0].id; + // } + // }, this); + + // this.canvasController.initialize(); + // }, + // draw: function(ease) { + + // var easingDecimal = ease || 1; + // this.clear(); + + // // Draw all the scales + // helpers.each(this.scales, function(scale) { + // scale.draw(this.chartArea); + // }, this); + + // //Draw all the bars for each dataset + // this.eachElement(function(bar, index, datasetIndex) { + // bar.transition(easingDecimal).draw(); + // }, this); + + // // Finally draw the tooltip + // this.tooltip.transition(easingDecimal).draw(); + // }, + // }); }).call(this); diff --git a/Chart.min.js b/Chart.min.js index ebde0d71acb..858da0d5644 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,7 +7,8 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width")||t.canvas.width,o=this.height=e(t.canvas,"Height")||t.canvas.height;return t.canvas.width=i,t.canvas.height=o,i=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,s.retinaScale(this),this},o="rgba(0,0,0,0.1)";i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:o,elements:{}}},i.types={};{var s=i.helpers={},a=s.each=function(t,e,i){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;for(s=0;s=0;o--){var s=t[o];if(e(s))return s}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},o=function(){this.constructor=i};return o.prototype=e.prototype,i.prototype=new o,i.extend=h,t&&n(i.prototype,t),i.__super__=e.prototype,i}),l=s.noop=function(){},c=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)},u=s.amd="function"==typeof define&&define.amd,m=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},v=s.max=function(t){return Math.max.apply(Math,t)},g=s.min=function(t){return Math.min.apply(Math,t)},p=(s.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},s.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},s.cap=function(t,e,i){if(m(e)){if(t>e)return e}else if(m(i)&&i>t)return i;return t},s.getDecimalPlaces=function(t){if(t%1!==0&&m(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},s.toRadians=function(t){return t*(Math.PI/180)},s.toDegrees=function(t){return t*(180/Math.PI)},s.getAngleFromPoint=function(t,e){var i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o),a=Math.atan2(o,i);return a<-.5*Math.PI&&(a+=2*Math.PI),{angle:a,distance:s}},s.aliasPixel=function(t){return t%2===0?0:.5},s.splineCurve=function(t,e,i,o){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),r=o*s/(s+a),n=o*a/(s+a);return{previous:{x:e.x-r*(i.x-t.x),y:e.y-r*(i.y-t.y)},next:{x:e.x+n*(i.x-t.x),y:e.y+n*(i.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),f=(s.calculateScaleRange=function(t,e,i,o,s){var a=2,r=Math.floor(e/(1.5*i)),n=a>=r,h=v(t),l=g(t);h===l&&(h+=.5,l>=.5&&!o?l-=.5:h+=.5);for(var c=Math.abs(h-l),d=p(c),u=Math.ceil(h/(1*Math.pow(10,d)))*Math.pow(10,d),m=o?0:Math.floor(l/(1*Math.pow(10,d)))*Math.pow(10,d),f=u-m,b=Math.pow(10,d),x=Math.round(f/b);(x>r||r>2*x)&&!n;)if(x>r)b*=2,x=Math.round(f/b),x%1!==0&&(n=!0);else if(s&&d>=0){if(b/2%1!==0)break;b/=2,x=Math.round(f/b)}else b/=2,x=Math.round(f/b);return n&&(x=a,b=f/x),{steps:x,stepValue:b,min:m,max:m+x*b}},s.niceNum=function(t,e){var i,o=Math.floor(s.log10(t)),a=t/Math.pow(10,o);return i=e?1.5>a?1:3>a?2:7>a?5:10:1>=a?1:2>=a?2:5>=a?5:10,i*Math.pow(10,o)},s.template=function(t,e){function i(t,e){var i=/\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('');"):o[t]=o[t];return e?i(e):i}if(t instanceof Function)return t(e);var o={};return i(t,e)}),b=(s.generateLabels=function(t,e,i,o){var s=new Array(e);return t&&a(s,function(e,a){s[a]=f(t,{value:i+o*(a+1)})}),s},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 e=1.70158,i=0,o=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ot?-.5*o*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):o*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+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}}),x=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),A=(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,e,i,o,s,a){var r=0,n=b[i]||b.linear,h=function(){r++;var i=r/e,l=n(i);t.call(a,l,i,r),o.call(a,l,i),e>r?a.animationFrame=x(h):s.apply(a)};x(h)},s.getRelativePosition=function(t){var e,i,o=t.originalEvent||t,s=t.currentTarget||t.srcElement,a=s.getBoundingClientRect();return o.touches?(e=o.touches[0].clientX-a.left,i=o.touches[0].clientY-a.top):(e=o.clientX-a.left,i=o.clientY-a.top),{x:e,y:i}},s.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),C=s.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=l},y=(s.bindEvents=function(t,e,i){t.events||(t.events={}),a(e,function(e){t.events[e]=function(){i.apply(t,arguments)},A(t.chart.canvas,e,t.events[e])})},s.unbindEvents=function(t,e){a(e,function(e,i){C(t.chart.canvas,i,e)})}),w=s.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(k(e,"padding-left"))+parseInt(k(e,"padding-right"));return e.clientWidth-i},_=s.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(k(e,"padding-bottom"))+parseInt(k(e,"padding-top"));return e.clientHeight-i},k=s.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},S=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,o=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=o+"px",e.canvas.height=o*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))}),I=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)};s.fontString=function(t,e,i){return e+" "+t+"px "+i},s.longestText=function(t,e,i){t.font=e;var o=0;return a(i,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},s.drawRoundedRectangle=function(t,e,i,o,s,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+o-a,i),t.quadraticCurveTo(e+o,i,e+o,i+a),t.lineTo(e+o,i+s-a),t.quadraticCurveTo(e+o,i+s,e+o-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()},s.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},s.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}i.instances={},i.Type=function(t,e){this.data=t.data,this.options=t.options,this.chart=e,this.id=c(),i.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this)},n(i.Type.prototype,{initialize:function(){return this},clear:function(){return I(this.chart),this},stop:function(){return i.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,e=w(this.chart.canvas),i=this.options.maintainAspectRatio?e/this.chart.aspectRatio:_(this.chart.canvas);return t.width=this.chart.width=e,t.height=this.chart.height=i,S(this.chart),this},redraw:l,render:function(t){if(0!==this.options.animation.duration||t){var e=new i.Animation;e.numSteps=(t||this.options.animation.duration)/16.66,e.easing=this.options.animation.easing,e.render=function(t,e){var i=s.easingEffects[e.easing],o=e.currentStep/e.numSteps,a=i(o);t.draw(a,o,e.currentStep)},e.onAnimationProgress=this.options.onAnimationProgress,e.onAnimationComplete=this.options.onAnimationComplete,i.animationService.addAnimation(this,e,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},eachElement:function(t){s.each(this.data.datasets,function(e,i){s.each(e.metaData,t,this,e.metaData,i)},this)},eachValue:function(t){s.each(this.data.datasets,function(e,i){s.each(e.data,t,this,i)},this)},eachDataset:function(t){s.each(this.data.datasets,t,this)},getElementsAtEvent:function(t){for(var e,i=[],o=s.getRelativePosition(t),a=function(t){i.push(t.metaData[e])},r=0;r=n[a].length||!n[a][i].type?n[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==n[a][i].type?n[a][i]=e.configMerge(n[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):n[a][i]=e.configMerge(n[a][i],t)}):(n[a]=[],e.each(t,function(t){n[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):n.hasOwnProperty(a)&&"object"==typeof n[a]&&null!==n[a]&&"object"==typeof t?n[a]=e.configMerge(n[a],t):n[a]=t)}),n},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var n=t[a];if(e(n))return n}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&n(i.prototype,t),i.__super__=e.prototype,i}),o=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,n=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:n}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=a*n/(n+s),r=a*s/(n+s);return{previous:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,n){var s=2,o=Math.floor(e/(1.5*i)),r=s>=o,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var f=Math.abs(u-d),g=c(f),p=Math.ceil(u/(1*Math.pow(10,g)))*Math.pow(10,g),v=a?0:Math.floor(d/(1*Math.pow(10,g)))*Math.pow(10,g),m=p-v,b=Math.pow(10,g),x=Math.round(m/b);(x>o||o>2*x)&&!r;)if(x>o)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(n&&g>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=s,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},e.niceNum=function(t,i){var a,n=Math.floor(e.log10(t)),s=t/Math.pow(10,n);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,n)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,n){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+n*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),f=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),g=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,n,s){var o=0,r=d[i]||d.linear,h=function(){o++;var i=o/e,l=r(i);t.call(s,l,i,o),a.call(s,l,i),e>o?s.animationFrame=f(h):n.apply(s)};f(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,n=t.currentTarget||t.srcElement,s=n.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),p=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=o},v=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){p(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-left"))+parseInt(v(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-bottom"))+parseInt(v(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var n=0;return i(a,function(e){var i=t.measureText(e).width;n=i>n?i:n}),n},e.drawRoundedRectangle=function(t,e,i,a,n,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+n-s),t.quadraticCurveTo(e+a,i+n,e+a-s,i+n),t.lineTo(e+s,i+n),t.quadraticCurveTo(e,i+n,e,i+n-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var n=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=n.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var o=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-o)*t+o}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var n=0;n1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var n=Date.now(),s=n-t-this.frameDuration,o=s/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildScales(),this.buildControllers(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){this.scales={},e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){this.eachDataset(function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))})},resetElements:function(){this.eachDataset(function(t,e){t.controller.reset()})},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){t.controller.update()}),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],n=i.currentStep/i.numSteps,s=a(n);t.draw(s,n,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},eachValue:function(t){e.each(this.data.datasets,function(i,a){e.each(i.data,t,this,a)},this)},eachElement:function(t){e.each(this.data.datasets,function(i,a){e.each(i.metaData,t,this,i.metaData,a)},this)},eachDataset:function(t){e.each(this.data.datasets,t,this)},nextElement:function(t,e,i){return this.loop?dataset[e+1]||dataset[0]:t[e+1]||t[e]},previousElement:function(t,e,i){return this.loop?dataset[e-1]||dataset[dataset.length-1]:t[e-1]||t[e]},getElementAtEvent:function(t){for(var i=[],a=e.getRelativePosition(t),n=0;n30?5:2,s=a>30?5:2;if(t){var o=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*n,u-=2*s;var d=(e-c)/(o.length+r.length),f=(a-u)/(h.length+l.length),g=[],p=function(t){var e=t.fit(d,u);g.push({horizontal:!1,minSize:e,scale:t})},v=function(t){var e=t.fit(c,f);g.push({horizontal:!0,minSize:e,scale:t})};i.each(o,p),i.each(r,p),i.each(h,v),i.each(l,v);var m=a-2*s,b=e-2*n;i.each(g,function(t){t.horizontal?m-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(g,function(e){return e.scale===t});e&&t.fit(e.minSize.width,m)},y=function(t){var e=i.findNextWhere(g,function(e){return e.scale===t}),a={left:w,right:k,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=n,k=n,_=s,C=s;i.each(o,x),i.each(r,x),i.each(o,function(t){w+=t.width}),i.each(r,function(t){k+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){C+=t.height}),i.each(o,function(t){var e=i.findNextWhere(g,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:C};e&&t.fit(e.minSize.width,m,a)}),i.each(r,function(t){var e=i.findNextWhere(g,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:C};e&&t.fit(e.minSize.width,m,a)});var S=n,P=s,M=function(t){t.left=S,t.right=S+t.width,t.top=_,t.bottom=_+m,S=t.right},A=function(t){t.left=w,t.right=w+b,t.top=P,t.bottom=P+t.height,P=t.bottom};i.each(o,M),i.each(h,A),S+=b,P+=m,i.each(r,M),i.each(l,A),t.chartArea={left:w,top:_,right:w+b,bottom:_+m}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,n,s=[],o=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,n=i.indexOf(a,this._active[0]),-1===n);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[n]&&e[n].hasValue()&&c.push(e[n])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),o.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,n);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:o,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,n=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,o=s+e.caretHeight+a;e.x+n/2>this._chart.width?e.xAlign="left":e.x-n/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-n/2,h=e.y-o;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-n+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,n,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+n/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,n){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(n+1)),t.fillStyle=i.color(e.legendColors[n].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(n+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[n].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(n,s){var o;o=a.min<0&&a.max<0?a.getPixelForValue(a.max):a.min>0&&a.max>0?a.getPixelForValue(a.min):a.getPixelForValue(0),i.extend(n,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?o:a.getPixelForValue(this.getDataset().data[s]),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:n.custom&&n.custom.backgroundColor?n.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:n.custom&&n.custom.borderColor?n.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:n.custom&&n.custom.borderWidth?n.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) +}}),n.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},getElementsAtEvent:function(t){for(var e,a=[],n=i.getRelativePosition(t),s=function(t){a.push(t.metaData[e])},o=0;o0&&s.max>0?s.getPixelForValue(s.min):s.getPixelForValue(0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:n,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(n,function(t,e){i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:s,_datasetIndex:this.index,_index:e,_model:{x:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:s.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},n=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var n=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=n/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),o=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(o+=s/2),this.left+Math.round(o)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),n=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?n+s/2:n+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var n,s,o=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=o/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),n=h*o,s=h*r,n+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=n+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var n={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),o=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(n.width=t,this.width=t):this.options.display&&(n.width=Math.min(o+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*o+1.5*this.options.labels.fontSize;n.height=Math.min(r,e)}else this.options.display&&(n.width=Math.min(o+6,t));return this.width=n.width,this.height=n.height,n},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,n="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(o,r){var h=this.getPixelForValue(o,r,null,!1),l=this.getPixelForValue(o,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(o,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",n,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},n=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var n=this.options.override.start+a*this.options.override.stepWidth;ticks.push(n)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var o=i.sign(this.min),r=i.sign(this.max);0>o&&0>r?this.max=0:o>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var n;this.options.labels.userCallback?n=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(n=i.template(this.options.labels.template,{value:t})),this.labels.push(n?n:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var n=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>n?e[a]+=n:t[a]+=n},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var n=0,s=0,o=0;i>o;++o)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]:n+=this.data.datasets[o].data[e];return 0>a?this.getPixelForValue(s+a):this.getPixelForValue(n+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var n=0;t>n;n++)this.data.datasets[n].yAxisID===this.id&&(i+=this.data.datasets[n].data[e]<0?this.data.datasets[n].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,n=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?n+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return 0>i?this.getPixelForValue(n+i):this.getPixelForValue(a+i)}for(var o=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var n="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(o,r){var h=this.getPixelForValue(o);0===o||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,n),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var o;"top"==this.options.position?(o=this.bottom-10,this.ctx.textBaseline="bottom"):(o=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,o)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(n,s){var o=this.getPixelForValue(n);0===n||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),o+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,o),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,o),this.ctx.lineTo(t.right,o)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",n,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!1,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},n=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var n=i.sign(this.min),s=i.sign(this.max);0>n&&0>s?this.max=0:n>0&&s>0&&(this.min=0)}for(var o=i.niceNum(this.max-this.min,!1),r=i.niceNum(o/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var n;this.options.labels.userCallback?n=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(n=i.template(this.options.labels.template,{value:t})),this.yLabels.push(n?n:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,n,s,o,r,h,l,c,u,d,f=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),g=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;eg&&(g=t.x+n,s=e),t.x-ng&&(g=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var n=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-n;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var o=0;o=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var n=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],n.x,n.y)}}}}});e.scaleService.registerScaleType("radialLinear",n,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -16,7 +17,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,o){o||(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var o=0;othis.animations[o].animationObject.numSteps&&(this.animations[o].animationObject.currentStep=this.animations[o].animationObject.numSteps),this.animations[o].animationObject.render(this.animations[o].chartInstance,this.animations[o].animationObject),this.animations[o].animationObject.currentStep==this.animations[o].animationObject.numSteps&&(this.animations[o].chartInstance.animating=!1,this.animations.splice(o,1),o--);var s=Date.now(),a=s-t-this.frameDuration,r=a/this.frameDuration;r>1&&(this.dropFrames+=r),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.scaleService={fitScalesForChart:function(t,e,o){var s=e>30?5:2,a=o>30?5:2;if(t){var r=i.where(t.scales,function(t){return"left"==t.options.position}),n=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=(i.where(t.scales,function(t){return"left"==t.options.position}),i.where(t.scales,function(t){return"right"==t.options.position}),i.where(t.scales,function(t){return"top"==t.options.position}),i.where(t.scales,function(t){return"bottom"==t.options.position}),e/2),d=o/2;c-=2*s,d-=2*a;var u=(e-c)/(r.length+n.length),m=(o-d)/(h.length+l.length),v=[],g=function(t){var e=t.fit(u,d);v.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,m);v.push({horizontal:!0,minSize:e,scale:t})};i.each(r,g),i.each(n,g),i.each(h,p),i.each(l,p);var f=o-2*a,b=e-2*s;i.each(v,function(t){t.horizontal?f-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(v,function(e){return e.scale===t});e&&t.fit(e.minSize.width,f)},A=function(t){var e=i.findNextWhere(v,function(e){return e.scale===t}),o={left:C,right:y,top:0,bottom:0};e&&t.fit(b,e.minSize.height,o)},C=s,y=s,w=a,_=a;i.each(r,x),i.each(n,x),i.each(r,function(t){C+=t.width}),i.each(n,function(t){y+=t.width}),i.each(h,A),i.each(l,A),i.each(h,function(t){w+=t.height}),i.each(l,function(t){_+=t.height}),i.each(r,function(t){var e=i.findNextWhere(v,function(e){return e.scale===t}),o={left:0,right:0,top:w,bottom:_};e&&t.fit(e.minSize.width,f,o)}),i.each(n,function(t){var e=i.findNextWhere(v,function(e){return e.scale===t}),o={left:0,right:0,top:w,bottom:_};e&&t.fit(e.minSize.width,f,o)});var k=s,S=a,I=function(t){t.left=k,t.right=k+t.width,t.top=w,t.bottom=w+f,k=t.right},P=function(t){t.left=C,t.right=C+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(r,I),i.each(h,P),k+=b,S+=f,i.each(n,I),i.each(l,P),t.chartArea={left:C,top:w,right:C+b,bottom:w+f}}}},e.scales={constructors:{},registerScaleType:function(t,e){this.constructors[t]=e},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0}}}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.Arc=e.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?a.startAngle-2*Math.PI:a.startAngle,o=a.endAngle<-.5*Math.PI?a.endAngle+2*Math.PI:a.endAngle>1.5*Math.PI?a.endAngle-2*Math.PI:a.endAngle,r=n.angle>=s&&n.angle<=o,h=n.distance>=a.innerRadius&&n.distance<=a.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -25,7 +26,7 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.anima * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var o,s,a=[],r=[],n=this._data.datasets.length-1;n>=0&&(o=this._data.datasets[n].metaData,s=i.indexOf(o,this._active[0]),-1===s);n--);var h=function(){var t,e,o,n,h,l=[],c=[],d=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),d.push(t._view.y),a.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),r.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(d),o=i.max(d),n=i.min(c),e=i.max(c),{x:n>this._chart.width/2?n:e,y:(h+o)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:a,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:r,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=a.length*this._model.fontSize+(a.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,a)+this._model.fontSize+3,d=i.max([c,l]);this._model.width=d+2*this._model.xPadding;var u=this._model.height/2;this._model.y-u<0?this._model.y=u:this._model.y+u>this._chart.height&&(this._model.y=this._chart.height-u),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var o=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,a=e.fontSize+2*e.yPadding,r=a+e.caretHeight+o;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-r<0&&(e.yAlign="below");var n=e.x-s/2,h=e.y-r;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-o),t.lineTo(e.x+e.caretHeight,e.y-(o+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(o+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+o+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+o),t.lineTo(e.x+e.caretHeight,e.y+o+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+o+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":n=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":n=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,n,h,s,a,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,n+s/2,h+a/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(o,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(o,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.max-(this.options.gridLines.offsetGridLines?0:1),1),a=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&i&&(a+=s/2),this.left+Math.round(a)}return this.top+e*(this.height/this.max)},calculateLabelRotation:function(t,e){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var s,a,r=this.ctx.measureText(this.labels[0]).width,n=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=n/2+3,this.paddingLeft=r/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,o,this.labels);this.labelWidth=c;for(var d=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>d&&0===this.labelRotation||this.labelWidth>d&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*r,a=h*n,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,o){this.calculateRange(),this.calculateLabelRotation(e,o);var s={width:0,height:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),r=i.longestText(this.ctx,a,this.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(r+6,t)),this.isHorizontal()){var n=Math.cos(i.toRadians(this.labelRotation))*r+1.5*this.options.labels.fontSize;s.height=Math.min(n,e)}else this.options.display&&(s.width=Math.min(r+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var o="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,a=0!==this.labelRotation;i.each(this.labels,function(r,n){var h=this.getPixelForValue(r,n,!1),l=this.getPixelForValue(r,n,!0);this.options.gridLines.show&&(0===n?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,a?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=a?"right":"center",this.ctx.textBaseline=a?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scales.registerScaleType("category",o)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o=e.Element.extend({calculateRange:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var o=0;o<=this.options.override.steps;++o){var s=this.options.override.start+o*this.options.override.stepWidth;ticks.push(s)}else{var a;if(a=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),a=Math.max(2,a),this.options.beginAtZero){var r=i.sign(this.min),n=i.sign(this.max);0>r&&0>n?this.max=0:r>0&&n>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(a-1),!0),c=Math.floor(this.min/l)*l,d=Math.ceil(this.max/l)*l,u=c;d>=u;u+=l)this.ticks.push(u)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.lables.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},fit:function(t,e){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var o={width:0,height:0};if(o.width=this.isHorizontal()?t:this.options.gridLines.show&&this.options.display?10:0,o.height=this.isHorizontal()?this.options.gridLines.show&&this.options.display?10:0:e,this.options.labels.show&&this.options.display){var s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var a=(e-o.height,1.5*this.options.labels.fontSize);o.height=Math.min(e,o.height+a)}else{var r=t-o.width,n=i.longestText(this.ctx,s,this.labels);r>n?o.width+=n:o.width=t}}return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e,o;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,a="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(r,n){var h=this.getPixelForValue(r);0===r||!o&&0===n?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var r;"top"==this.options.position?(r=this.bottom-10,this.ctx.textBaseline="bottom"):(r=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,r)},this)}}else{if(this.options.gridLines.show){e=!0,o=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var n="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,a){var r=this.getPixelForValue(s);0===s||!o&&0===a?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),r+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(n,r),this.ctx.lineTo(h,r)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,r),this.ctx.lineTo(t.right,r)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scales.registerScaleType("linear",o)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,o=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:i.noop,generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var o=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(o=Math.max(2,o),this.options.beginAtZero){var s=i.sign(this.min),a=i.sign(this.max);0>s&&0>a?this.max=0:s>0&&a>0&&(this.min=0)}for(var r=i.niceNum(this.max-this.min,!1),n=i.niceNum(r/(o-1),!0),h=Math.floor(this.min/n)*n,l=Math.ceil(this.max/n)*n,c=h;l>=c;c+=n)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,o){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,o):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,o,s,a,r,n,h,l,c,d,u,m=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),v=this.width,g=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ev&&(v=t.x+s,a=e),t.x-sv&&(v=t.x+o,a=e):e>this.valuesCount/2&&t.x-o0){var s,a=o*(this.drawingArea/Math.max(this.ticks.length,1)),r=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var o=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var a=this.labels.length,r=this.labels.length/2,n=r/2,h=n>e||e>a-n,l=e===n||e===a-n;t.textAlign=0===e?"center":e===r?"center":r>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scales.registerScaleType("radialLinear",o)}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,n=this._children[0],s=this._children[this._children.length-1];i.each(this._children,function(e,n){var s=i.previousItem(this._children,n),o=i.nextItem(this._children,n);return 0===n?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(s._view.x,e._view.y),a.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,s._view.y),a.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!n._view.skip?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,n._view.controlPointPreviousX,n._view.controlPointPreviousY,n._view.x,n._view.y):a.lineTo(n._view.x,n._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,n){var s=i.previousItem(this._children,n),o=i.nextItem(this._children,n);return 0===n?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(s._view.x,e._view.y),void a.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,s._view.y),void a.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!n._view.skip&&(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,n._view.controlPointPreviousX,n._view.controlPointPreviousY,n._view.x,n._view.y):a.lineTo(n._view.x,n._view.y)),a.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -34,33 +35,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.toolt * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.Arc=e.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?o.startAngle-2*Math.PI:o.startAngle,r=o.endAngle<-.5*Math.PI?o.endAngle+2*Math.PI:o.endAngle>1.5*Math.PI?o.endAngle-2*Math.PI:o.endAngle,n=s.angle>=a&&s.angle<=r,h=s.distance>=o.innerRadius&&s.distance<=o.outerRadius;return n&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! - * Chart.js - * http://chartjs.org/ - * Version: 2.0.0-alpha - * - * Copyright 2015 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.Line=e.Element.extend({draw:function(){var t=this._view,o=this._chart.ctx,s=this._children[0],a=this._children[this._children.length-1];i.each(this._children,function(e,i){var s=this.previousPoint(e,this._children,i),a=this.nextPoint(e,this._children,i);return 0===i?void o.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(o.lineTo(s._view.x,e._view.y),o.moveTo(a._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(o.moveTo(e._view.x,s._view.y),o.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?o.moveTo(e._view.x,e._view.y):t.tension>0?o.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):o.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!s._view.skip?o.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):o.lineTo(s._view.x,s._view.y)),this._children.length>0&&t.fill&&(o.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),o.lineTo(this._children[0]._view.x,t.scaleZero),o.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,o.closePath(),o.fill()),o.lineWidth=t.borderWidth||e.defaults.global.defaultColor,o.strokeStyle=t.borderColor||e.defaults.global.defaultColor,o.beginPath(),i.each(this._children,function(e,i){var s=this.previousPoint(e,this._children,i),a=this.nextPoint(e,this._children,i);return 0===i?void o.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(o.moveTo(s._view.x,e._view.y),void o.moveTo(a._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(o.moveTo(e._view.x,s._view.y),void o.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void o.moveTo(e._view.x,e._view.y):void(t.tension>0?o.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):o.lineTo(e._view.x,e._view.y))},this),this._loop&&!s._view.skip&&(t.tension>0?o.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):o.lineTo(s._view.x,s._view.y)),o.stroke()},nextPoint:function(t,e,i){return this.loop?e[i+1]||e[0]:e[i+1]||e[e.length-1]},previousPoint:function(t,e,i){return this.loop?e[i-1]||e[e.length-1]:e[i-1]||e[0]}})}.call(this),/*! - * Chart.js - * http://chartjs.org/ - * Version: 2.0.0-alpha - * - * Copyright 2015 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ -function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.Point=e.Element.extend({inRange:function(t,e){var i=this._view,o=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),/*! - * Chart.js - * http://chartjs.org/ - * Version: 2.0.0-alpha - * - * Copyright 2015 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ -function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,o=e.x-i,s=e.x+i,a=e.base-(e.base-e.y),r=e.borderWidth/2;e.borderWidth&&(o+=r,s-=r,a+=r),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(o,e.base),t.lineTo(o,a),t.lineTo(s,a),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{type:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Bar",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Rectangle({_chart:this.chart,_datasetIndex:o,_index:s}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.calculateBarX(this.data.datasets.length,s,e),y:a,base:n.calculateBarBase(s,e),width:r.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.rectangle.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:r,_datasetIndex:s,_index:e,_model:{x:a.calculateBarX(this.data.datasets.length,s,e),y:r.calculateBarY(s,e),base:r.calculateBarBase(s,e),width:a.calculateBarWidth(this.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].backgroundColor,e,this.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].borderColor,e,this.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].borderWidth,e,this.options.elements.rectangle.borderWidth),label:this.data.labels[e],datasetLabel:this.data.datasets[s].label}}),t.pivot()},this),this.render(t)},buildScale:function(){var t=this,o=function(){this.min=null,this.max=null;var e=[],o=[];if(t.options.stacked){i.each(t.data.datasets,function(s){s.yAxisID===this.id&&i.each(s.data,function(i,s){e[s]=e[s]||0,o[s]=o[s]||0,t.options.relativePoints?e[s]=100:0>i?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].type),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],id:this.options.scales.xAxes[0].id,calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},calculateBaseWidth:function(){return this.getPixelForValue(null,1,!0)-this.getPixelForValue(null,0,!0)-2*t.options.valueSpacing},calculateBarWidth:function(e){var i=this.calculateBaseWidth()-(e-1)*t.options.datasetSpacing;return t.options.stacked?i:i/e},calculateBarX:function(e,i,o){var s=this.calculateBaseWidth(),a=this.getPixelForValue(null,o,!0)-s/2,r=this.calculateBarWidth(e);return t.options.stacked?a+r/2:a+r*i+i*t.options.datasetSpacing+r/2}});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.type),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,calculateBarBase:function(e,i){var o=0;if(t.options.stacked){var s=t.data.datasets[e].data[i];if(0>s)for(var a=0;e>a;a++)t.data.datasets[a].yAxisID===this.id&&(o+=t.data.datasets[a].data[i]<0?t.data.datasets[a].data[i]:0);else for(var r=0;e>r;r++)t.data.datasets[r].yAxisID===this.id&&(o+=t.data.datasets[r].data[i]>0?t.data.datasets[r].data[i]:0);return this.getPixelForValue(o)}return o=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(o=this.getPixelForValue(0),o+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(o=this.getPixelForValue(this.max)),o},calculateBarY:function(e,i){var o=t.data.datasets[e].data[i];if(t.options.stacked){for(var s=0,a=0,r=0;e>r;r++)t.data.datasets[r].data[i]<0?a+=t.data.datasets[r].data[i]||0:s+=t.data.datasets[r].data[i]||0;return this.getPixelForValue(0>o?a+o:s+o)}for(var n=0,h=e;h0?2*Math.PI*(e/t.total):0},resetElements:function(){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.arc.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(e,o){i.extend(e,{_model:{x:this.chart.width/2,y:this.chart.height/2,startAngle:Math.PI*-.5,circumference:this.options.animation.animateRotate?0:this.calculateCircumference(metaSlice.value),outerRadius:this.options.animation.animateScale?0:t.outerRadius,innerRadius:this.options.animation.animateScale?0:t.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,o,this.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,o,this.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,o,this.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,o,this.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(t.label,o,this.data.labels[o])}}),e.pivot()},this)},this)},update:function(t){this.outerRadius=(i.min([this.chart.width,this.chart.height])-this.options.elements.arc.borderWidth/2)/2,this.innerRadius=this.options.cutoutPercentage?this.outerRadius/100*this.options.cutoutPercentage:1,this.radiusLength=(this.outerRadius-this.innerRadius)/this.data.datasets.length,i.each(this.data.datasets,function(t,e){t.total=0,i.each(t.data,function(e){t.total+=Math.abs(e)},this),t.outerRadius=this.outerRadius-this.radiusLength*e,t.innerRadius=t.outerRadius-this.radiusLength,i.each(t.metaData,function(o,s){i.extend(o,{_chart:this.chart,_datasetIndex:e,_index:s,_model:{x:this.chart.width/2,y:this.chart.height/2,circumference:this.calculateCircumference(t,t.data[s]),outerRadius:t.outerRadius,innerRadius:t.innerRadius,backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(t.backgroundColor,s,this.options.elements.arc.backgroundColor),hoverBackgroundColor:o.custom&&o.custom.hoverBackgroundColor?o.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(t.hoverBackgroundColor,s,this.options.elements.arc.hoverBackgroundColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(t.borderWidth,s,this.options.elements.arc.borderWidth),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(t.borderColor,s,this.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(t.label,s,this.data.labels[s])}}),o._model.startAngle=0===s?Math.PI*-.5:t.metaData[s-1]._model.endAngle,o._model.endAngle=o._model.startAngle+o._model.circumference,s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{type:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]}};e.Type.extend({name:"Line",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID=this.options.scales.xAxes[0].id,t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.getPixelForValue(null,e,!0),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o){var s=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=s.previous.x,t._model.controlPointNextX=s.next.x,t._model.controlPointNextY=s.next.y>this.chartArea.bottom?this.chartArea.bottom:s.next.ythis.chartArea.bottom?this.chartArea.bottom:s.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.metaDataset.custom&&t.metaDataset.custom.tension?t.metaDataset.custom.tension:t.tension||this.options.elements.line.tension,backgroundColor:t.metaDataset.custom&&t.metaDataset.custom.backgroundColor?t.metaDataset.custom.backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.metaDataset.custom&&t.metaDataset.custom.borderWidth?t.metaDataset.custom.borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.metaDataset.custom&&t.metaDataset.custom.borderColor?t.metaDataset.custom.borderColor:t.borderColor||this.options.elements.line.borderColor,fill:t.metaDataset.custom&&t.metaDataset.custom.fill?t.metaDataset.custom.fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:r,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(null,e,!0),y:r.getPointPixelForValue(this.data.datasets[s].data[e],e,s),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.data.datasets[s].radius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o){var s=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=s.previous.x,t._model.controlPointNextX=s.next.x,t._model.controlPointNextY=s.next.y>this.chartArea.bottom?this.chartArea.bottom:s.next.ythis.chartArea.bottom?this.chartArea.bottom:s.previous.yi?o[s]+=i:e[s]+=i},this)},this);var s=e.concat(o);this.min=i.min(s),this.max=i.max(s)}else i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)};this.scales={};var s=e.scales.getScaleConstructor(this.options.scales.xAxes[0].type),a=new s({ctx:this.chart.ctx,options:this.options.scales.xAxes[0],calculateRange:function(){this.labels=t.data.labels,this.min=0,this.max=this.labels.length},id:this.options.scales.xAxes[0].id});this.scales[a.id]=a,i.each(this.options.scales.yAxes,function(i){var s=e.scales.getScaleConstructor(i.type),a=new s({ctx:this.chart.ctx,options:i,calculateRange:o,getPointPixelForValue:function(e,i,o){if(t.options.stacked){for(var s=0,a=0,r=0;o>r;++r)t.data.datasets[r].data[i]<0?a+=t.data.datasets[r].data[i]:s+=t.data.datasets[r].data[i];return this.getPixelForValue(0>e?a+e:s+e)}return this.getPixelForValue(e)},id:i.id});this.scales[a.id]=a},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){this.lastActive=this.lastActive||[],this.active="mouseout"==t.type?[]:function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.radius:i.getValueAtIndexOrDefault(e.radius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2}},animateRotate:!0};e.Type.extend({name:"PolarArea",defaults:o,initialize:function(){var t=this,o=e.scales.getScaleConstructor(this.options.scale.type);this.scale=new o({options:this.options.scale,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,valuesCount:this.data.length,calculateRange:function(){this.min=null,this.max=null,i.each(t.data.datasets[0].data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)}}),i.bindEvents(this,this.options.events,this.events),i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Arc({_chart:this.chart,_datasetIndex:o,_index:s,_model:{}}))},this)},this),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),this.updateScaleRange(),this.scale.calculateRange(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},updateScaleRange:function(){i.extend(this.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},resetElements:function(){1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){this.data.datasets[0].data[e];i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:0,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot()},this)},update:function(t){this.updateScaleRange(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels(),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height);var o=1/this.data.datasets[0].data.length*2;i.each(this.data.datasets[0].metaData,function(t,e){var s=this.data.datasets[0].data[e],a=-.5*Math.PI+Math.PI*o*e,r=a+o*Math.PI;i.extend(t,{_index:e,_model:{x:this.chart.width/2,y:this.chart.height/2,innerRadius:0,outerRadius:this.scale.calculateCenterOffset(s),startAngle:a,endAngle:r,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor,e,this.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor,e,this.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth,e,this.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[0].borderColor,e,this.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.data.datasets[0].labels,e,this.data.datasets[0].labels[e])}}),t.pivot(),console.log(t)},this),this.render(t)},draw:function(t){var e=t||1;this.clear(),i.each(this.data.datasets[0].metaData,function(t){t.transition(e).draw()},this),this.scale.draw(),this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getSliceAtEvent(t);case"label":return this.getSlicesAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.backgroundColor,o,this.options.elements.arc.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.borderColor,o,this.options.elements.arc.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.borderWidth,o,this.options.elements.arc.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},elements:{line:{tension:0}},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    '},initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData,_loop:!0}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[0]},previousPoint:function(t,e){return t[e-1]||t[t.length-1]},resetElements:function(){this.eachElement(function(t,e,o,s){i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_scale:this.scale,_model:{x:this.scale.xCenter,y:this.scale.yCenter,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o){i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=this.scale.xCenter,t._model.controlPointPreviousY=this.scale.yCenter,t._model.controlPointNextX=this.scale.xCenter,t._model.controlPointNextY=this.scale.yCenter,t.pivot()},this)},update:function(t){e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){var o;o=this.scale.min<0&&this.scale.max<0?this.scale.getPointPosition(0,this.scale.max):this.scale.min>0&&this.scale.max>0?this.scale.getPointPosition(0,this.scale.min):this.scale.getPointPosition(0,0),i.extend(t.metaDataset,{_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:this.scale.top,scaleBottom:this.scale.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(this.data.datasets[s].data[e]));i.extend(t,{_chart:this.chart,_datasetIndex:s,_index:e,_model:{x:a.x,y:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].hitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o){var s=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=s.previous.x,t._model.controlPointNextX=s.next.x,t._model.controlPointNextY=s.next.y>this.chartArea.bottom?this.chartArea.bottom:s.next.ythis.chartArea.bottom?this.chartArea.bottom:s.previous.ythis.max&&(this.max=t)},this)},this)}}),this.scale.setScaleSize(),this.scale.calculateRange(),this.scale.generateTicks(),this.scale.buildYLabels()},draw:function(t){var e=t||1;this.clear(),this.scale.draw(this.chartArea);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){this.lastActive=this.lastActive||[],this.active="mouseout"==t.type?[]:function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&this.options.onClick&&this.options.onClick.call(this,t,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}],yAxes:[{type:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.05)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,integersOnly:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}}]},legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Type.extend({name:"Scatter",defaults:o,initialize:function(){i.bindEvents(this,this.options.events,this.events),i.each(this.data.datasets,function(t,o){t.metaDataset=new e.Line({_chart:this.chart,_datasetIndex:o,_points:t.metaData}),t.metaData=[],i.each(t.data,function(i,s){t.metaData.push(new e.Point({_datasetIndex:o,_index:s,_chart:this.chart,_model:{x:0,y:0}}))},this),t.xAxisID||(t.xAxisID=this.options.scales.xAxes[0].id),t.yAxisID||(t.yAxisID=this.options.scales.yAxes[0].id)},this),this.buildScale(),this.tooltip=new e.Tooltip({_chart:this.chart,_data:this.data,_options:this.options},this),e.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.resetElements(),this.update()},nextPoint:function(t,e){return t[e+1]||t[e]},previousPoint:function(t,e){return t[e-1]||t[e]},resetElements:function(){this.eachElement(function(t,e,o,s){var a,r=this.scales[this.data.datasets[s].xAxisID],n=this.scales[this.data.datasets[s].yAxisID];a=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart,_xScale:r,_yScale:n,_datasetIndex:s,_index:e,_model:{x:r.getPixelForValue(this.data.datasets[s].data[e].x),y:a,tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o){var s=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=s.previous.x,t._model.controlPointNextX=s.next.x,t._model.controlPointNextY=s.next.y>this.chartArea.bottom?this.chartArea.bottom:s.next.ythis.chartArea.bottom?this.chartArea.bottom:s.previous.y0&&s.max>0?s.min:0),i.extend(t.metaDataset,{_scale:s,_datasetIndex:e,_children:t.metaData,_model:{tension:t.tension||this.options.elements.line.tension,backgroundColor:t.backgroundColor||this.options.elements.line.backgroundColor,borderWidth:t.borderWidth||this.options.elements.line.borderWidth,borderColor:t.borderColor||this.options.elements.line.borderColor,fill:void 0!==t.fill?t.fill:this.options.elements.line.fill,skipNull:void 0!==t.skipNull?t.skipNull:this.options.elements.line.skipNull,drawNull:void 0!==t.drawNull?t.drawNull:this.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:o}}),t.metaDataset.pivot()}),this.eachElement(function(t,e,o,s){var a=this.scales[this.data.datasets[s].xAxisID],r=this.scales[this.data.datasets[s].yAxisID];i.extend(t,{_chart:this.chart,_xScale:a,_yScale:r,_datasetIndex:s,_index:e,_model:{x:a.getPixelForValue(this.data.datasets[s].data[e].x),y:r.getPixelForValue(this.data.datasets[s].data[e].y),tension:t.custom&&t.custom.tension?t.custom.tension:this.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointRadius,e,this.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBackgroundColor,e,this.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderColor,e,this.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.data.datasets[s].pointBorderWidth,e,this.options.elements.point.borderWidth),skip:null===this.data.datasets[s].data[e]||null===this.data.datasets[s].data[e].x||null===this.data.datasets[s].data[e].y,hoverRadius:t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(this.data.datasets[s].pointHitRadius,e,this.options.elements.point.hitRadius)}})},this),this.eachElement(function(t,e,o){var s=i.splineCurve(this.previousPoint(o,e)._model,t._model,this.nextPoint(o,e)._model,t._model.tension);t._model.controlPointPreviousX=s.previous.x,t._model.controlPointNextX=s.next.x,t._model.controlPointNextY=s.next.y>this.chartArea.bottom?this.chartArea.bottom:s.next.ythis.chartArea.bottom?this.chartArea.bottom:s.previous.ythis.max&&(this.max=t.x)},this)},this)},s=function(){this.min=null,this.max=null,i.each(t.data.datasets,function(t){t.yAxisID===this.id&&i.each(t.data,function(t){null===this.min?this.min=t.y:t.ythis.max&&(this.max=t.y)},this)},this)};this.scales={},i.each(this.options.scales.xAxes,function(t){var i=e.scales.getScaleConstructor(t.type),s=new i({ctx:this.chart.ctx,options:t,calculateRange:o,id:t.id});this.scales[s.id]=s},this),i.each(this.options.scales.yAxes,function(t){var i=e.scales.getScaleConstructor(t.type),o=new i({ctx:this.chart.ctx,options:t,calculateRange:s,id:t.id,getPointPixelForValue:function(t){return this.getPixelForValue(t)}});this.scales[o.id]=o},this)},draw:function(t){var e=t||1;this.clear(),i.each(this.scales,function(t){t.draw(this.chartArea)},this);for(var o=this.data.datasets.length-1;o>=0;o--){var s=this.data.datasets[o];i.each(s.metaData,function(t){t.transition(e)},this),s.metaDataset.transition(e).draw(),i.each(s.metaData,function(t){t.draw()})}this.tooltip.transition(e).draw()},events:function(t){if("mouseout"==t.type)return this;this.lastActive=this.lastActive||[],this.active=function(){switch(this.options.hover.mode){case"single":return this.getElementAtEvent(t);case"label":return this.getElementsAtEvent(t);case"dataset":return this.getDatasetAtEvent(t);default:return t -}}.call(this),this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active);var e,o;if(this.lastActive.length)switch(this.options.hover.mode){case"single":e=this.data.datasets[this.lastActive[0]._datasetIndex],o=this.lastActive[0]._index,this.lastActive[0]._model.radius=this.lastActive[0].custom&&this.lastActive[0].custom.radius?this.lastActive[0].custom.pointRadius:i.getValueAtIndexOrDefault(e.pointRadius,o,this.options.elements.point.radius),this.lastActive[0]._model.backgroundColor=this.lastActive[0].custom&&this.lastActive[0].custom.backgroundColor?this.lastActive[0].custom.backgroundColor:i.getValueAtIndexOrDefault(e.pointBackgroundColor,o,this.options.elements.point.backgroundColor),this.lastActive[0]._model.borderColor=this.lastActive[0].custom&&this.lastActive[0].custom.borderColor?this.lastActive[0].custom.borderColor:i.getValueAtIndexOrDefault(e.pointBorderColor,o,this.options.elements.point.borderColor),this.lastActive[0]._model.borderWidth=this.lastActive[0].custom&&this.lastActive[0].custom.borderWidth?this.lastActive[0].custom.borderWidth:i.getValueAtIndexOrDefault(e.pointBorderWidth,o,this.options.elements.point.borderWidth);break;case"label":for(var s=0;s=o?o/12.92:Math.pow((o+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,o=this.alpha()-t.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,a=1-s,r=this.rgbArray(),n=t.rgbArray(),h=0;he&&(e+=360),o=(n+h)/2,i=h==n?0:.5>=o?l/(h+n):l/(2-h-n),[e,100*i,100*o]}function o(t){var e,i,o,s=t[0],a=t[1],r=t[2],n=Math.min(s,a,r),h=Math.max(s,a,r),l=h-n;return i=0==h?0:l/h*1e3/10,h==n?e=0:s==h?e=(a-r)/l:a==h?e=2+(r-s)/l:r==h&&(e=4+(s-a)/l),e=Math.min(60*e,360),0>e&&(e+=360),o=h/255*1e3/10,[e,i,o]}function s(t){var e=t[0],o=t[1],s=t[2],a=i(t)[0],r=1/255*Math.min(e,Math.min(o,s)),s=1-1/255*Math.max(e,Math.max(o,s));return[a,100*r,100*s]}function a(t){var e,i,o,s,a=t[0]/255,r=t[1]/255,n=t[2]/255;return s=Math.min(1-a,1-r,1-n),e=(1-a-s)/(1-s)||0,i=(1-r-s)/(1-s)||0,o=(1-n-s)/(1-s)||0,[100*e,100*i,100*o,100*s]}function n(t){return U[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var s=.4124*e+.3576*i+.1805*o,a=.2126*e+.7152*i+.0722*o,r=.0193*e+.1192*i+.9505*o;return[100*s,100*a,100*r]}function l(t){var e,i,o,s=h(t),a=s[0],r=s[1],n=s[2];return a/=95.047,r/=100,n/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*r-16,i=500*(a-r),o=200*(r-n),[e,i,o]}function c(t){return L(l(t))}function d(t){var e,i,o,s,a,r=t[0]/360,n=t[1]/100,h=t[2]/100;if(0==n)return a=255*h,[a,a,a];i=.5>h?h*(1+n):h+n-h*n,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)o=r+1/3*-(l-1),0>o&&o++,o>1&&o--,a=1>6*o?e+6*(i-e)*o:1>2*o?i:2>3*o?e+(i-e)*(2/3-o)*6:e,s[l]=255*a;return s}function u(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return a*=2,s*=1>=a?a:2-a,i=(a+s)/2,e=2*s/(a+s),[o,100*e,100*i]}function m(t){return s(d(t))}function v(t){return a(d(t))}function p(t){return n(d(t))}function f(t){var e=t[0]/60,i=t[1]/100,o=t[2]/100,s=Math.floor(e)%6,a=e-Math.floor(e),r=255*o*(1-i),n=255*o*(1-i*a),h=255*o*(1-i*(1-a)),o=255*o;switch(s){case 0:return[o,h,r];case 1:return[n,o,r];case 2:return[r,o,h];case 3:return[r,n,o];case 4:return[h,r,o];case 5:return[o,r,n]}}function x(t){var e,i,o=t[0],s=t[1]/100,a=t[2]/100;return i=(2-s)*a,e=s*a,e/=1>=i?i:2-i,e=e||0,i/=2,[o,100*e,100*i]}function A(t){return s(f(t))}function C(t){return a(f(t))}function y(t){return n(f(t))}function w(t){var e,i,o,s,a=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*a),i=1-h,o=6*a-e,0!=(1&e)&&(o=1-o),s=n+o*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(w(t))}function k(t){return o(w(t))}function S(t){return a(w(t))}function I(t){return n(w(t))}function P(t){var e,i,o,s=t[0]/100,a=t[1]/100,r=t[2]/100,n=t[3]/100;return e=1-Math.min(1,s*(1-n)+n),i=1-Math.min(1,a*(1-n)+n),o=1-Math.min(1,r*(1-n)+n),[255*e,255*i,255*o]}function W(t){return i(P(t))}function D(t){return o(P(t))}function O(t){return s(P(t))}function M(t){return n(P(t))}function V(t){var e,i,o,s=t[0]/100,a=t[1]/100,r=t[2]/100;return e=3.2406*s+-1.5372*a+r*-.4986,i=s*-.9689+1.8758*a+.0415*r,o=.0557*s+a*-.204+1.057*r,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=12.92*o,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),[255*e,255*i,255*o]}function R(t){var e,i,o,s=t[0],a=t[1],r=t[2];return s/=95.047,a/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*a-16,i=500*(s-a),o=200*(a-r),[e,i,o]}function B(t){return L(R(t))}function z(t){var e,i,o,s,a=t[0],r=t[1],n=t[2];return 8>=a?(i=100*a/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((a+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(r/500+s-16/116)/7.787:95.047*Math.pow(r/500+s,3),o=.008859>=o/108.883?o=108.883*(s-n/200-16/116)/7.787:108.883*Math.pow(s-n/200,3),[e,i,o]}function L(t){var e,i,o,s=t[0],a=t[1],r=t[2];return e=Math.atan2(r,a),i=360*e/2/Math.PI,0>i&&(i+=360),o=Math.sqrt(a*a+r*r),[s,o,i]}function T(t){return V(z(t))}function F(t){var e,i,o,s=t[0],a=t[1],r=t[2];return o=r/360*2*Math.PI,e=a*Math.cos(o),i=a*Math.sin(o),[s,e,i]}function E(t){return z(F(t))}function N(t){return T(F(t))}function H(t){return G[t]}function q(t){return i(H(t))}function Y(t){return o(H(t))}function j(t){return s(H(t))}function X(t){return a(H(t))}function Z(t){return l(H(t))}function Q(t){return h(H(t))}e.exports={rgb2hsl:i,rgb2hsv:o,rgb2hwb:s,rgb2cmyk:a,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:d,hsl2hsv:u,hsl2hwb:m,hsl2cmyk:v,hsl2keyword:p,hsv2rgb:f,hsv2hsl:x,hsv2hwb:A,hsv2cmyk:C,hsv2keyword:y,hwb2rgb:w,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:I,cmyk2rgb:P,cmyk2hsl:W,cmyk2hsv:D,cmyk2hwb:O,cmyk2keyword:M,keyword2rgb:H,keyword2hsl:q,keyword2hsv:Y,keyword2hwb:j,keyword2cmyk:X,keyword2lab:Z,keyword2xyz:Q,xyz2rgb:V,xyz2lab:R,xyz2lch:B,lab2xyz:z,lab2rgb:T,lab2lch:L,lch2lab:F,lch2xyz:E,lch2rgb:N};var G={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},U={};for(var $ in G)U[JSON.stringify(G[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),o=function(){return new h};for(var s in i){o[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var a=/(\w+)2(\w+)/.exec(s),r=a[1],n=a[2];o[r]=o[r]||{},o[r][n]=o[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var o=i[t](e);if("string"==typeof o||void 0===o)return o;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return u(t,e);var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+o+"%, "+s+"%)"}function u(t,e){var i=Math.round(t[0]/255*100),o=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+o+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?v(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function g(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function p(t){return A[t.slice(0,3)]}function f(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:o,getRgb:a,getHsl:r,getHwb:s,getAlpha:n,hexString:h,rgbString:l,rgbaString:c,percentString:d,percentaString:u,hslString:m,hslaString:v,hwbString:g,keyword:p};var A={};for(var C in x)A[x[C]]=C},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,n=e.x+i,s=e.base-(e.base-e.y),o=e.borderWidth/2;e.borderWidth&&(a+=o,n-=o,s+=o),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,s),t.lineTo(n,s),t.lineTo(n,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),n=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,s=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function n(t){var e,i,a,n=t[0],s=t[1],o=t[2],r=Math.min(n,s,o),h=Math.max(n,s,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(s-o)/l:s==h?e=2+(o-n)/l:o==h&&(e=4+(n-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],i=t[1],n=t[2],s=a(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[s,100*o,100*n]}function o(t){var e,i,a,n,s=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-s,1-o,1-r),e=(1-s-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,a=(1-r-n)/(1-n)||0,[100*e,100*i,100*a,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var n=.4124*e+.3576*i+.1805*a,s=.2126*e+.7152*i+.0722*a,o=.0193*e+.1192*i+.9505*a;return[100*n,100*s,100*o]}function c(t){var e,i,a,n=l(t),s=n[0],o=n[1],r=n[2];return s/=95.047,o/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(s-o),a=200*(o-r),[e,i,a]}function u(t){return O(c(t))}function d(t){var e,i,a,n,s,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)a=o+1/3*-(l-1),0>a&&a++,a>1&&a--,s=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,n[l]=255*s;return n}function f(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return s*=2,n*=1>=s?s:2-s,i=(s+n)/2,e=2*n/(s+n),[a,100*e,100*i]}function p(t){return s(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,n=Math.floor(e)%6,s=e-Math.floor(e),o=255*a*(1-i),r=255*a*(1-i*s),h=255*a*(1-i*(1-s)),a=255*a;switch(n){case 0:return[a,h,o];case 1:return[r,a,o];case 2:return[o,a,h];case 3:return[o,r,a];case 4:return[h,o,a];case 5:return[a,o,r]}}function y(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return i=(2-n)*s,e=n*s,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return s(x(t))}function k(t){return o(x(t))}function _(t){return h(x(t))}function C(t){var e,i,a,n,s=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*s),i=1-h,a=6*s-e,0!=(1&e)&&(a=1-a),n=o+a*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function S(t){return a(C(t))}function P(t){return n(C(t))}function M(t){return o(C(t))}function A(t){return h(C(t))}function D(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),a=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*a]}function F(t){return a(D(t))}function I(t){return n(D(t))}function z(t){return s(D(t))}function R(t){return h(D(t))}function T(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*s+o*-.4986,i=n*-.9689+1.8758*s+.0415*o,a=.0557*n+s*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function L(t){var e,i,a,n=t[0],s=t[1],o=t[2];return n/=95.047,s/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*s-16,i=500*(n-s),a=200*(s-o),[e,i,a]}function V(t){return O(L(t))}function W(t){var e,i,a,n,s=t[0],o=t[1],r=t[2];return 8>=s?(i=100*s/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),a=.008859>=a/108.883?a=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,a]}function O(t){var e,i,a,n=t[0],s=t[1],o=t[2];return e=Math.atan2(o,s),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(s*s+o*o),[n,a,i]}function E(t){return T(W(t))}function N(t){var e,i,a,n=t[0],s=t[1],o=t[2];return a=o/360*2*Math.PI,e=s*Math.cos(a),i=s*Math.sin(a),[n,e,i]}function H(t){return W(N(t))}function B(t){return E(N(t))}function q(t){return U[t]}function j(t){return a(q(t))}function Y(t){return n(q(t))}function X(t){return s(q(t))}function G(t){return o(q(t))}function Q(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:n,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:f,hsl2hwb:p,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:k,hsv2keyword:_,hwb2rgb:C,hwb2hsl:S,hwb2hsv:P,hwb2cmyk:M,hwb2keyword:A,cmyk2rgb:D,cmyk2hsl:F,cmyk2hsv:I,cmyk2hwb:z,cmyk2keyword:R,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:G,keyword2lab:Q,keyword2xyz:Z,xyz2rgb:T,xyz2lab:L,xyz2lch:V,lab2xyz:W,lab2rgb:E,lab2lch:O,lch2lab:N,lch2xyz:H,lch2rgb:B};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var a=t("./conversions"),n=function(){return new l};for(var s in a){n[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return f(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+n+"%)"}function f(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:n,getRgb:o,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:f,hslString:g,hslaString:p,hwbString:v,keyword:m};var w={};for(var k in y)w[y[k]]=k},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/samples/combo-bar-line.html b/samples/combo-bar-line.html new file mode 100644 index 00000000000..a4cd5fbfd9f --- /dev/null +++ b/samples/combo-bar-line.html @@ -0,0 +1,63 @@ + + + + + Bar Chart + + + + + +
    + +
    + + + + + diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index ef235c18d46..1e74c8a3ef2 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -93,7 +93,6 @@ backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), - }, }); rectangle.pivot(); @@ -122,16 +121,6 @@ // }, this); // }, - // eachRectangle: function(callback) { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // helpers.each(dataset.metaData, function(element, index) { - // if (element instanceof Chart.Rectangle) { - // callback(element, index, dataset, datasetIndex); - // } - // }, this); - // }, this); - // }, - // addLine: function addLine(dataset, datasetIndex) { // if (dataset) { // dataset.metaDataset = new Chart.Line({ @@ -322,7 +311,6 @@ // }, - // setElementHoverStyle: function setElementHoverStyle(element) { // if (element instanceof Chart.Point) { // this.setPointHoverStyle(element); @@ -341,7 +329,7 @@ // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); // }, - // setRectangleHoverStyle: function(rectangle) { + // setHoverStyle: function(rectangle) { // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; // var index = rectangle._index; @@ -388,42 +376,42 @@ // }, this); // }, - // getElementsAtEvent: function(e) { - // var elementsArray = [], - // eventPosition = helpers.getRelativePosition(e), - // datasetIterator = function(dataset) { - // elementsArray.push(dataset.metaData[elementIndex]); - // }, - // elementIndex; - - // for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { - // for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { - // if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - // helpers.each(this.chart.data.datasets, datasetIterator); - // } - // } - // } + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.chart.data.datasets, datasetIterator); + } + } + } - // return elementsArray.length ? elementsArray : []; - // }, + return elementsArray.length ? elementsArray : []; + }, // // Get the single element that was clicked on // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - // getElementAtEvent: function(e) { - // var element = []; - // var eventPosition = helpers.getRelativePosition(e); - - // for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { - // for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - // if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - // element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); - // return element; - // } - // } - // } + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } - // return []; - // }, + return []; + }, }); diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js new file mode 100644 index 00000000000..fd460eb92a6 --- /dev/null +++ b/src/controllers/controller.line.js @@ -0,0 +1,371 @@ +(function() { + + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.controllers.line = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; + + helpers.extend(Chart.controllers.line.prototype, { + + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, + + linkScales: function() { + if (!this.getDataset().xAxisID) { + this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; + } + + if (!this.getDataset().yAxisID) { + this.getDataset().yAxisID = this.chart.options.scales.yAxes[0].id; + } + }, + + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, + + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + + addElements: function() { + + this.getDataset().metaData = this.getDataset().metaData || []; + + this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _points: this.getDataset().metaData, + }); + + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + }, this); + }, + + reset: function() { + this.update(true); + }, + + update: function(reset) { + + var line = this.getDataset().metaDataset; + var points = this.getDataset().metaData; + + var yScale = this.getScaleForId(this.getDataset().yAxisID); + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + + // Update Line + helpers.extend(line, { + // Utility + _scale: yScale, + _datasetIndex: this.index, + // Data + _children: points, + // Model + _model: { + // Appearance + tension: line.custom && line.custom.tension ? line.custom.tension : (this.getDataset().tension || this.chart.options.elements.line.tension), + backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor), + borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth), + borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor), + fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill), + skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, + drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: scaleBase, + }, + }); + line.pivot(); + + // Update Points + helpers.each(points, function(point, index) { + helpers.extend(point, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + + }); + }, this); + + // Update bezier control points + helpers.each(this.getDataset().metaData, function(point, index) { + var controlPoints = helpers.splineCurve( + helpers.previousItem(this.getDataset().metaData, index)._model, + point._model, + helpers.nextItem(this.getDataset().metaData, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chart.chartArea.bottom) { + point._model.controlPointNextY = this.chart.chartArea.bottom; + } else if (controlPoints.next.y < this.chart.chartArea.top) { + point._model.controlPointNextY = this.chart.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chart.chartArea.bottom) { + point._model.controlPointPreviousY = this.chart.chartArea.bottom; + } else if (controlPoints.previous.y < this.chart.chartArea.top) { + point._model.controlPointPreviousY = this.chart.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + }, + + draw: function(ease) { + var easingDecimal = ease || 1; + + // Transition Point Locations + helpers.each(this.getDataset().metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + this.getDataset().metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(this.getDataset().metaData, function(point) { + point.draw(); + }); + }, + + + + + + + + + // eachLine: function eachLine(callback) { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { + // callback.call(this, dataset, datasetIndex); + // } + // }, this); + // }, + + // addPoint: function addPoint(dataset, datasetIndex, index) { + // if (dataset) { + // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); + + // if (index < dataset.metaData.length) { + // dataset.metaData[index] = new Chart.Point({ + // _datasetIndex: datasetIndex, + // _index: index, + // _chart: this.chart.chart, + // _model: { + // x: 0, + // y: 0, + // }, + // }); + // } + // } + // }, + + + + // resetElements: function resetElements() { + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.resetDatasetPoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (lines) + // this.resetDatasetRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { + // helpers.each(dataset.metaData, function(point, index) { + // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); + // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); + + // var yScalePoint; + + // if (yScale.min < 0 && yScale.max < 0) { + // // all less than 0. use the top + // yScalePoint = yScale.getPixelForValue(yScale.max); + // } else if (yScale.min > 0 && yScale.max > 0) { + // yScalePoint = yScale.getPixelForValue(yScale.min); + // } else { + // yScalePoint = yScale.getPixelForValue(0); + // } + + // helpers.extend(point, { + // // Utility + // _chart: this.chart.chart, //WTF + // _xScale: xScale, + // _yScale: yScale, + // _datasetIndex: datasetIndex, + // _index: index, + + // // Desired view properties + // _model: { + // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), + // y: yScalePoint, + // }, + // }); + + // this.updatePointElementAppearance(point, datasetIndex, index); + // }, this); + + // this.updateBezierControlPoints(dataset); + // }, + + // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { + + // }, + + // resetElementAppearance: function(element, datasetIndex, index) { + // if (element instanceof Chart.Point) { + // this.updatePointElementAppearance(element, datasetIndex, index); + // } else if (element instanceof Chart.Rectangle) { + // this.updateRectangleElementAppearance(element, datasetIndex, index); + // } + // }, + + // updateElements: function updateElements() { + // // Update the lines + // this.updateLines(); + + // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { + // // All elements must be the same type for the given dataset so we are fine to check just the first one + // if (dataset.metaData[0] instanceof Chart.Point) { + // // Have points. Update all of them + // this.updatePoints(dataset, datasetIndex); + // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { + // // Have rectangles (lines) + // this.updateRectangles(dataset, datasetIndex); + // } + // }, this); + // }, + + + // setElementHoverStyle: function setElementHoverStyle(element) { + // if (element instanceof Chart.Point) { + // this.setPointHoverStyle(element); + // } else if (element instanceof Chart.Rectangle) { + // this.setRectangleHoverStyle(element); + // } + // }, + + // setPointHoverStyle: function setPointHoverStyle(point) { + // var dataset = this.chart.data.datasets[point._datasetIndex]; + // var index = point._index; + + // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + // }, + + // setHoverStyle: function(rectangle) { + // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + // var index = rectangle._index; + + // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + // }, + + getElementsAtEvent: function(e) { + var elementsArray = [], + eventPosition = helpers.getRelativePosition(e), + datasetIterator = function(dataset) { + elementsArray.push(dataset.metaData[elementIndex]); + }, + elementIndex; + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.chart.data.datasets, datasetIterator); + } + } + } + + return elementsArray.length ? elementsArray : []; + }, + + // // Get the single element that was clicked on + // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn + getElementAtEvent: function(e) { + var element = []; + var eventPosition = helpers.getRelativePosition(e); + + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { + for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); + return element; + } + } + } + + return []; + }, + }); + + + +}).call(this); diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 4c2535ddd45..cacdf29b4af 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -191,6 +191,12 @@ this.tooltip.transition(easingDecimal).draw(); }, + + + + + + eachValue: function eachValue(callback) { helpers.each(this.data.datasets, function(dataset, datasetIndex) { helpers.each(dataset.data, callback, this, datasetIndex); diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index c3e649437d3..29f925bd509 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -327,6 +327,18 @@ } }; }, + nextItem = helpers.nextItem = function(collection, index, loop) { + if (loop) { + return collection[index + 1] || collection[0]; + } + return collection[index + 1] || collection[collection.length - 1]; + }, + previousItem = helpers.previousItem = function(collection, index, loop) { + if (loop) { + return collection[index - 1] || collection[collection.length - 1]; + } + return collection[index - 1] || collection[0]; + }, calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { return Math.floor(Math.log(val) / Math.LN10); }, diff --git a/src/elements/element.line.js b/src/elements/element.line.js index edefce6d092..bd5ba83269c 100644 --- a/src/elements/element.line.js +++ b/src/elements/element.line.js @@ -28,7 +28,7 @@ }; - Chart.Line = Chart.Element.extend({ + Chart.elements.Line = Chart.Element.extend({ draw: function() { var vm = this._view; @@ -38,8 +38,8 @@ // Draw the background first (so the border is always on top) helpers.each(this._children, function(point, index) { - var previous = this.previousPoint(point, this._children, index); - var next = this.nextPoint(point, this._children, index); + var previous = helpers.previousItem(this._children, index); + var next = helpers.nextItem(this._children, index); // First point only if (index === 0) { @@ -112,8 +112,8 @@ ctx.beginPath(); helpers.each(this._children, function(point, index) { - var previous = this.previousPoint(point, this._children, index); - var next = this.nextPoint(point, this._children, index); + var previous = helpers.previousItem(this._children, index); + var next = helpers.nextItem(this._children, index); // First point only if (index === 0) { @@ -173,18 +173,6 @@ ctx.stroke(); }, - nextPoint: function(point, collection, index) { - if (this.loop) { - return collection[index + 1] || collection[0]; - } - return collection[index + 1] || collection[collection.length - 1]; - }, - previousPoint: function(point, collection, index) { - if (this.loop) { - return collection[index - 1] || collection[collection.length - 1]; - } - return collection[index - 1] || collection[0]; - }, }); }).call(this); diff --git a/src/elements/element.point.js b/src/elements/element.point.js index 13e272de6f7..ff9517c3788 100644 --- a/src/elements/element.point.js +++ b/src/elements/element.point.js @@ -29,7 +29,7 @@ }; - Chart.Point = Chart.Element.extend({ + Chart.elements.Point = Chart.Element.extend({ inRange: function(mouseX, mouseY) { var vm = this._view; var hoverRange = vm.hitRadius + vm.radius; From 76d2a782fc966a1e697e07dfa92687ef4d810ac6 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 15 Jun 2015 17:31:29 -0400 Subject: [PATCH 168/424] Linear scale is reversible --- src/scales/scale.linear.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 60caae47734..a122886065e 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -22,6 +22,7 @@ }, // scale numbers + reverse: false, beginAtZero: false, override: null, @@ -122,6 +123,16 @@ // range of the scale this.max = helpers.max(this.ticks); this.min = helpers.min(this.ticks); + + if (this.options.reverse) { + this.ticks.reverse(); + + this.start = this.max; + this.end = this.min; + } else { + this.start = this.min; + this.end = this.max; + } }, buildLabels: function() { // We assume that this has been run after ticks have been generated. We try to figure out @@ -152,13 +163,13 @@ // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined var pixel; - var range = this.max - this.min; + var range = this.end - this.start; if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.min)); + pixel = this.left + (this.width / range * (value - this.start)); } else { // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.min)); + pixel = this.bottom - (this.height / range * (value - this.start)); } return pixel; From 872c9d5ebb5ab36a78fcdfb4721ff56c37d922eb Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 16:18:56 -0600 Subject: [PATCH 169/424] Hover macros, type defaults, and cleanup --- src/charts/chart.bar.js | 75 ---- src/charts/chart.line.js | 85 ----- src/controllers/controller.bar.js | 331 ++---------------- .../controller.doughnut.js} | 4 +- src/controllers/controller.line.js | 200 ++--------- .../controller.polarArea.js} | 4 +- .../controller.radar.js} | 4 +- .../controller.scatter.js} | 2 + src/core/core.controller.js | 118 ++----- src/elements/element.arc.js | 2 +- src/elements/element.point.js | 2 +- src/elements/element.rectangle.js | 2 +- 12 files changed, 110 insertions(+), 719 deletions(-) delete mode 100644 src/charts/chart.bar.js delete mode 100644 src/charts/chart.line.js rename src/{charts/chart.doughnut.js => controllers/controller.doughnut.js} (99%) rename src/{charts/chart.polarArea.js => controllers/controller.polarArea.js} (99%) rename src/{charts/chart.radar.js => controllers/controller.radar.js} (99%) rename src/{charts/chart.scatter.js => controllers/controller.scatter.js} (98%) diff --git a/src/charts/chart.bar.js b/src/charts/chart.bar.js deleted file mode 100644 index 24d2abb2bfb..00000000000 --- a/src/charts/chart.bar.js +++ /dev/null @@ -1,75 +0,0 @@ -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - - Chart.defaults.bar = { - hover: { - mode: "label" - }, - - scales: { - xAxes: [{ - type: "category", - categorySpacing: 10, - spacing: 1, - - // grid line settings - gridLines: { - offsetGridLines: true, - }, - }], - yAxes: [{ - type: "linear", - }], - }, - }; - - // Chart.Type.extend({ - // name: "Bar", - // defaults: defaultConfig, - // initialize: function() { - // this.elementController = new Chart.RectangularElementController(this); - // this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); - - // //Create a new bar for each piece of data - // helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // helpers.each(dataset.data, function(dataPoint, index) { - // this.elementController.addRectangle(dataset, datasetIndex, index); - // }, this); - - // // The bar chart only supports a single x axis because the x axis is always a category axis - // dataset.xAxisID = this.options.scales.xAxes[0].id; - - // if (!dataset.yAxisID) { - // dataset.yAxisID = this.options.scales.yAxes[0].id; - // } - // }, this); - - // this.canvasController.initialize(); - // }, - // draw: function(ease) { - - // var easingDecimal = ease || 1; - // this.clear(); - - // // Draw all the scales - // helpers.each(this.scales, function(scale) { - // scale.draw(this.chartArea); - // }, this); - - // //Draw all the bars for each dataset - // this.eachElement(function(bar, index, datasetIndex) { - // bar.transition(easingDecimal).draw(); - // }, this); - - // // Finally draw the tooltip - // this.tooltip.transition(easingDecimal).draw(); - // }, - // }); - - -}).call(this); diff --git a/src/charts/chart.line.js b/src/charts/chart.line.js deleted file mode 100644 index 469cf0c8739..00000000000 --- a/src/charts/chart.line.js +++ /dev/null @@ -1,85 +0,0 @@ -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - hover: { - mode: "label" - }, - - scales: { - xAxes: [{ - type: "category", - }], - yAxes: [{ - type: "linear", - }], - }, - }; - - - Chart.Type.extend({ - name: "Line", - defaults: defaultConfig, - initialize: function() { - - this.elementController = new Chart.RectangularElementController(this); - this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - this.elementController.addLine(dataset, datasetIndex); - - helpers.each(dataset.data, function(dataPoint, index) { - this.elementController.addPoint(dataset, datasetIndex, index); - }, this); - - // The line chart onlty supports a single x axis because the x axis is always a dataset axis - if (!dataset.xAxisID) { - dataset.xAxisID = this.options.scales.xAxes[0].id; - } - - if (!dataset.yAxisID) { - dataset.yAxisID = this.options.scales.yAxes[0].id; - } - }, this); - - this.canvasController.initialize(); - }, - draw: function(ease) { - - var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - helpers.each(this.scales, function(scale) { - scale.draw(this.chartArea); - }, this); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } - - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); - }, - }); -}).call(this); diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 1e74c8a3ef2..7abc60df6b5 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -6,6 +6,28 @@ Chart = root.Chart, helpers = Chart.helpers; + Chart.defaults.bar = { + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + type: "category", + categorySpacing: 10, + spacing: 1, + + // grid line settings + gridLines: { + offsetGridLines: true, + }, + }], + yAxes: [{ + type: "linear", + }], + }, + }; + Chart.controllers.bar = function(chart, datasetIndex) { this.initialize.call(this, chart, datasetIndex); }; @@ -108,310 +130,19 @@ + setHoverStyle: function(rectangle) { + var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + var index = rectangle._index; - - - - - // eachLine: function eachLine(callback) { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { - // callback.call(this, dataset, datasetIndex); - // } - // }, this); - // }, - - // addLine: function addLine(dataset, datasetIndex) { - // if (dataset) { - // dataset.metaDataset = new Chart.Line({ - // _chart: this.chart.chart, - // _datasetIndex: datasetIndex, - // _points: dataset.metaData, - // }); - // } - // }, - - // addPoint: function addPoint(dataset, datasetIndex, index) { - // if (dataset) { - // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); - - // if (index < dataset.metaData.length) { - // dataset.metaData[index] = new Chart.Point({ - // _datasetIndex: datasetIndex, - // _index: index, - // _chart: this.chart.chart, - // _model: { - // x: 0, - // y: 0, - // }, - // }); - // } - // } - // }, - - - - // resetElements: function resetElements() { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.resetDatasetPoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (bars) - // this.resetDatasetRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { - // helpers.each(dataset.metaData, function(point, index) { - // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); - - // var yScalePoint; - - // if (yScale.min < 0 && yScale.max < 0) { - // // all less than 0. use the top - // yScalePoint = yScale.getPixelForValue(yScale.max); - // } else if (yScale.min > 0 && yScale.max > 0) { - // yScalePoint = yScale.getPixelForValue(yScale.min); - // } else { - // yScalePoint = yScale.getPixelForValue(0); - // } - - // helpers.extend(point, { - // // Utility - // _chart: this.chart.chart, //WTF - // _xScale: xScale, - // _yScale: yScale, - // _datasetIndex: datasetIndex, - // _index: index, - - // // Desired view properties - // _model: { - // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // y: yScalePoint, - // }, - // }); - - // this.updatePointElementAppearance(point, datasetIndex, index); - // }, this); - - // this.updateBezierControlPoints(dataset); - // }, - - // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { - - // }, - - // resetElementAppearance: function(element, datasetIndex, index) { - // if (element instanceof Chart.Point) { - // this.updatePointElementAppearance(element, datasetIndex, index); - // } else if (element instanceof Chart.Rectangle) { - // this.updateRectangleElementAppearance(element, datasetIndex, index); - // } - // }, - - // updateElements: function updateElements() { - // // Update the lines - // this.updateLines(); - - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.updatePoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (bars) - // this.updateRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - // updateLines: function updateLines() { - // this.eachLine(function(dataset, datasetIndex) { - // var yScale = this.getScaleForId(dataset.yAxisID); - // var scaleBase; - - // if (yScale.min < 0 && yScale.max < 0) { - // scaleBase = yScale.getPixelForValue(yScale.max); - // } else if (yScale.min > 0 && yScale.max > 0) { - // scaleBase = yScale.getPixelForValue(yScale.min); - // } else { - // scaleBase = yScale.getPixelForValue(0); - // } - - // helpers.extend(dataset.metaDataset, { - // // Utility - // _scale: yScale, - // _datasetIndex: datasetIndex, - // // Data - // _children: dataset.metaData, - // // Model - // _model: { - // // Appearance - // tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chart.options.elements.line.tension), - // backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chart.options.elements.line.backgroundColor), - // borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chart.options.elements.line.borderWidth), - // borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chart.options.elements.line.borderColor), - // fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chart.options.elements.line.fill), - // skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chart.options.elements.line.skipNull, - // drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chart.options.elements.line.drawNull, - // // Scale - // scaleTop: yScale.top, - // scaleBottom: yScale.bottom, - // scaleZero: scaleBase, - // }, - // }); - - // dataset.metaDataset.pivot(); - // }); - // }, - - // updatePoints: function updatePoints(dataset, datasetIndex) { - // helpers.each(dataset.metaData, function(point, index) { - // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); - - // helpers.extend(point, { - // // Utility - // _chart: this.chart.chart, - // _xScale: xScale, - // _yScale: yScale, - // _datasetIndex: datasetIndex, - // _index: index, - - // // Desired view properties - // _model: { - // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // y: yScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // }, - // }); - - // this.updatePointElementAppearance(point, datasetIndex, index); - // }, this); - - // this.updateBezierControlPoints(dataset); - // }, - - // updatePointElementAppearance: function updatePointElementAppearance(point, datasetIndex, index) { - // helpers.extend(point._model, { - // // Appearance - // tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - // radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), - // backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - // borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), - // borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - // skip: this.chart.data.datasets[datasetIndex].data[index] === null, - - // // Tooltip - // hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), - // }); - // }, - - - // setElementHoverStyle: function setElementHoverStyle(element) { - // if (element instanceof Chart.Point) { - // this.setPointHoverStyle(element); - // } else if (element instanceof Chart.Rectangle) { - // this.setRectangleHoverStyle(element); - // } - // }, - - // setPointHoverStyle: function setPointHoverStyle(point) { - // var dataset = this.chart.data.datasets[point._datasetIndex]; - // var index = point._index; - - // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); - // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); - // }, - - // setHoverStyle: function(rectangle) { - // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; - // var index = rectangle._index; - - // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); - // }, - - // updateBezierControlPoints: function updateBezierControlPoints(dataset) { - // // Update control points for the bezier curve - // helpers.each(dataset.metaData, function(point, index) { - // var controlPoints = helpers.splineCurve( - // this.previousPoint(dataset.metaData, index)._model, - // point._model, - // this.nextPoint(dataset.metaData, index)._model, - // point._model.tension - // ); - - // point._model.controlPointPreviousX = controlPoints.previous.x; - // point._model.controlPointNextX = controlPoints.next.x; - - // // Prevent the bezier going outside of the bounds of the graph - - // // Cap puter bezier handles to the upper/lower scale bounds - // if (controlPoints.next.y > this.chart.chartArea.bottom) { - // point._model.controlPointNextY = this.chart.chartArea.bottom; - // } else if (controlPoints.next.y < this.chart.chartArea.top) { - // point._model.controlPointNextY = this.chart.chartArea.top; - // } else { - // point._model.controlPointNextY = controlPoints.next.y; - // } - - // // Cap inner bezier handles to the upper/lower scale bounds - // if (controlPoints.previous.y > this.chart.chartArea.bottom) { - // point._model.controlPointPreviousY = this.chart.chartArea.bottom; - // } else if (controlPoints.previous.y < this.chart.chartArea.top) { - // point._model.controlPointPreviousY = this.chart.chartArea.top; - // } else { - // point._model.controlPointPreviousY = controlPoints.previous.y; - // } - - // // Now pivot the point for animation - // point.pivot(); - // }, this); - // }, - - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.chart.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; + rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); }, - // // Get the single element that was clicked on - // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } + removeHoverStyle: function(rectangle) { + // TODO + } - return []; - }, }); diff --git a/src/charts/chart.doughnut.js b/src/controllers/controller.doughnut.js similarity index 99% rename from src/charts/chart.doughnut.js rename to src/controllers/controller.doughnut.js index 47884f29831..2324a78505f 100644 --- a/src/charts/chart.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -1,6 +1,8 @@ (function() { "use strict"; + return; + var root = this, Chart = root.Chart, //Cache a local reference to Chart.helpers @@ -347,7 +349,7 @@ var location = helpers.getRelativePosition(e); this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { + if (slice.inLabelRange(location.x, location.y)) { elements.push(slice); } }, this); diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index fd460eb92a6..14462210993 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -6,6 +6,22 @@ Chart = root.Chart, helpers = Chart.helpers; + Chart.defaults.line = { + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + type: "category", + }], + yAxes: [{ + type: "linear", + }], + }, + }; + + Chart.controllers.line = function(chart, datasetIndex) { this.initialize.call(this, chart, datasetIndex); }; @@ -187,183 +203,21 @@ }); }, + setHoverStyle: function(point) { + // Point + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; - - - - - - - // eachLine: function eachLine(callback) { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { - // callback.call(this, dataset, datasetIndex); - // } - // }, this); - // }, - - // addPoint: function addPoint(dataset, datasetIndex, index) { - // if (dataset) { - // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); - - // if (index < dataset.metaData.length) { - // dataset.metaData[index] = new Chart.Point({ - // _datasetIndex: datasetIndex, - // _index: index, - // _chart: this.chart.chart, - // _model: { - // x: 0, - // y: 0, - // }, - // }); - // } - // } - // }, - - - - // resetElements: function resetElements() { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.resetDatasetPoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (lines) - // this.resetDatasetRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { - // helpers.each(dataset.metaData, function(point, index) { - // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); - - // var yScalePoint; - - // if (yScale.min < 0 && yScale.max < 0) { - // // all less than 0. use the top - // yScalePoint = yScale.getPixelForValue(yScale.max); - // } else if (yScale.min > 0 && yScale.max > 0) { - // yScalePoint = yScale.getPixelForValue(yScale.min); - // } else { - // yScalePoint = yScale.getPixelForValue(0); - // } - - // helpers.extend(point, { - // // Utility - // _chart: this.chart.chart, //WTF - // _xScale: xScale, - // _yScale: yScale, - // _datasetIndex: datasetIndex, - // _index: index, - - // // Desired view properties - // _model: { - // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // y: yScalePoint, - // }, - // }); - - // this.updatePointElementAppearance(point, datasetIndex, index); - // }, this); - - // this.updateBezierControlPoints(dataset); - // }, - - // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { - - // }, - - // resetElementAppearance: function(element, datasetIndex, index) { - // if (element instanceof Chart.Point) { - // this.updatePointElementAppearance(element, datasetIndex, index); - // } else if (element instanceof Chart.Rectangle) { - // this.updateRectangleElementAppearance(element, datasetIndex, index); - // } - // }, - - // updateElements: function updateElements() { - // // Update the lines - // this.updateLines(); - - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.updatePoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (lines) - // this.updateRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - - // setElementHoverStyle: function setElementHoverStyle(element) { - // if (element instanceof Chart.Point) { - // this.setPointHoverStyle(element); - // } else if (element instanceof Chart.Rectangle) { - // this.setRectangleHoverStyle(element); - // } - // }, - - // setPointHoverStyle: function setPointHoverStyle(point) { - // var dataset = this.chart.data.datasets[point._datasetIndex]; - // var index = point._index; - - // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); - // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); - // }, - - // setHoverStyle: function(rectangle) { - // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; - // var index = rectangle._index; - - // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); - // }, - - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; - - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.chart.data.datasets, datasetIterator); - } - } - } - - return elementsArray.length ? elementsArray : []; + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); }, - // // Get the single element that was clicked on - // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); - - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } + removeHoverStyle: function(point) { + // TODO + } - return []; - }, }); diff --git a/src/charts/chart.polarArea.js b/src/controllers/controller.polarArea.js similarity index 99% rename from src/charts/chart.polarArea.js rename to src/controllers/controller.polarArea.js index dcbb90c4236..22b0fbb3ab3 100644 --- a/src/charts/chart.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -1,6 +1,8 @@ (function() { "use strict"; + return; + var root = this, Chart = root.Chart, //Cache a local reference to Chart.helpers @@ -335,7 +337,7 @@ var location = helpers.getRelativePosition(e); this.eachElement(function(slice, index) { - if (slice.inGroupRange(location.x, location.y)) { + if (slice.inLabelRange(location.x, location.y)) { elements.push(slice); } }, this); diff --git a/src/charts/chart.radar.js b/src/controllers/controller.radar.js similarity index 99% rename from src/charts/chart.radar.js rename to src/controllers/controller.radar.js index 3f723cba30b..b813764bfc1 100644 --- a/src/charts/chart.radar.js +++ b/src/controllers/controller.radar.js @@ -1,6 +1,8 @@ (function() { "use strict"; + return; + var root = this, Chart = root.Chart, helpers = Chart.helpers; @@ -135,7 +137,7 @@ this.scale.calculateRange(); this.scale.generateTicks(); this.scale.buildYLabels(); - + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); // Update the lines diff --git a/src/charts/chart.scatter.js b/src/controllers/controller.scatter.js similarity index 98% rename from src/charts/chart.scatter.js rename to src/controllers/controller.scatter.js index fb2f101fe1e..7048897b9ea 100644 --- a/src/charts/chart.scatter.js +++ b/src/controllers/controller.scatter.js @@ -1,6 +1,8 @@ (function() { "use strict"; + return; + var root = this, Chart = root.Chart, helpers = Chart.helpers; diff --git a/src/core/core.controller.js b/src/core/core.controller.js index cacdf29b4af..55c4159d39c 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -118,29 +118,29 @@ }, buildControllers: function() { - this.eachDataset(function(dataset, datasetIndex) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { var type = dataset.type || this.config.type; if (dataset.controller) { dataset.controller.updateIndex(datasetIndex); return; } dataset.controller = new Chart.controllers[type](this, datasetIndex); - }); + }, this); }, resetElements: function resetElements() { - this.eachDataset(function(dataset, datasetIndex) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.reset(); - }); + }, this); }, update: function update(animationDuration) { // This will loop through any data and do the appropriate element update for the type Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - this.eachDataset(function(dataset, datasetIndex) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.update(); - }); + }, this); this.render(animationDuration); }, @@ -195,90 +195,48 @@ - - - eachValue: function eachValue(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, callback, this, datasetIndex); - }, this); - }, - - eachElement: function eachElement(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - }, this); - }, - - eachDataset: function eachDataset(callback) { - helpers.each(this.data.datasets, callback, this); - }, - - // 2 helper functions to get next/previous elements in datasets - nextElement: function nextElement(datasets, index, loop) { - if (this.loop) { - return dataset[index + 1] || dataset[0]; - } - return datasets[index + 1] || datasets[index]; - }, - previousElement: function previousElement(datasets, index, loop) { - if (this.loop) { - return dataset[index - 1] || dataset[dataset.length - 1]; - } - return datasets[index - 1] || datasets[index]; - }, - // Get the single element that was clicked on // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw - getElementAtEvent: function getElementAtEvent(e) { + getElementAtEvent: function(e) { - var element = []; var eventPosition = helpers.getRelativePosition(e); + var element = []; - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(element, index) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); return element; } - } - } + }, this); + }, this); return []; }, - getElementsAtEvent: function getElementsAtEvent(e) { - - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; + getElementsAtEvent: function(e) { + var eventPosition = helpers.getRelativePosition(e); + var elementsArray = []; - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(element, index) { + if (element.inRange(eventPosition.x, eventPosition.y)) { + elementsArray.push(element); } - } - } + }, this); + }, this); - return elementsArray.length ? elementsArray : []; + return elementsArray; }, - getDatasetAtEvent: function getDatasetAtEvent(e) { - - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; + getDatasetAtEvent: function(e) { + var eventPosition = helpers.getRelativePosition(e); + var elementsArray = []; - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inLabelRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.chart.data.datasets, datasetIterator); } } } @@ -338,11 +296,11 @@ this.active = function() { switch (this.options.hover.mode) { case 'single': - return this.elementController.getElementAtEvent(e); + return this.getElementAtEvent(e); case 'label': - return this.elementController.getElementsAtEvent(e); + return this.getElementsAtEvent(e); case 'dataset': - return this.elementController.getDatasetAtEvent(e); + return this.getDatasetAtEvent(e); default: return e; } @@ -366,11 +324,11 @@ if (this.lastActive.length) { switch (this.options.hover.mode) { case 'single': - this.elementController.resetElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); + this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { - this.elementController.resetElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); } break; case 'dataset': @@ -384,11 +342,11 @@ if (this.active.length && this.options.hover.mode) { switch (this.options.hover.mode) { case 'single': - this.elementController.setElementHoverStyle(this.active[0]); + this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[0]); break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.elementController.setElementHoverStyle(this.active[i]); + this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[i]); } break; case 'dataset': diff --git a/src/elements/element.arc.js b/src/elements/element.arc.js index a726abfd29a..f5a3c628a73 100644 --- a/src/elements/element.arc.js +++ b/src/elements/element.arc.js @@ -24,7 +24,7 @@ }; Chart.Arc = Chart.Element.extend({ - inGroupRange: function(mouseX) { + inLabelRange: function(mouseX) { var vm = this._view; if (vm) { diff --git a/src/elements/element.point.js b/src/elements/element.point.js index ff9517c3788..1a4f709cb44 100644 --- a/src/elements/element.point.js +++ b/src/elements/element.point.js @@ -35,7 +35,7 @@ var hoverRange = vm.hitRadius + vm.radius; return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); }, - inGroupRange: function(mouseX) { + inLabelRange: function(mouseX) { var vm = this._view; if (vm) { diff --git a/src/elements/element.rectangle.js b/src/elements/element.rectangle.js index f4b71a38058..10682b1c07d 100644 --- a/src/elements/element.rectangle.js +++ b/src/elements/element.rectangle.js @@ -61,7 +61,7 @@ return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); } }, - inGroupRange: function(mouseX) { + inLabelRange: function(mouseX) { var vm = this._view; return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); }, From 9f9237905af991f829463b12f170cc94139002d8 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 16:19:56 -0600 Subject: [PATCH 170/424] Line now draws --- Chart.js | 2124 +++++++++++++++++++++++++++++---------------- Chart.min.js | 10 +- samples/line.html | 3 +- 3 files changed, 1406 insertions(+), 731 deletions(-) diff --git a/Chart.js b/Chart.js index 4ab301d1518..f620d39f0af 100644 --- a/Chart.js +++ b/Chart.js @@ -1312,29 +1312,29 @@ }, buildControllers: function() { - this.eachDataset(function(dataset, datasetIndex) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { var type = dataset.type || this.config.type; if (dataset.controller) { dataset.controller.updateIndex(datasetIndex); return; } dataset.controller = new Chart.controllers[type](this, datasetIndex); - }); + }, this); }, resetElements: function resetElements() { - this.eachDataset(function(dataset, datasetIndex) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.reset(); - }); + }, this); }, update: function update(animationDuration) { // This will loop through any data and do the appropriate element update for the type Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - this.eachDataset(function(dataset, datasetIndex) { + helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.update(); - }); + }, this); this.render(animationDuration); }, @@ -1389,90 +1389,48 @@ - - - eachValue: function eachValue(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.data, callback, this, datasetIndex); - }, this); - }, - - eachElement: function eachElement(callback) { - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - helpers.each(dataset.metaData, callback, this, dataset.metaData, datasetIndex); - }, this); - }, - - eachDataset: function eachDataset(callback) { - helpers.each(this.data.datasets, callback, this); - }, - - // 2 helper functions to get next/previous elements in datasets - nextElement: function nextElement(datasets, index, loop) { - if (this.loop) { - return dataset[index + 1] || dataset[0]; - } - return datasets[index + 1] || datasets[index]; - }, - previousElement: function previousElement(datasets, index, loop) { - if (this.loop) { - return dataset[index - 1] || dataset[dataset.length - 1]; - } - return datasets[index - 1] || datasets[index]; - }, - // Get the single element that was clicked on // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw - getElementAtEvent: function getElementAtEvent(e) { + getElementAtEvent: function(e) { - var element = []; var eventPosition = helpers.getRelativePosition(e); + var element = []; - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.data.datasets[datasetIndex].metaData[elementIndex]); + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(element, index) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { + element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); return element; } - } - } + }, this); + }, this); return []; }, - getElementsAtEvent: function getElementsAtEvent(e) { - - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; + getElementsAtEvent: function(e) { + var eventPosition = helpers.getRelativePosition(e); + var elementsArray = []; - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + helpers.each(dataset.metaData, function(element, index) { + if (element.inRange(eventPosition.x, eventPosition.y)) { + elementsArray.push(element); } - } - } + }, this); + }, this); - return elementsArray.length ? elementsArray : []; + return elementsArray; }, - getDatasetAtEvent: function getDatasetAtEvent(e) { - - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; + getDatasetAtEvent: function(e) { + var eventPosition = helpers.getRelativePosition(e); + var elementsArray = []; - for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets, datasetIterator); + for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { + for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inLabelRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.chart.data.datasets, datasetIterator); } } } @@ -1532,11 +1490,11 @@ this.active = function() { switch (this.options.hover.mode) { case 'single': - return this.elementController.getElementAtEvent(e); + return this.getElementAtEvent(e); case 'label': - return this.elementController.getElementsAtEvent(e); + return this.getElementsAtEvent(e); case 'dataset': - return this.elementController.getDatasetAtEvent(e); + return this.getDatasetAtEvent(e); default: return e; } @@ -1560,11 +1518,11 @@ if (this.lastActive.length) { switch (this.options.hover.mode) { case 'single': - this.elementController.resetElementAppearance(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); + this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { - this.elementController.resetElementAppearance(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); } break; case 'dataset': @@ -1578,11 +1536,11 @@ if (this.active.length && this.options.hover.mode) { switch (this.options.hover.mode) { case 'single': - this.elementController.setElementHoverStyle(this.active[0]); + this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[0]); break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.elementController.setElementHoverStyle(this.active[i]); + this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[i]); } break; case 'dataset': @@ -2287,6 +2245,28 @@ Chart = root.Chart, helpers = Chart.helpers; + Chart.defaults.bar = { + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + type: "category", + categorySpacing: 10, + spacing: 1, + + // grid line settings + gridLines: { + offsetGridLines: true, + }, + }], + yAxes: [{ + type: "linear", + }], + }, + }; + Chart.controllers.bar = function(chart, datasetIndex) { this.initialize.call(this, chart, datasetIndex); }; @@ -2389,456 +2369,1186 @@ + setHoverStyle: function(rectangle) { + var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + var index = rectangle._index; + rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + }, + removeHoverStyle: function(rectangle) { + // TODO + } + }); - // eachLine: function eachLine(callback) { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { - // callback.call(this, dataset, datasetIndex); - // } - // }, this); - // }, - - // addLine: function addLine(dataset, datasetIndex) { - // if (dataset) { - // dataset.metaDataset = new Chart.Line({ - // _chart: this.chart.chart, - // _datasetIndex: datasetIndex, - // _points: dataset.metaData, - // }); - // } - // }, - - // addPoint: function addPoint(dataset, datasetIndex, index) { - // if (dataset) { - // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); - - // if (index < dataset.metaData.length) { - // dataset.metaData[index] = new Chart.Point({ - // _datasetIndex: datasetIndex, - // _index: index, - // _chart: this.chart.chart, - // _model: { - // x: 0, - // y: 0, - // }, - // }); - // } - // } - // }, - - - - // resetElements: function resetElements() { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.resetDatasetPoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (bars) - // this.resetDatasetRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { - // helpers.each(dataset.metaData, function(point, index) { - // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); - - // var yScalePoint; - - // if (yScale.min < 0 && yScale.max < 0) { - // // all less than 0. use the top - // yScalePoint = yScale.getPixelForValue(yScale.max); - // } else if (yScale.min > 0 && yScale.max > 0) { - // yScalePoint = yScale.getPixelForValue(yScale.min); - // } else { - // yScalePoint = yScale.getPixelForValue(0); - // } - - // helpers.extend(point, { - // // Utility - // _chart: this.chart.chart, //WTF - // _xScale: xScale, - // _yScale: yScale, - // _datasetIndex: datasetIndex, - // _index: index, - - // // Desired view properties - // _model: { - // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // y: yScalePoint, - // }, - // }); - - // this.updatePointElementAppearance(point, datasetIndex, index); - // }, this); - - // this.updateBezierControlPoints(dataset); - // }, - - // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { - - // }, - - // resetElementAppearance: function(element, datasetIndex, index) { - // if (element instanceof Chart.Point) { - // this.updatePointElementAppearance(element, datasetIndex, index); - // } else if (element instanceof Chart.Rectangle) { - // this.updateRectangleElementAppearance(element, datasetIndex, index); - // } - // }, - - // updateElements: function updateElements() { - // // Update the lines - // this.updateLines(); - - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.updatePoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (bars) - // this.updateRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - // updateLines: function updateLines() { - // this.eachLine(function(dataset, datasetIndex) { - // var yScale = this.getScaleForId(dataset.yAxisID); - // var scaleBase; - - // if (yScale.min < 0 && yScale.max < 0) { - // scaleBase = yScale.getPixelForValue(yScale.max); - // } else if (yScale.min > 0 && yScale.max > 0) { - // scaleBase = yScale.getPixelForValue(yScale.min); - // } else { - // scaleBase = yScale.getPixelForValue(0); - // } - - // helpers.extend(dataset.metaDataset, { - // // Utility - // _scale: yScale, - // _datasetIndex: datasetIndex, - // // Data - // _children: dataset.metaData, - // // Model - // _model: { - // // Appearance - // tension: dataset.metaDataset.custom && dataset.metaDataset.custom.tension ? dataset.metaDataset.custom.tension : (dataset.tension || this.chart.options.elements.line.tension), - // backgroundColor: dataset.metaDataset.custom && dataset.metaDataset.custom.backgroundColor ? dataset.metaDataset.custom.backgroundColor : (dataset.backgroundColor || this.chart.options.elements.line.backgroundColor), - // borderWidth: dataset.metaDataset.custom && dataset.metaDataset.custom.borderWidth ? dataset.metaDataset.custom.borderWidth : (dataset.borderWidth || this.chart.options.elements.line.borderWidth), - // borderColor: dataset.metaDataset.custom && dataset.metaDataset.custom.borderColor ? dataset.metaDataset.custom.borderColor : (dataset.borderColor || this.chart.options.elements.line.borderColor), - // fill: dataset.metaDataset.custom && dataset.metaDataset.custom.fill ? dataset.metaDataset.custom.fill : (dataset.fill !== undefined ? dataset.fill : this.chart.options.elements.line.fill), - // skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.chart.options.elements.line.skipNull, - // drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.chart.options.elements.line.drawNull, - // // Scale - // scaleTop: yScale.top, - // scaleBottom: yScale.bottom, - // scaleZero: scaleBase, - // }, - // }); - - // dataset.metaDataset.pivot(); - // }); - // }, - - // updatePoints: function updatePoints(dataset, datasetIndex) { - // helpers.each(dataset.metaData, function(point, index) { - // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); - - // helpers.extend(point, { - // // Utility - // _chart: this.chart.chart, - // _xScale: xScale, - // _yScale: yScale, - // _datasetIndex: datasetIndex, - // _index: index, - - // // Desired view properties - // _model: { - // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // y: yScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // }, - // }); - - // this.updatePointElementAppearance(point, datasetIndex, index); - // }, this); - - // this.updateBezierControlPoints(dataset); - // }, - - // updatePointElementAppearance: function updatePointElementAppearance(point, datasetIndex, index) { - // helpers.extend(point._model, { - // // Appearance - // tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - // radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].radius, index, this.chart.options.elements.point.radius), - // backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - // borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderColor, index, this.chart.options.elements.point.borderColor), - // borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - // skip: this.chart.data.datasets[datasetIndex].data[index] === null, - - // // Tooltip - // hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.chart.data.datasets[datasetIndex].hitRadius, index, this.chart.options.elements.point.hitRadius), - // }); - // }, - - - // setElementHoverStyle: function setElementHoverStyle(element) { - // if (element instanceof Chart.Point) { - // this.setPointHoverStyle(element); - // } else if (element instanceof Chart.Rectangle) { - // this.setRectangleHoverStyle(element); - // } - // }, - - // setPointHoverStyle: function setPointHoverStyle(point) { - // var dataset = this.chart.data.datasets[point._datasetIndex]; - // var index = point._index; - - // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); - // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); - // }, - - // setHoverStyle: function(rectangle) { - // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; - // var index = rectangle._index; - - // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); - // }, - - // updateBezierControlPoints: function updateBezierControlPoints(dataset) { - // // Update control points for the bezier curve - // helpers.each(dataset.metaData, function(point, index) { - // var controlPoints = helpers.splineCurve( - // this.previousPoint(dataset.metaData, index)._model, - // point._model, - // this.nextPoint(dataset.metaData, index)._model, - // point._model.tension - // ); - - // point._model.controlPointPreviousX = controlPoints.previous.x; - // point._model.controlPointNextX = controlPoints.next.x; - - // // Prevent the bezier going outside of the bounds of the graph - - // // Cap puter bezier handles to the upper/lower scale bounds - // if (controlPoints.next.y > this.chart.chartArea.bottom) { - // point._model.controlPointNextY = this.chart.chartArea.bottom; - // } else if (controlPoints.next.y < this.chart.chartArea.top) { - // point._model.controlPointNextY = this.chart.chartArea.top; - // } else { - // point._model.controlPointNextY = controlPoints.next.y; - // } - - // // Cap inner bezier handles to the upper/lower scale bounds - // if (controlPoints.previous.y > this.chart.chartArea.bottom) { - // point._model.controlPointPreviousY = this.chart.chartArea.bottom; - // } else if (controlPoints.previous.y < this.chart.chartArea.top) { - // point._model.controlPointPreviousY = this.chart.chartArea.top; - // } else { - // point._model.controlPointPreviousY = controlPoints.previous.y; - // } - - // // Now pivot the point for animation - // point.pivot(); - // }, this); - // }, - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; +}).call(this); - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.chart.data.datasets, datasetIterator); - } - } - } +(function() { + "use strict"; - return elementsArray.length ? elementsArray : []; - }, + return; - // // Get the single element that was clicked on - // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); - return element; - } - } - } + var defaultConfig = { - return []; + animation: { + //Boolean - Whether we animate the rotation of the Doughnut + animateRotate: true, + + //Boolean - Whether we animate scaling the Doughnut from the centre + animateScale: false, }, - }); + hover: { + mode: 'single' + }, + //The percentage of the chart that we cut out of the middle. -}).call(this); + cutoutPercentage: 50, -(function() { + }; - "use strict"; + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "Doughnut", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + //Set up tooltip events on the chart + helpers.bindEvents(this, this.options.events, this.events); - Chart.controllers.line = function(chart, datasetIndex) { - this.initialize.call(this, chart, datasetIndex); - }; + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); + }, this); - helpers.extend(Chart.controllers.line.prototype, { + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); - initialize: function(chart, datasetIndex) { - this.chart = chart; - this.index = datasetIndex; - this.linkScales(); - this.addElements(); - }, + this.resetElements(); - linkScales: function() { - if (!this.getDataset().xAxisID) { - this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; - } + // Update the chart with the latest data. + this.update(); - if (!this.getDataset().yAxisID) { - this.getDataset().yAxisID = this.chart.options.scales.yAxes[0].id; - } }, - getDataset: function() { - return this.chart.data.datasets[this.index]; + calculateCircumference: function(dataset, value) { + if (dataset.total > 0) { + return (Math.PI * 2) * (value / dataset.total); + } else { + return 0; + } }, + resetElements: function() { + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - getScaleForId: function(scaleID) { - return this.chart.scales[scaleID]; + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + // So that calculateCircumference works + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + helpers.extend(slice, { + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, + innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + slice.pivot(); + }, this); + + }, this); }, + update: function(animationDuration) { - addElements: function() { + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; + this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - this.getDataset().metaData = this.getDataset().metaData || []; - this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({ - _chart: this.chart.chart, - _datasetIndex: this.index, - _points: this.getDataset().metaData, - }); + // Update the points + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.total = 0; + helpers.each(dataset.data, function(value) { + dataset.total += Math.abs(value); + }, this); + + + dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + + dataset.innerRadius = dataset.outerRadius - this.radiusLength; + + helpers.each(dataset.metaData, function(slice, index) { + + helpers.extend(slice, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + + // Desired view properties + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + circumference: this.calculateCircumference(dataset, dataset.data[index]), + outerRadius: dataset.outerRadius, + innerRadius: dataset.innerRadius, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + }, + }); + + if (index === 0) { + slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + } else { + slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; + } + + slice._model.endAngle = slice._model.startAngle + slice._model.circumference; + + + //Check to see if it's the last slice, if not get the next and update its start angle + if (index < dataset.data.length - 1) { + dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; + } + + slice.pivot(); + }, this); - helpers.each(this.getDataset().data, function(value, index) { - this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({ - _chart: this.chart.chart, - _datasetIndex: this.index, - _index: index, - }); }, this); - }, - reset: function() { - this.update(true); + this.render(animationDuration); }, + draw: function(easeDecimal) { + easeDecimal = easeDecimal || 1; + this.clear(); - update: function(reset) { + this.eachElement(function(slice) { + slice.transition(easeDecimal).draw(); + }, this); - var line = this.getDataset().metaDataset; - var points = this.getDataset().metaData; + this.tooltip.transition(easeDecimal).draw(); + }, + events: function(e) { - var yScale = this.getScaleForId(this.getDataset().yAxisID); - var xScale = this.getScaleForId(this.getDataset().xAxisID); - var scaleBase; + this.lastActive = this.lastActive || []; - if (yScale.min < 0 && yScale.max < 0) { - scaleBase = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - scaleBase = yScale.getPixelForValue(yScale.min); + // Find Active Elements + if (e.type == 'mouseout') { + this.active = []; } else { - scaleBase = yScale.getPixelForValue(0); + + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } } + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inLabelRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); + + Chart.types.Doughnut.extend({ + name: "Pie", + defaults: helpers.merge(defaultConfig, { + cutoutPercentage: 0 + }) + }); + +}).call(this); + +(function() { + + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + Chart.defaults.line = { + hover: { + mode: "label" + }, + + scales: { + xAxes: [{ + type: "category", + }], + yAxes: [{ + type: "linear", + }], + }, + }; + + + Chart.controllers.line = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; + + helpers.extend(Chart.controllers.line.prototype, { + + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, + + linkScales: function() { + if (!this.getDataset().xAxisID) { + this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; + } + + if (!this.getDataset().yAxisID) { + this.getDataset().yAxisID = this.chart.options.scales.yAxes[0].id; + } + }, + + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, + + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + + addElements: function() { + + this.getDataset().metaData = this.getDataset().metaData || []; + + this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _points: this.getDataset().metaData, + }); + + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + }, this); + }, + + reset: function() { + this.update(true); + }, + + update: function(reset) { + + var line = this.getDataset().metaDataset; + var points = this.getDataset().metaData; + + var yScale = this.getScaleForId(this.getDataset().yAxisID); + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + + // Update Line + helpers.extend(line, { + // Utility + _scale: yScale, + _datasetIndex: this.index, + // Data + _children: points, + // Model + _model: { + // Appearance + tension: line.custom && line.custom.tension ? line.custom.tension : (this.getDataset().tension || this.chart.options.elements.line.tension), + backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor), + borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth), + borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor), + fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill), + skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, + drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, + // Scale + scaleTop: yScale.top, + scaleBottom: yScale.bottom, + scaleZero: scaleBase, + }, + }); + line.pivot(); + + // Update Points + helpers.each(points, function(point, index) { + helpers.extend(point, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + + }); + }, this); + + // Update bezier control points + helpers.each(this.getDataset().metaData, function(point, index) { + var controlPoints = helpers.splineCurve( + helpers.previousItem(this.getDataset().metaData, index)._model, + point._model, + helpers.nextItem(this.getDataset().metaData, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = controlPoints.previous.x; + point._model.controlPointNextX = controlPoints.next.x; + + // Prevent the bezier going outside of the bounds of the graph + + // Cap puter bezier handles to the upper/lower scale bounds + if (controlPoints.next.y > this.chart.chartArea.bottom) { + point._model.controlPointNextY = this.chart.chartArea.bottom; + } else if (controlPoints.next.y < this.chart.chartArea.top) { + point._model.controlPointNextY = this.chart.chartArea.top; + } else { + point._model.controlPointNextY = controlPoints.next.y; + } + + // Cap inner bezier handles to the upper/lower scale bounds + if (controlPoints.previous.y > this.chart.chartArea.bottom) { + point._model.controlPointPreviousY = this.chart.chartArea.bottom; + } else if (controlPoints.previous.y < this.chart.chartArea.top) { + point._model.controlPointPreviousY = this.chart.chartArea.top; + } else { + point._model.controlPointPreviousY = controlPoints.previous.y; + } + + // Now pivot the point for animation + point.pivot(); + }, this); + + }, + + draw: function(ease) { + var easingDecimal = ease || 1; + + // Transition Point Locations + helpers.each(this.getDataset().metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + this.getDataset().metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(this.getDataset().metaData, function(point) { + point.draw(); + }); + }, + + setHoverStyle: function(point) { + // Point + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; + + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + }, + + removeHoverStyle: function(point) { + // TODO + } + + }); + + + +}).call(this); + +(function() { + "use strict"; + + return; + + var root = this, + Chart = root.Chart, + //Cache a local reference to Chart.helpers + helpers = Chart.helpers; + + var defaultConfig = { + + scale: { + type: "radialLinear", + lineArc: true, // so that lines are circular + }, + + //Boolean - Whether to animate the rotation of the chart + animateRotate: true, + }; + + + Chart.Type.extend({ + //Passing in a name registers this chart in the Chart namespace + name: "PolarArea", + //Providing a defaults will also register the deafults in the chart namespace + defaults: defaultConfig, + //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() { + + // Scale setup + var self = this; + var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); + this.scale = new ScaleClass({ + options: this.options.scale, + lineArc: true, + width: this.chart.width, + height: this.chart.height, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + valuesCount: this.data.length, + data: this.data + }); + + helpers.bindEvents(this, this.options.events, this.events); + + //Set up tooltip events on the chart + helpers.bindEvents(this, this.options.events, this.events); + + //Create a new bar for each piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + dataset.metaData = []; + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Arc({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _model: {} + })); + }, this); + }, this); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Fit the scale before we animate + this.updateScaleRange(); + this.scale.calculateRange(); + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // so that we animate nicely + this.resetElements(); + + // Update the chart with the latest data. + this.update(); + + }, + updateScaleRange: function() { + helpers.extend(this.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2 + }); + }, + resetElements: function() { + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: 0, + startAngle: Math.PI * -0.5, + endAngle: Math.PI * -0.5, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + + slice.pivot(); + }, this); + }, + update: function(animationDuration) { + + this.updateScaleRange(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + var circumference = 1 / this.data.datasets[0].data.length * 2; + + // Map new data to data points + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + + var value = this.data.datasets[0].data[index]; + + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + helpers.extend(slice, { + _index: index, + _model: { + x: this.chart.width / 2, + y: this.chart.height / 2, + innerRadius: 0, + outerRadius: this.scale.getDistanceFromCenterForValue(value), + startAngle: startAngle, + endAngle: endAngle, + + backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), + hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), + borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), + borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + }, + }); + slice.pivot(); + + console.log(slice); + + }, this); + + this.render(animationDuration); + }, + draw: function(ease) { + var easingDecimal = ease || 1; + + this.clear(); + + helpers.each(this.data.datasets[0].metaData, function(slice, index) { + slice.transition(easingDecimal).draw(); + }, this); + + this.scale.draw(); + + this.tooltip.transition(easingDecimal).draw(); + }, + events: function(e) { + + // If exiting chart + if (e.type == 'mouseout') { + return this; + } + + this.lastActive = this.lastActive || []; + + // Find Active Elements + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getSliceAtEvent(e); + case 'label': + return this.getSlicesAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + + + // Built in Tooltips + if (this.options.tooltips.enabled) { + + // The usual updates + this.tooltip.initialize(); + + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; + + helpers.extend(this.tooltip, { + _active: this.active, + }); + + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; + } + } + + + // Hover animations + this.tooltip.pivot(); + + if (!this.animating) { + var changed; + + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; + } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); + } + } + + // Remember Last Active + this.lastActive = this.active; + return this; + }, + getSliceAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + }, + /*getSlicesAtEvent: function(e) { + var elements = []; + + var location = helpers.getRelativePosition(e); + + this.eachElement(function(slice, index) { + if (slice.inLabelRange(location.x, location.y)) { + elements.push(slice); + } + }, this); + return elements; + },*/ + }); + +}).call(this); + +(function() { + "use strict"; + + return; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + + + Chart.Type.extend({ + name: "Radar", + defaults: { + + scale: { + type: "radialLinear", + }, + + elements: { + line: { + tension: 0, // no bezier in radar + } + }, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + + }, + + initialize: function() { + + // Events + helpers.bindEvents(this, this.options.events, this.events); + + // Create a new line and its points for each dataset and piece of data + helpers.each(this.data.datasets, function(dataset, datasetIndex) { + + dataset.metaDataset = new Chart.Line({ + _chart: this.chart, + _datasetIndex: datasetIndex, + _points: dataset.metaData, + _loop: true + }); + + dataset.metaData = []; + + helpers.each(dataset.data, function(dataPoint, index) { + dataset.metaData.push(new Chart.Point({ + _datasetIndex: datasetIndex, + _index: index, + _chart: this.chart, + _model: { + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, + }, + })); + + }, this); + }, this); + + // Build the scale. + this.buildScale(); + + // Create tooltip instance exclusively for this chart with some defaults. + this.tooltip = new Chart.Tooltip({ + _chart: this.chart, + _data: this.data, + _options: this.options, + }, this); + + // Need to fit scales before we reset elements. + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Reset so that we animation from the baseline + this.resetElements(); + + // Update that shiz + this.update(); + }, + nextPoint: function(collection, index) { + return collection[index + 1] || collection[0]; + }, + previousPoint: function(collection, index) { + return collection[index - 1] || collection[collection.length - 1]; + }, + resetElements: function() { + + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + helpers.extend(point, { + // Utility + _chart: this.chart, + _datasetIndex: datasetIndex, + _index: index, + _scale: this.scale, + + // Desired view properties + _model: { + x: this.scale.xCenter, + y: this.scale.yCenter, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + }, + }); + }, this); + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { + var controlPoints = helpers.splineCurve( + this.previousPoint(dataset, index)._model, + point._model, + this.nextPoint(dataset, index)._model, + point._model.tension + ); + + point._model.controlPointPreviousX = this.scale.xCenter; + point._model.controlPointPreviousY = this.scale.yCenter; + point._model.controlPointNextX = this.scale.xCenter; + point._model.controlPointNextY = this.scale.yCenter; + + // Now pivot the point for animation + point.pivot(); + }, this); + }, + update: function(animationDuration) { + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + + Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + + // Update the lines + this.eachDataset(function(dataset, datasetIndex) { + var scaleBase; + + if (this.scale.min < 0 && this.scale.max < 0) { + scaleBase = this.scale.getPointPositionForValue(0, this.scale.max); + } else if (this.scale.min > 0 && this.scale.max > 0) { + scaleBase = this.scale.getPointPositionForValue(0, this.scale.min); + } else { + scaleBase = this.scale.getPointPositionForValue(0, 0); + } + + helpers.extend(dataset.metaDataset, { + // Utility + _datasetIndex: datasetIndex, - // Update Line - helpers.extend(line, { - // Utility - _scale: yScale, - _datasetIndex: this.index, - // Data - _children: points, - // Model - _model: { - // Appearance - tension: line.custom && line.custom.tension ? line.custom.tension : (this.getDataset().tension || this.chart.options.elements.line.tension), - backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor), - borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth), - borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor), - fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill), - skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, - drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, - // Scale - scaleTop: yScale.top, - scaleBottom: yScale.bottom, - scaleZero: scaleBase, - }, + // Data + _children: dataset.metaData, + + // Model + _model: { + // Appearance + tension: dataset.tension || this.options.elements.line.tension, + backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, + borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, + borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, + drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, + + // Scale + scaleTop: this.scale.top, + scaleBottom: this.scale.bottom, + scaleZero: scaleBase, + }, + }); + + dataset.metaDataset.pivot(); }); - line.pivot(); - // Update Points - helpers.each(points, function(point, index) { + // Update the points + this.eachElement(function(point, index, dataset, datasetIndex) { + var pointPosition = this.scale.getPointPositionForValue(index, this.data.datasets[datasetIndex].data[index]); + helpers.extend(point, { // Utility - _chart: this.chart.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: this.index, + _chart: this.chart, + _datasetIndex: datasetIndex, _index: index, // Desired view properties _model: { - x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - y: yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: pointPosition.y, + // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: this.getDataset().data[index] === null, + tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), + skip: this.data.datasets[datasetIndex].data[index] === null, // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), }, - }); }, this); - // Update bezier control points - helpers.each(this.getDataset().metaData, function(point, index) { + + // Update control points for the bezier curve + this.eachElement(function(point, index, dataset, datasetIndex) { var controlPoints = helpers.splineCurve( - helpers.previousItem(this.getDataset().metaData, index)._model, + this.previousPoint(dataset, index)._model, point._model, - helpers.nextItem(this.getDataset().metaData, index)._model, + this.nextPoint(dataset, index)._model, point._model.tension ); @@ -2848,19 +3558,19 @@ // Prevent the bezier going outside of the bounds of the graph // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chart.chartArea.bottom) { - point._model.controlPointNextY = this.chart.chartArea.bottom; - } else if (controlPoints.next.y < this.chart.chartArea.top) { - point._model.controlPointNextY = this.chart.chartArea.top; + if (controlPoints.next.y > this.chartArea.bottom) { + point._model.controlPointNextY = this.chartArea.bottom; + } else if (controlPoints.next.y < this.chartArea.top) { + point._model.controlPointNextY = this.chartArea.top; } else { point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chart.chartArea.bottom) { - point._model.controlPointPreviousY = this.chart.chartArea.bottom; - } else if (controlPoints.previous.y < this.chart.chartArea.top) { - point._model.controlPointPreviousY = this.chart.chartArea.top; + if (controlPoints.previous.y > this.chartArea.bottom) { + point._model.controlPointPreviousY = this.chartArea.bottom; + } else if (controlPoints.previous.y < this.chartArea.top) { + point._model.controlPointPreviousY = this.chartArea.top; } else { point._model.controlPointPreviousY = controlPoints.previous.y; } @@ -2869,206 +3579,246 @@ point.pivot(); }, this); + this.render(animationDuration); }, + buildScale: function() { + var self = this; + + var ScaleConstructor = Chart.scaleService.getScaleConstructor(this.options.scale.type); + this.scale = new ScaleConstructor({ + options: this.options.scale, + height: this.chart.height, + width: this.chart.width, + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2, + ctx: this.chart.ctx, + labels: this.data.labels, + valuesCount: this.data.datasets[0].data.length, + data: this.data, + }); + this.scale.setScaleSize(); + this.scale.calculateRange(); + this.scale.generateTicks(); + this.scale.buildYLabels(); + }, draw: function(ease) { var easingDecimal = ease || 1; + this.clear(); - // Transition Point Locations - helpers.each(this.getDataset().metaData, function(point, index) { - point.transition(easingDecimal); - }, this); + // Draw all the scales + this.scale.draw(this.chartArea); - // Transition and Draw the line - this.getDataset().metaDataset.transition(easingDecimal).draw(); + // reverse for-loop for proper stacking + for (var i = this.data.datasets.length - 1; i >= 0; i--) { - // Draw the points - helpers.each(this.getDataset().metaData, function(point) { - point.draw(); - }); + var dataset = this.data.datasets[i]; + + // Transition Point Locations + helpers.each(dataset.metaData, function(point, index) { + point.transition(easingDecimal); + }, this); + + // Transition and Draw the line + dataset.metaDataset.transition(easingDecimal).draw(); + + // Draw the points + helpers.each(dataset.metaData, function(point) { + point.draw(); + }); + } + + // Finally draw the tooltip + this.tooltip.transition(easingDecimal).draw(); }, + events: function(e) { + + this.lastActive = this.lastActive || []; + + // Find Active Elements + // If exiting chart + if (e.type == 'mouseout') { + this.active = []; + } else { + this.active = function() { + switch (this.options.hover.mode) { + case 'single': + return this.getElementAtEvent(e); + case 'label': + return this.getElementsAtEvent(e); + case 'dataset': + return this.getDatasetAtEvent(e); + default: + return e; + } + }.call(this); + } + + // On Hover hook + if (this.options.hover.onHover) { + this.options.hover.onHover.call(this, this.active); + } + + if (e.type == 'mouseup' || e.type == 'click') { + if (this.options.onClick) { + this.options.onClick.call(this, e, this.active); + } + } + + var dataset; + var index; + // Remove styling for last active (even if it may still be active) + if (this.lastActive.length) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; + index = this.lastActive[0]._index; + this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + break; + case 'label': + for (var i = 0; i < this.lastActive.length; i++) { + dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; + index = this.lastActive[i]._index; + this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + // Built in hover styling + if (this.active.length && this.options.hover.mode) { + switch (this.options.hover.mode) { + case 'single': + dataset = this.data.datasets[this.active[0]._datasetIndex]; + index = this.active[0]._index; + this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); + this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); + break; + case 'label': + for (var i = 0; i < this.active.length; i++) { + dataset = this.data.datasets[this.active[i]._datasetIndex]; + index = this.active[i]._index; + this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); + this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); + } + break; + case 'dataset': + break; + default: + // Don't change anything + } + } + // Built in Tooltips + if (this.options.tooltips.enabled) { + // The usual updates + this.tooltip.initialize(); - // eachLine: function eachLine(callback) { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // if (dataset.metaDataset && dataset.metaDataset instanceof Chart.Line) { - // callback.call(this, dataset, datasetIndex); - // } - // }, this); - // }, - - // addPoint: function addPoint(dataset, datasetIndex, index) { - // if (dataset) { - // dataset.metaData = dataset.metaData || new Array(this.chart.data.datasets[datasetIndex].data.length); - - // if (index < dataset.metaData.length) { - // dataset.metaData[index] = new Chart.Point({ - // _datasetIndex: datasetIndex, - // _index: index, - // _chart: this.chart.chart, - // _model: { - // x: 0, - // y: 0, - // }, - // }); - // } - // } - // }, - - - - // resetElements: function resetElements() { - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.resetDatasetPoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (lines) - // this.resetDatasetRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - // resetDatasetPoints: function resetDatasetPoints(dataset, datasetIndex) { - // helpers.each(dataset.metaData, function(point, index) { - // var xScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].xAxisID); - // var yScale = this.getScaleForId(this.chart.data.datasets[datasetIndex].yAxisID); - - // var yScalePoint; - - // if (yScale.min < 0 && yScale.max < 0) { - // // all less than 0. use the top - // yScalePoint = yScale.getPixelForValue(yScale.max); - // } else if (yScale.min > 0 && yScale.max > 0) { - // yScalePoint = yScale.getPixelForValue(yScale.min); - // } else { - // yScalePoint = yScale.getPixelForValue(0); - // } - - // helpers.extend(point, { - // // Utility - // _chart: this.chart.chart, //WTF - // _xScale: xScale, - // _yScale: yScale, - // _datasetIndex: datasetIndex, - // _index: index, - - // // Desired view properties - // _model: { - // x: xScale.getPointPixelForValue(this.chart.data.datasets[datasetIndex].data[index], index, datasetIndex), - // y: yScalePoint, - // }, - // }); - - // this.updatePointElementAppearance(point, datasetIndex, index); - // }, this); - - // this.updateBezierControlPoints(dataset); - // }, - - // resetDatasetRectangles: function resetDatasetRectangles(dataset, datasetIndex) { - - // }, - - // resetElementAppearance: function(element, datasetIndex, index) { - // if (element instanceof Chart.Point) { - // this.updatePointElementAppearance(element, datasetIndex, index); - // } else if (element instanceof Chart.Rectangle) { - // this.updateRectangleElementAppearance(element, datasetIndex, index); - // } - // }, - - // updateElements: function updateElements() { - // // Update the lines - // this.updateLines(); - - // helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { - // // All elements must be the same type for the given dataset so we are fine to check just the first one - // if (dataset.metaData[0] instanceof Chart.Point) { - // // Have points. Update all of them - // this.updatePoints(dataset, datasetIndex); - // } else if (dataset.metaData[0] instanceof Chart.Rectangle) { - // // Have rectangles (lines) - // this.updateRectangles(dataset, datasetIndex); - // } - // }, this); - // }, - - - // setElementHoverStyle: function setElementHoverStyle(element) { - // if (element instanceof Chart.Point) { - // this.setPointHoverStyle(element); - // } else if (element instanceof Chart.Rectangle) { - // this.setRectangleHoverStyle(element); - // } - // }, - - // setPointHoverStyle: function setPointHoverStyle(point) { - // var dataset = this.chart.data.datasets[point._datasetIndex]; - // var index = point._index; - - // point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); - // point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); - // }, - - // setHoverStyle: function(rectangle) { - // var dataset = this.chart.data.datasets[rectangle._datasetIndex]; - // var index = rectangle._index; - - // rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - // rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); - // }, + // Active + if (this.active.length) { + this.tooltip._model.opacity = 1; - getElementsAtEvent: function(e) { - var elementsArray = [], - eventPosition = helpers.getRelativePosition(e), - datasetIterator = function(dataset) { - elementsArray.push(dataset.metaData[elementIndex]); - }, - elementIndex; + helpers.extend(this.tooltip, { + _active: this.active, + }); - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inGroupRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.chart.data.datasets, datasetIterator); - } + this.tooltip.update(); + } else { + // Inactive + this.tooltip._model.opacity = 0; } } - return elementsArray.length ? elementsArray : []; - }, + // Hover animations + this.tooltip.pivot(); - // // Get the single element that was clicked on - // // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawn - getElementAtEvent: function(e) { - var element = []; - var eventPosition = helpers.getRelativePosition(e); + if (!this.animating) { + var changed; - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; ++datasetIndex) { - for (var elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; ++elementIndex) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); - return element; + helpers.each(this.active, function(element, index) { + if (element !== this.lastActive[index]) { + changed = true; } + }, this); + + // If entering, leaving, or changing elements, animate the change via pivot + if ((!this.lastActive.length && this.active.length) || + (this.lastActive.length && !this.active.length) || + (this.lastActive.length && this.active.length && changed)) { + + this.stop(); + this.render(this.options.hover.animationDuration); } } - return []; + // Remember Last Active + this.lastActive = this.active; + return this; }, }); +}).call(this); + +(function() { + "use strict"; + + return; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + hover: { + mode: 'single', + }, + + scales: { + xAxes: [{ + type: "linear", // scatter should not use a category axis + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + }], + yAxes: [{ + type: "linear", + position: "left", + id: "y-axis-1", + }], + }, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", + + tooltips: { + template: "(<%= value.x %>, <%= value.y %>)", + multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", + }, + }; + Chart.types.Line.extend({ + name: "Scatter", + defaults: defaultConfig, + }); }).call(this); (function() { @@ -4369,7 +5119,7 @@ }; Chart.Arc = Chart.Element.extend({ - inGroupRange: function(mouseX) { + inLabelRange: function(mouseX) { var vm = this._view; if (vm) { @@ -4653,7 +5403,7 @@ var hoverRange = vm.hitRadius + vm.radius; return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); }, - inGroupRange: function(mouseX) { + inLabelRange: function(mouseX) { var vm = this._view; if (vm) { @@ -4764,7 +5514,7 @@ return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); } }, - inGroupRange: function(mouseX) { + inLabelRange: function(mouseX) { var vm = this._view; return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); }, @@ -4786,82 +5536,6 @@ -}).call(this); - -(function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - - Chart.defaults.bar = { - hover: { - mode: "label" - }, - - scales: { - xAxes: [{ - type: "category", - categorySpacing: 10, - spacing: 1, - - // grid line settings - gridLines: { - offsetGridLines: true, - }, - }], - yAxes: [{ - type: "linear", - }], - }, - }; - - // Chart.Type.extend({ - // name: "Bar", - // defaults: defaultConfig, - // initialize: function() { - // this.elementController = new Chart.RectangularElementController(this); - // this.canvasController = new Chart.RectangularCanvasController(this, this.elementController); - - // //Create a new bar for each piece of data - // helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // helpers.each(dataset.data, function(dataPoint, index) { - // this.elementController.addRectangle(dataset, datasetIndex, index); - // }, this); - - // // The bar chart only supports a single x axis because the x axis is always a category axis - // dataset.xAxisID = this.options.scales.xAxes[0].id; - - // if (!dataset.yAxisID) { - // dataset.yAxisID = this.options.scales.yAxes[0].id; - // } - // }, this); - - // this.canvasController.initialize(); - // }, - // draw: function(ease) { - - // var easingDecimal = ease || 1; - // this.clear(); - - // // Draw all the scales - // helpers.each(this.scales, function(scale) { - // scale.draw(this.chartArea); - // }, this); - - // //Draw all the bars for each dataset - // this.eachElement(function(bar, index, datasetIndex) { - // bar.transition(easingDecimal).draw(); - // }, this); - - // // Finally draw the tooltip - // this.tooltip.transition(easingDecimal).draw(); - // }, - // }); - - }).call(this); !function e(r,t,n){function a(i,u){if(!t[i]){if(!r[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(s)return s(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var o=t[i]={exports:{}};r[i][0].call(o.exports,function(e){var t=r[i][1][e];return a(t?t:e)},o,o.exports,e,r,t,n)}return t[i].exports}for(var s="function"==typeof require&&require,i=0;i=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*r[0]+.7152*r[1]+.0722*r[2]},contrast:function(e){var r=this.luminosity(),t=e.luminosity();return r>t?(r+.05)/(t+.05):(t+.05)/(r+.05)},level:function(e){var r=this.contrast(e);return r>=7.1?"AAA":r>=4.5?"AA":""},dark:function(){var e=this.values.rgb,r=(299*e[0]+587*e[1]+114*e[2])/1e3;return 128>r},light:function(){return!this.dark()},negate:function(){for(var e=[],r=0;3>r;r++)e[r]=255-this.values.rgb[r];return this.setValues("rgb",e),this},lighten:function(e){return this.values.hsl[2]+=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},darken:function(e){return this.values.hsl[2]-=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},saturate:function(e){return this.values.hsl[1]+=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},desaturate:function(e){return this.values.hsl[1]-=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},whiten:function(e){return this.values.hwb[1]+=this.values.hwb[1]*e,this.setValues("hwb",this.values.hwb),this},blacken:function(e){return this.values.hwb[2]+=this.values.hwb[2]*e,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var e=this.values.rgb,r=.3*e[0]+.59*e[1]+.11*e[2];return this.setValues("rgb",[r,r,r]),this},clearer:function(e){return this.setValues("alpha",this.values.alpha-this.values.alpha*e),this},opaquer:function(e){return this.setValues("alpha",this.values.alpha+this.values.alpha*e),this},rotate:function(e){var r=this.values.hsl[0];return r=(r+e)%360,r=0>r?360+r:r,this.values.hsl[0]=r,this.setValues("hsl",this.values.hsl),this},mix:function(e,r){r=1-(null==r?.5:r);for(var t=2*r-1,n=this.alpha()-e.alpha(),a=((t*n==-1?t:(t+n)/(1+t*n))+1)/2,s=1-a,i=this.rgbArray(),u=e.rgbArray(),l=0;lr&&(r+=360),n=(u+l)/2,t=l==u?0:.5>=n?h/(l+u):h/(2-l-u),[r,100*t,100*n]}function s(e){var r,t,n,a=e[0],s=e[1],i=e[2],u=Math.min(a,s,i),l=Math.max(a,s,i),h=l-u;return t=0==l?0:h/l*1e3/10,l==u?r=0:a==l?r=(s-i)/h:s==l?r=2+(i-a)/h:i==l&&(r=4+(a-s)/h),r=Math.min(60*r,360),0>r&&(r+=360),n=l/255*1e3/10,[r,t,n]}function i(e){var r=e[0],t=e[1],n=e[2],s=a(e)[0],i=1/255*Math.min(r,Math.min(t,n)),n=1-1/255*Math.max(r,Math.max(t,n));return[s,100*i,100*n]}function u(e){var r,t,n,a,s=e[0]/255,i=e[1]/255,u=e[2]/255;return a=Math.min(1-s,1-i,1-u),r=(1-s-a)/(1-a)||0,t=(1-i-a)/(1-a)||0,n=(1-u-a)/(1-a)||0,[100*r,100*t,100*n,100*a]}function l(e){return X[JSON.stringify(e)]}function h(e){var r=e[0]/255,t=e[1]/255,n=e[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*r+.3576*t+.1805*n,s=.2126*r+.7152*t+.0722*n,i=.0193*r+.1192*t+.9505*n;return[100*a,100*s,100*i]}function o(e){var r,t,n,a=h(e),s=a[0],i=a[1],u=a[2];return s/=95.047,i/=100,u/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,r=116*i-16,t=500*(s-i),n=200*(i-u),[r,t,n]}function c(e){return J(o(e))}function v(e){var r,t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100;if(0==u)return s=255*l,[s,s,s];t=.5>l?l*(1+u):l+u-l*u,r=2*l-t,a=[0,0,0];for(var h=0;3>h;h++)n=i+1/3*-(h-1),0>n&&n++,n>1&&n--,s=1>6*n?r+6*(t-r)*n:1>2*n?t:2>3*n?r+(t-r)*(2/3-n)*6:r,a[h]=255*s;return a}function f(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return s*=2,a*=1>=s?s:2-s,t=(s+a)/2,r=2*a/(s+a),[n,100*r,100*t]}function d(e){return i(v(e))}function p(e){return u(v(e))}function m(e){return l(v(e))}function y(e){var r=e[0]/60,t=e[1]/100,n=e[2]/100,a=Math.floor(r)%6,s=r-Math.floor(r),i=255*n*(1-t),u=255*n*(1-t*s),l=255*n*(1-t*(1-s)),n=255*n;switch(a){case 0:return[n,l,i];case 1:return[u,n,i];case 2:return[i,n,l];case 3:return[i,u,n];case 4:return[l,i,n];case 5:return[n,i,u]}}function w(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return t=(2-a)*s,r=a*s,r/=1>=t?t:2-t,r=r||0,t/=2,[n,100*r,100*t]}function k(e){return i(y(e))}function M(e){return u(y(e))}function S(e){return l(y(e))}function x(e){var t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100,h=u+l;switch(h>1&&(u/=h,l/=h),t=Math.floor(6*i),n=1-l,a=6*i-t,0!=(1&t)&&(a=1-a),s=u+a*(n-u),t){default:case 6:case 0:r=n,g=s,b=u;break;case 1:r=s,g=n,b=u;break;case 2:r=u,g=n,b=s;break;case 3:r=u,g=s,b=n;break;case 4:r=s,g=u,b=n;break;case 5:r=n,g=u,b=s}return[255*r,255*g,255*b]}function V(e){return a(x(e))}function q(e){return s(x(e))}function A(e){return u(x(e))}function C(e){return l(x(e))}function F(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100,u=e[3]/100;return r=1-Math.min(1,a*(1-u)+u),t=1-Math.min(1,s*(1-u)+u),n=1-Math.min(1,i*(1-u)+u),[255*r,255*t,255*n]}function N(e){return a(F(e))}function z(e){return s(F(e))}function I(e){return i(F(e))}function O(e){return l(F(e))}function E(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100;return r=3.2406*a+-1.5372*s+i*-.4986,t=a*-.9689+1.8758*s+.0415*i,n=.0557*a+s*-.204+1.057*i,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=12.92*r,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:t=12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,r=Math.min(Math.max(0,r),1),t=Math.min(Math.max(0,t),1),n=Math.min(Math.max(0,n),1),[255*r,255*t,255*n]}function H(e){var r,t,n,a=e[0],s=e[1],i=e[2];return a/=95.047,s/=100,i/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,r=116*s-16,t=500*(a-s),n=200*(s-i),[r,t,n]}function U(e){return J(H(e))}function j(e){var r,t,n,a,s=e[0],i=e[1],u=e[2];return 8>=s?(t=100*s/903.3,a=7.787*(t/100)+16/116):(t=100*Math.pow((s+16)/116,3),a=Math.pow(t/100,1/3)),r=.008856>=r/95.047?r=95.047*(i/500+a-16/116)/7.787:95.047*Math.pow(i/500+a,3),n=.008859>=n/108.883?n=108.883*(a-u/200-16/116)/7.787:108.883*Math.pow(a-u/200,3),[r,t,n]}function J(e){var r,t,n,a=e[0],s=e[1],i=e[2];return r=Math.atan2(i,s),t=360*r/2/Math.PI,0>t&&(t+=360),n=Math.sqrt(s*s+i*i),[a,n,t]}function R(e){return E(j(e))}function $(e){var r,t,n,a=e[0],s=e[1],i=e[2];return n=i/360*2*Math.PI,r=s*Math.cos(n),t=s*Math.sin(n),[a,r,t]}function D(e){return j($(e))}function P(e){return R($(e))}function _(e){return W[e]}function L(e){return a(_(e))}function T(e){return s(_(e))}function B(e){return i(_(e))}function G(e){return u(_(e))}function K(e){return o(_(e))}function Q(e){return h(_(e))}t.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:i,rgb2cmyk:u,rgb2keyword:l,rgb2xyz:h,rgb2lab:o,rgb2lch:c,hsl2rgb:v,hsl2hsv:f,hsl2hwb:d,hsl2cmyk:p,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:k,hsv2cmyk:M,hsv2keyword:S,hwb2rgb:x,hwb2hsl:V,hwb2hsv:q,hwb2cmyk:A,hwb2keyword:C,cmyk2rgb:F,cmyk2hsl:N,cmyk2hsv:z,cmyk2hwb:I,cmyk2keyword:O,keyword2rgb:_,keyword2hsl:L,keyword2hsv:T,keyword2hwb:B,keyword2cmyk:G,keyword2lab:K,keyword2xyz:Q,xyz2rgb:E,xyz2lab:H,xyz2lch:U,lab2xyz:j,lab2rgb:R,lab2lch:J,lch2lab:$,lch2xyz:D,lch2rgb:P};var W={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},X={};for(var Y in W)X[JSON.stringify(W[Y])]=Y},{}],3:[function(e,r,t){var n=e("./conversions"),a=function(){return new h};for(var s in n){a[s+"Raw"]=function(e){return function(r){return"number"==typeof r&&(r=Array.prototype.slice.call(arguments)),n[e](r)}}(s);var i=/(\w+)2(\w+)/.exec(s),u=i[1],l=i[2];a[u]=a[u]||{},a[u][l]=a[s]=function(e){return function(r){"number"==typeof r&&(r=Array.prototype.slice.call(arguments));var t=n[e](r);if("string"==typeof t||void 0===t)return t;for(var a=0;ar||e[3]&&e[3]<1?c(e,r):"rgb("+e[0]+", "+e[1]+", "+e[2]+")"}function c(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+r+")"}function g(e,r){if(1>r||e[3]&&e[3]<1)return v(e,r);var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgb("+t+"%, "+n+"%, "+a+"%)"}function v(e,r){var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgba("+t+"%, "+n+"%, "+a+"%, "+(r||e[3]||1)+")"}function f(e,r){return 1>r||e[3]&&e[3]<1?d(e,r):"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)"}function d(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+r+")"}function b(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+(void 0!==r&&1!==r?", "+r:"")+")"}function p(e){return k[e.slice(0,3)]}function m(e,r,t){return Math.min(Math.max(r,e),t)}function y(e){var r=e.toString(16).toUpperCase();return r.length<2?"0"+r:r}var w=e("color-name");r.exports={getRgba:n,getHsla:a,getRgb:i,getHsl:u,getHwb:s,getAlpha:l,hexString:h,rgbString:o,rgbaString:c,percentString:g,percentaString:v,hslString:f,hslaString:d,hwbString:b,keyword:p};var k={};for(var M in w)k[w[M]]=M},{"color-name":5}],5:[function(e,r,t){r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/Chart.min.js b/Chart.min.js index 858da0d5644..40b369014f2 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,8 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},n=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=n,t.canvas.height=s,n=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=n[a].length||!n[a][i].type?n[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==n[a][i].type?n[a][i]=e.configMerge(n[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):n[a][i]=e.configMerge(n[a][i],t)}):(n[a]=[],e.each(t,function(t){n[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):n.hasOwnProperty(a)&&"object"==typeof n[a]&&null!==n[a]&&"object"==typeof t?n[a]=e.configMerge(n[a],t):n[a]=t)}),n},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var n=t[a];if(e(n))return n}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&n(i.prototype,t),i.__super__=e.prototype,i}),o=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,n=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:n}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=a*n/(n+s),r=a*s/(n+s);return{previous:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,n){var s=2,o=Math.floor(e/(1.5*i)),r=s>=o,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var f=Math.abs(u-d),g=c(f),p=Math.ceil(u/(1*Math.pow(10,g)))*Math.pow(10,g),v=a?0:Math.floor(d/(1*Math.pow(10,g)))*Math.pow(10,g),m=p-v,b=Math.pow(10,g),x=Math.round(m/b);(x>o||o>2*x)&&!r;)if(x>o)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(n&&g>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=s,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},e.niceNum=function(t,i){var a,n=Math.floor(e.log10(t)),s=t/Math.pow(10,n);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,n)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,n){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+n*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),f=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),g=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,n,s){var o=0,r=d[i]||d.linear,h=function(){o++;var i=o/e,l=r(i);t.call(s,l,i,o),a.call(s,l,i),e>o?s.animationFrame=f(h):n.apply(s)};f(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,n=t.currentTarget||t.srcElement,s=n.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),p=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=o},v=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){p(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-left"))+parseInt(v(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-bottom"))+parseInt(v(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var n=0;return i(a,function(e){var i=t.measureText(e).width;n=i>n?i:n}),n},e.drawRoundedRectangle=function(t,e,i,a,n,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+n-s),t.quadraticCurveTo(e+a,i+n,e+a-s,i+n),t.lineTo(e+s,i+n),t.quadraticCurveTo(e,i+n,e,i+n-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var n=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=n.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var o=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-o)*t+o}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var n=0;n1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var n=Date.now(),s=n-t-this.frameDuration,o=s/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildScales(),this.buildControllers(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){this.scales={},e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){this.eachDataset(function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))})},resetElements:function(){this.eachDataset(function(t,e){t.controller.reset()})},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),this.eachDataset(function(t,e){t.controller.update()}),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],n=i.currentStep/i.numSteps,s=a(n);t.draw(s,n,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},eachValue:function(t){e.each(this.data.datasets,function(i,a){e.each(i.data,t,this,a)},this)},eachElement:function(t){e.each(this.data.datasets,function(i,a){e.each(i.metaData,t,this,i.metaData,a)},this)},eachDataset:function(t){e.each(this.data.datasets,t,this)},nextElement:function(t,e,i){return this.loop?dataset[e+1]||dataset[0]:t[e+1]||t[e]},previousElement:function(t,e,i){return this.loop?dataset[e-1]||dataset[dataset.length-1]:t[e-1]||t[e]},getElementAtEvent:function(t){for(var i=[],a=e.getRelativePosition(t),n=0;n30?5:2,s=a>30?5:2;if(t){var o=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*n,u-=2*s;var d=(e-c)/(o.length+r.length),f=(a-u)/(h.length+l.length),g=[],p=function(t){var e=t.fit(d,u);g.push({horizontal:!1,minSize:e,scale:t})},v=function(t){var e=t.fit(c,f);g.push({horizontal:!0,minSize:e,scale:t})};i.each(o,p),i.each(r,p),i.each(h,v),i.each(l,v);var m=a-2*s,b=e-2*n;i.each(g,function(t){t.horizontal?m-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(g,function(e){return e.scale===t});e&&t.fit(e.minSize.width,m)},y=function(t){var e=i.findNextWhere(g,function(e){return e.scale===t}),a={left:w,right:k,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=n,k=n,_=s,C=s;i.each(o,x),i.each(r,x),i.each(o,function(t){w+=t.width}),i.each(r,function(t){k+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){C+=t.height}),i.each(o,function(t){var e=i.findNextWhere(g,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:C};e&&t.fit(e.minSize.width,m,a)}),i.each(r,function(t){var e=i.findNextWhere(g,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:C};e&&t.fit(e.minSize.width,m,a)});var S=n,P=s,M=function(t){t.left=S,t.right=S+t.width,t.top=_,t.bottom=_+m,S=t.right},A=function(t){t.left=w,t.right=w+b,t.top=P,t.bottom=P+t.height,P=t.bottom};i.each(o,M),i.each(h,A),S+=b,P+=m,i.each(r,M),i.each(l,A),t.chartArea={left:w,top:_,right:w+b,bottom:_+m}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,n,s=[],o=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,n=i.indexOf(a,this._active[0]),-1===n);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[n]&&e[n].hasValue()&&c.push(e[n])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),o.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,n);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:o,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,n=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,o=s+e.caretHeight+a;e.x+n/2>this._chart.width?e.xAlign="left":e.x-n/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-n/2,h=e.y-o;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-n+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,n,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+n/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,n){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(n+1)),t.fillStyle=i.color(e.legendColors[n].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(n+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[n].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(n+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(n,s){var o;o=a.min<0&&a.max<0?a.getPixelForValue(a.max):a.min>0&&a.max>0?a.getPixelForValue(a.min):a.getPixelForValue(0),i.extend(n,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?o:a.getPixelForValue(this.getDataset().data[s]),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:n.custom&&n.custom.backgroundColor?n.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:n.custom&&n.custom.borderColor?n.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:n.custom&&n.custom.borderWidth?n.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) -}}),n.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},getElementsAtEvent:function(t){for(var e,a=[],n=i.getRelativePosition(t),s=function(t){a.push(t.metaData[e])},o=0;o0&&s.max>0?s.getPixelForValue(s.min):s.getPixelForValue(0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:n,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(n,function(t,e){i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:s,_datasetIndex:this.index,_index:e,_model:{x:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:s.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},n=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var n=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=n/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),o=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(o+=s/2),this.left+Math.round(o)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),n=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?n+s/2:n+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var n,s,o=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=o/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),n=h*o,s=h*r,n+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=n+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var n={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),o=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(n.width=t,this.width=t):this.options.display&&(n.width=Math.min(o+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*o+1.5*this.options.labels.fontSize;n.height=Math.min(r,e)}else this.options.display&&(n.width=Math.min(o+6,t));return this.width=n.width,this.height=n.height,n},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,n="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(o,r){var h=this.getPixelForValue(o,r,null,!1),l=this.getPixelForValue(o,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(o,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",n,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},n=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var n=this.options.override.start+a*this.options.override.stepWidth;ticks.push(n)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var o=i.sign(this.min),r=i.sign(this.max);0>o&&0>r?this.max=0:o>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var n;this.options.labels.userCallback?n=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(n=i.template(this.options.labels.template,{value:t})),this.labels.push(n?n:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var n=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>n?e[a]+=n:t[a]+=n},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var n=0,s=0,o=0;i>o;++o)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]:n+=this.data.datasets[o].data[e];return 0>a?this.getPixelForValue(s+a):this.getPixelForValue(n+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var n=0;t>n;n++)this.data.datasets[n].yAxisID===this.id&&(i+=this.data.datasets[n].data[e]<0?this.data.datasets[n].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,n=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?n+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return 0>i?this.getPixelForValue(n+i):this.getPixelForValue(a+i)}for(var o=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var n="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(o,r){var h=this.getPixelForValue(o);0===o||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,n),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var o;"top"==this.options.position?(o=this.bottom-10,this.ctx.textBaseline="bottom"):(o=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,o)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(n,s){var o=this.getPixelForValue(n);0===n||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),o+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,o),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,o),this.ctx.lineTo(t.right,o)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",n,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!1,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},n=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var n=i.sign(this.min),s=i.sign(this.max);0>n&&0>s?this.max=0:n>0&&s>0&&(this.min=0)}for(var o=i.niceNum(this.max-this.min,!1),r=i.niceNum(o/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var n;this.options.labels.userCallback?n=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(n=i.template(this.options.labels.template,{value:t})),this.yLabels.push(n?n:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,n,s,o,r,h,l,c,u,d,f=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),g=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;eg&&(g=t.x+n,s=e),t.x-ng&&(g=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var n=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-n;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var o=0;o=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var n=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],n.x,n.y)}}}}});e.scaleService.registerScaleType("radialLinear",n,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var n=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},a=this.width=n(t.canvas,"Width")||t.canvas.width,s=this.height=n(t.canvas,"Height")||t.canvas.height;return t.canvas.width=a,t.canvas.height=s,a=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var n=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var a;for(a=0;a=a[n].length||!a[n][i].type?a[n].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==a[n][i].type?a[n][i]=e.configMerge(a[n][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):a[n][i]=e.configMerge(a[n][i],t)}):(a[n]=[],e.each(t,function(t){a[n].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):a.hasOwnProperty(n)&&"object"==typeof a[n]&&null!==a[n]&&"object"==typeof t?a[n]=e.configMerge(a[n],t):a[n]=t)}),a},e.getValueAtIndexOrDefault=function(t,i,n){return t?e.isArray(t)&&i=0;n--){var a=t[n];if(e(a))return a}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},n=function(){this.constructor=i};return n.prototype=e.prototype,i.prototype=new n,i.extend=s,t&&a(i.prototype,t),i.__super__=e.prototype,i}),o=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,n=e.y-t.y,a=Math.sqrt(i*i+n*n),s=Math.atan2(n,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:a}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,n){var a=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=n*a/(a+s),r=n*s/(a+s);return{previous:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,n,a){var s=2,o=Math.floor(e/(1.5*i)),r=s>=o,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!n?d-=.5:u+=.5);for(var g=Math.abs(u-d),f=c(g),p=Math.ceil(u/(1*Math.pow(10,f)))*Math.pow(10,f),v=n?0:Math.floor(d/(1*Math.pow(10,f)))*Math.pow(10,f),m=p-v,b=Math.pow(10,f),x=Math.round(m/b);(x>o||o>2*x)&&!r;)if(x>o)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(a&&f>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=s,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},e.niceNum=function(t,i){var n,a=Math.floor(e.log10(t)),s=t/Math.pow(10,a);return n=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,n*Math.pow(10,a)},e.template=function(t,e){function i(t,e){var i=/\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('');"):n[t]=n[t];return e?i(e):i}if(t instanceof Function)return t(e);var n={};return i(t,e)}),d=(e.generateLabels=function(t,e,n,a){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:n+a*(i+1)})}),s},e.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 e=1.70158,i=0,n=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),nt?-.5*n*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):n*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),f=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,n,a,s){var o=0,r=d[i]||d.linear,h=function(){o++;var i=o/e,l=r(i);t.call(s,l,i,o),n.call(s,l,i),e>o?s.animationFrame=g(h):a.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,n=t.originalEvent||t,a=t.currentTarget||t.srcElement,s=a.getBoundingClientRect();return n.touches?(e=n.touches[0].clientX-s.left,i=n.touches[0].clientY-s.top):(e=n.clientX-s.left,i=n.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),p=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=o},v=(e.bindEvents=function(t,e,n){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){n.apply(t,arguments)},f(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){p(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-left"))+parseInt(v(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-bottom"))+parseInt(v(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,n=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=n+"px",e.canvas.height=n*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,n){t.font=e;var a=0;return i(n,function(e){var i=t.measureText(e).width;a=i>a?i:a}),a},e.drawRoundedRectangle=function(t,e,i,n,a,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+a-s),t.quadraticCurveTo(e+n,i+a,e+n-s,i+a),t.lineTo(e+s,i+a),t.quadraticCurveTo(e,i+a,e,i+a-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,n){if("_"!==n[0]&&this._model.hasOwnProperty(n))if(this._view[n])if(this._model[n]===this._view[n]);else if("string"==typeof i)try{var a=e.color(this._start[n]).mix(e.color(this._model[n]),t);this._view[n]=a.rgbString()}catch(s){this._view[n]=i}else if("number"==typeof i){var o=void 0!==this._start[n]?this._start[n]:0;this._view[n]=(this._model[n]-o)*t+o}else this._view[n]=i;else"number"==typeof i?this._view[n]=i*t:this._view[n]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,n){n||(t.animating=!0);for(var a=0;a1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var n=0;nthis.animations[n].animationObject.numSteps&&(this.animations[n].animationObject.currentStep=this.animations[n].animationObject.numSteps),this.animations[n].animationObject.render(this.animations[n].chartInstance,this.animations[n].animationObject),this.animations[n].animationObject.currentStep==this.animations[n].animationObject.numSteps&&(this.animations[n].chartInstance.animating=!1,this.animations.splice(n,1),n--);var a=Date.now(),s=a-t-this.frameDuration,o=s/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildScales(),this.buildControllers(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),n=this.options.maintainAspectRatio?i/this.chart.aspectRatio:getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=n,e.retinaScale(this.chart),this},buildScales:function(){this.scales={},e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var n=e.easingEffects[i.easing],a=i.currentStep/i.numSteps,s=n(a);t.draw(s,a,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t);return e.each(this.data.datasets,function(t,n){e.each(t.metaData,function(t,e){return this.chart.data.datasets[n].metaData[elementIndex].inRange(i.x,i.y)?(t.push(this.chart.data.datasets[n].metaData[elementIndex]),t):void 0},this)},this),[]},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),n=[];return e.each(this.data.datasets,function(t,a){e.each(t.metaData,function(t,e){t.inRange(i.x,i.y)&&n.push(t)},this)},this),n},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),n=[],a=0;a30?5:2,s=n>30?5:2;if(t){var o=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=n/2;c-=2*a,u-=2*s;var d=(e-c)/(o.length+r.length),g=(n-u)/(h.length+l.length),f=[],p=function(t){var e=t.fit(d,u);f.push({horizontal:!1,minSize:e,scale:t})},v=function(t){var e=t.fit(c,g);f.push({horizontal:!0,minSize:e,scale:t})};i.each(o,p),i.each(r,p),i.each(h,v),i.each(l,v);var m=n-2*s,b=e-2*a;i.each(f,function(t){t.horizontal?m-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t});e&&t.fit(e.minSize.width,m)},y=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),n={left:w,right:_,top:0,bottom:0};e&&t.fit(b,e.minSize.height,n)},w=a,_=a,k=s,C=s;i.each(o,x),i.each(r,x),i.each(o,function(t){w+=t.width}),i.each(r,function(t){_+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){k+=t.height}),i.each(l,function(t){C+=t.height}),i.each(o,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),n={left:0,right:0,top:k,bottom:C};e&&t.fit(e.minSize.width,m,n)}),i.each(r,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),n={left:0,right:0,top:k,bottom:C};e&&t.fit(e.minSize.width,m,n)});var S=a,P=s,A=function(t){t.left=S,t.right=S+t.width,t.top=k,t.bottom=k+m,S=t.right},M=function(t){t.left=w,t.right=w+b,t.top=P,t.bottom=P+t.height,P=t.bottom};i.each(o,A),i.each(h,M),S+=b,P+=m,i.each(r,A),i.each(l,M),t.chartArea={left:w,top:k,right:w+b,bottom:k+m}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var n,a,s=[],o=[],r=this._data.datasets.length-1;r>=0&&(n=this._data.datasets[r].metaData,a=i.indexOf(n,this._active[0]),-1===a);r--);var h=function(t){var e,n,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[a]&&e[a].hasValue()&&c.push(e[a])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),o.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),n=i.max(u),{x:h>this._chart.width/2?h:n,y:(l+r)/2}}.call(this,a);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:o,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var n=e.caretPadding||2,a=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,o=s+e.caretHeight+n;e.x+a/2>this._chart.width?e.xAlign="left":e.x-a/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-a/2,h=e.y-o;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-n),t.lineTo(e.x+e.caretHeight,e.y-(n+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(n+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+n+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+n),t.lineTo(e.x+e.caretHeight,e.y+n+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+n+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-a+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,a,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+a/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(n,a){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(n,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(a+1)),t.fillStyle=i.color(e.legendColors[a].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(a+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[a].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(a+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(a,s){var o;o=n.min<0&&n.max<0?n.getPixelForValue(n.max):n.min>0&&n.max>0?n.getPixelForValue(n.min):n.getPixelForValue(0),i.extend(a,{_chart:this.chart.chart,_xScale:e,_yScale:n,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?o:n.getPixelForValue(this.getDataset().data[s]),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth)}}),a.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index; +t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,n,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,n,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,n,t._model.borderWidth)},removeHoverStyle:function(t){}})}.call(this),function(){"use strict";return}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,n=this.getDataset().metaDataset,a=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),o=this.getScaleForId(this.getDataset().xAxisID);e=s.min<0&&s.max<0?s.getPixelForValue(s.max):s.min>0&&s.max>0?s.getPixelForValue(s.min):s.getPixelForValue(0),i.extend(n,{_scale:s,_datasetIndex:this.index,_children:a,_model:{tension:n.custom&&n.custom.tension?n.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:n.custom&&n.custom.backgroundColor?n.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:n.custom&&n.custom.borderWidth?n.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:n.custom&&n.custom.borderColor?n.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:n.custom&&n.custom.fill?n.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),n.pivot(),i.each(a,function(t,e){i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:s,_datasetIndex:this.index,_index:e,_model:{x:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:s.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var n=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=n.previous.x,t._model.controlPointNextX=n.next.x,n.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:n.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:n.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},a=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,n){if(this.isHorizontal()){var a=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=a/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),o=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&n&&(o+=s/2),this.left+Math.round(o)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,e,!0)-n/2,s=this.calculateBarWidth(t);return this.options.stacked?a+s/2:a+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var n=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=n;var a,s,o=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=o/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,n,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),a=h*o,s=h*r,a+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=a+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,n){this.calculateLabelRotation(e,n);var a={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),o=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(a.width=t,this.width=t):this.options.display&&(a.width=Math.min(o+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*o+1.5*this.options.labels.fontSize;a.height=Math.min(r,e)}else this.options.display&&(a.width=Math.min(o+6,t));return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var n="bottom"==this.options.position?this.top:this.bottom-10,a="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(o,r){var h=this.getPixelForValue(o,r,null,!1),l=this.getPixelForValue(o,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,n),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(o,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",a,n)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},a=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var n=0;n<=this.options.override.steps;++n){var a=this.options.override.start+n*this.options.override.stepWidth;ticks.push(a)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var o=i.sign(this.min),r=i.sign(this.max);0>o&&0>r?this.max=0:o>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,n){var a;this.options.labels.userCallback?a=this.options.labels.userCallback(t,e,n):this.options.labels.template&&(a=i.template(this.options.labels.template,{value:t})),this.labels.push(a?a:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(n){(this.isHorizontal()?n.xAxisID===this.id:n.yAxisID===this.id)&&i.each(n.data,function(i,n){var a=this.getRightValue(i);t[n]=t[n]||0,e[n]=e[n]||0,this.options.relativePoints?t[n]=100:0>a?e[n]+=a:t[n]+=a},this)},this);var n=t.concat(e);this.min=i.min(n),this.max=i.max(n)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var n=this.getRightValue(t);if(this.options.stacked){for(var a=0,s=0,o=0;i>o;++o)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]:a+=this.data.datasets[o].data[e];return 0>n?this.getPixelForValue(s+n):this.getPixelForValue(a+n)}return this.getPixelForValue(n)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var n=this.data.datasets[t].data[e];if(0>n)for(var a=0;t>a;a++)this.data.datasets[a].yAxisID===this.id&&(i+=this.data.datasets[a].data[e]<0?this.data.datasets[a].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var n=0,a=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?a+=this.data.datasets[s].data[e]||0:n+=this.data.datasets[s].data[e]||0;return 0>i?this.getPixelForValue(a+i):this.getPixelForValue(n+i)}for(var o=0,r=t;rr?n.width+=r:n.width=t}}return this.width=n.width,this.height=n.height,n},draw:function(t){if(this.options.display){var e,n;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,n=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var a="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(o,r){var h=this.getPixelForValue(o);0===o||!n&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var o;"top"==this.options.position?(o=this.bottom-10,this.ctx.textBaseline="bottom"):(o=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,o)},this)}}else{if(this.options.gridLines.show){e=!0,n=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(a,s){var o=this.getPixelForValue(a);0===a||!n&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),o+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,o),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,o),this.ctx.lineTo(t.right,o)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",a,n)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={display:!0,animate:!1,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var n=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(n=Math.max(2,n),this.options.beginAtZero){var a=i.sign(this.min),s=i.sign(this.max);0>a&&0>s?this.max=0:a>0&&s>0&&(this.min=0)}for(var o=i.niceNum(this.max-this.min,!1),r=i.niceNum(o/(n-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,n){var a;this.options.labels.userCallback?a=this.options.labels.userCallback(t,e,n):this.options.labels.template&&(a=i.template(this.options.labels.template,{value:t})),this.yLabels.push(a?a:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,n,a,s,o,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),f=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ef&&(f=t.x+a,s=e),t.x-af&&(f=t.x+n,s=e):e>this.valuesCount/2&&t.x-n0){var a=this.getDistanceFromCenterForValue(this.ticks[n]),s=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var o=0;o=0;e--){if(this.options.angleLines.show){var n=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(n.x,n.y),t.stroke(),t.closePath()}var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],a.x,a.y)}}}}});e.scaleService.registerScaleType("radialLinear",a,n)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -17,7 +17,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.Arc=e.Element.extend({inGroupRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?a.startAngle-2*Math.PI:a.startAngle,o=a.endAngle<-.5*Math.PI?a.endAngle+2*Math.PI:a.endAngle>1.5*Math.PI?a.endAngle-2*Math.PI:a.endAngle,r=n.angle>=s&&n.angle<=o,h=n.distance>=a.innerRadius&&n.distance<=a.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?n.startAngle-2*Math.PI:n.startAngle,o=n.endAngle<-.5*Math.PI?n.endAngle+2*Math.PI:n.endAngle>1.5*Math.PI?n.endAngle-2*Math.PI:n.endAngle,r=a.angle>=s&&a.angle<=o,h=a.distance>=n.innerRadius&&a.distance<=n.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -26,7 +26,7 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,n=this._children[0],s=this._children[this._children.length-1];i.each(this._children,function(e,n){var s=i.previousItem(this._children,n),o=i.nextItem(this._children,n);return 0===n?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(s._view.x,e._view.y),a.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,s._view.y),a.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!n._view.skip?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,n._view.controlPointPreviousX,n._view.controlPointPreviousY,n._view.x,n._view.y):a.lineTo(n._view.x,n._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,n){var s=i.previousItem(this._children,n),o=i.nextItem(this._children,n);return 0===n?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(s._view.x,e._view.y),void a.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,s._view.y),void a.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!n._view.skip&&(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,n._view.controlPointPreviousX,n._view.controlPointPreviousY,n._view.x,n._view.y):a.lineTo(n._view.x,n._view.y)),a.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,n=this._chart.ctx,a=this._children[0],s=this._children[this._children.length-1];i.each(this._children,function(e,a){var s=i.previousItem(this._children,a),o=i.nextItem(this._children,a);return 0===a?void n.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(n.lineTo(s._view.x,e._view.y),n.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(n.moveTo(e._view.x,s._view.y),n.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?n.moveTo(e._view.x,e._view.y):t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):n.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!a._view.skip?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,a._view.controlPointPreviousX,a._view.controlPointPreviousY,a._view.x,a._view.y):n.lineTo(a._view.x,a._view.y)),this._children.length>0&&t.fill&&(n.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),n.lineTo(this._children[0]._view.x,t.scaleZero),n.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,n.closePath(),n.fill()),n.lineWidth=t.borderWidth||e.defaults.global.defaultColor,n.strokeStyle=t.borderColor||e.defaults.global.defaultColor,n.beginPath(),i.each(this._children,function(e,a){var s=i.previousItem(this._children,a),o=i.nextItem(this._children,a);return 0===a?void n.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(n.moveTo(s._view.x,e._view.y),void n.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(n.moveTo(e._view.x,s._view.y),void n.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void n.moveTo(e._view.x,e._view.y):void(t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):n.lineTo(e._view.x,e._view.y))},this),this._loop&&!a._view.skip&&(t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,a._view.controlPointPreviousX,a._view.controlPointPreviousY,a._view.x,a._view.y):n.lineTo(a._view.x,a._view.y)),n.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -35,4 +35,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,n=e.x+i,s=e.base-(e.base-e.y),o=e.borderWidth/2;e.borderWidth&&(a+=o,n-=o,s+=o),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,s),t.lineTo(n,s),t.lineTo(n,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inGroupRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),n=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,s=1-n,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function n(t){var e,i,a,n=t[0],s=t[1],o=t[2],r=Math.min(n,s,o),h=Math.max(n,s,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:n==h?e=(s-o)/l:s==h?e=2+(o-n)/l:o==h&&(e=4+(n-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],i=t[1],n=t[2],s=a(t)[0],o=1/255*Math.min(e,Math.min(i,n)),n=1-1/255*Math.max(e,Math.max(i,n));return[s,100*o,100*n]}function o(t){var e,i,a,n,s=t[0]/255,o=t[1]/255,r=t[2]/255;return n=Math.min(1-s,1-o,1-r),e=(1-s-n)/(1-n)||0,i=(1-o-n)/(1-n)||0,a=(1-r-n)/(1-n)||0,[100*e,100*i,100*a,100*n]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var n=.4124*e+.3576*i+.1805*a,s=.2126*e+.7152*i+.0722*a,o=.0193*e+.1192*i+.9505*a;return[100*n,100*s,100*o]}function c(t){var e,i,a,n=l(t),s=n[0],o=n[1],r=n[2];return s/=95.047,o/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(s-o),a=200*(o-r),[e,i,a]}function u(t){return O(c(t))}function d(t){var e,i,a,n,s,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,n=[0,0,0];for(var l=0;3>l;l++)a=o+1/3*-(l-1),0>a&&a++,a>1&&a--,s=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,n[l]=255*s;return n}function f(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return s*=2,n*=1>=s?s:2-s,i=(s+n)/2,e=2*n/(s+n),[a,100*e,100*i]}function p(t){return s(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,n=Math.floor(e)%6,s=e-Math.floor(e),o=255*a*(1-i),r=255*a*(1-i*s),h=255*a*(1-i*(1-s)),a=255*a;switch(n){case 0:return[a,h,o];case 1:return[r,a,o];case 2:return[o,a,h];case 3:return[o,r,a];case 4:return[h,o,a];case 5:return[a,o,r]}}function y(t){var e,i,a=t[0],n=t[1]/100,s=t[2]/100;return i=(2-n)*s,e=n*s,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return s(x(t))}function k(t){return o(x(t))}function _(t){return h(x(t))}function C(t){var e,i,a,n,s=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*s),i=1-h,a=6*s-e,0!=(1&e)&&(a=1-a),n=o+a*(i-o),e){default:case 6:case 0:r=i,g=n,b=o;break;case 1:r=n,g=i,b=o;break;case 2:r=o,g=i,b=n;break;case 3:r=o,g=n,b=i;break;case 4:r=n,g=o,b=i;break;case 5:r=i,g=o,b=n}return[255*r,255*g,255*b]}function S(t){return a(C(t))}function P(t){return n(C(t))}function M(t){return o(C(t))}function A(t){return h(C(t))}function D(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,n*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),a=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*a]}function F(t){return a(D(t))}function I(t){return n(D(t))}function z(t){return s(D(t))}function R(t){return h(D(t))}function T(t){var e,i,a,n=t[0]/100,s=t[1]/100,o=t[2]/100;return e=3.2406*n+-1.5372*s+o*-.4986,i=n*-.9689+1.8758*s+.0415*o,a=.0557*n+s*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function L(t){var e,i,a,n=t[0],s=t[1],o=t[2];return n/=95.047,s/=100,o/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*s-16,i=500*(n-s),a=200*(s-o),[e,i,a]}function V(t){return O(L(t))}function W(t){var e,i,a,n,s=t[0],o=t[1],r=t[2];return 8>=s?(i=100*s/903.3,n=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),n=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+n-16/116)/7.787:95.047*Math.pow(o/500+n,3),a=.008859>=a/108.883?a=108.883*(n-r/200-16/116)/7.787:108.883*Math.pow(n-r/200,3),[e,i,a]}function O(t){var e,i,a,n=t[0],s=t[1],o=t[2];return e=Math.atan2(o,s),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(s*s+o*o),[n,a,i]}function E(t){return T(W(t))}function N(t){var e,i,a,n=t[0],s=t[1],o=t[2];return a=o/360*2*Math.PI,e=s*Math.cos(a),i=s*Math.sin(a),[n,e,i]}function H(t){return W(N(t))}function B(t){return E(N(t))}function q(t){return U[t]}function j(t){return a(q(t))}function Y(t){return n(q(t))}function X(t){return s(q(t))}function G(t){return o(q(t))}function Q(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:n,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:f,hsl2hwb:p,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:k,hsv2keyword:_,hwb2rgb:C,hwb2hsl:S,hwb2hsv:P,hwb2cmyk:M,hwb2keyword:A,cmyk2rgb:D,cmyk2hsl:F,cmyk2hsv:I,cmyk2hwb:z,cmyk2keyword:R,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:G,keyword2lab:Q,keyword2xyz:Z,xyz2rgb:T,xyz2lab:L,xyz2lch:V,lab2xyz:W,lab2rgb:E,lab2lch:O,lch2lab:N,lch2xyz:H,lch2rgb:B};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var J in U)$[JSON.stringify(U[J])]=J},{}],3:[function(t,e,i){var a=t("./conversions"),n=function(){return new l};for(var s in a){n[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),r=o[1],h=o[2];n[r]=n[r]||{},n[r][h]=n[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var n=0;ne||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return f(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+n+"%)"}function f(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:n,getRgb:o,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:f,hslString:g,hslaString:p,hwbString:v,keyword:m};var w={};for(var k in y)w[y[k]]=k},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,n=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,n=e.x-i,a=e.x+i,s=e.base-(e.base-e.y),o=e.borderWidth/2;e.borderWidth&&(n+=o,a-=o,s+=o),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(n,e.base),t.lineTo(n,s),t.lineTo(a,s),t.lineTo(a,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,n=this.alpha()-t.alpha(),a=((i*n==-1?i:(i+n)/(1+i*n))+1)/2,s=1-a,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),n=(r+h)/2,i=h==r?0:.5>=n?l/(h+r):l/(2-h-r),[e,100*i,100*n]}function a(t){var e,i,n,a=t[0],s=t[1],o=t[2],r=Math.min(a,s,o),h=Math.max(a,s,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:a==h?e=(s-o)/l:s==h?e=2+(o-a)/l:o==h&&(e=4+(a-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),n=h/255*1e3/10,[e,i,n]}function s(t){var e=t[0],i=t[1],a=t[2],s=n(t)[0],o=1/255*Math.min(e,Math.min(i,a)),a=1-1/255*Math.max(e,Math.max(i,a));return[s,100*o,100*a]}function o(t){var e,i,n,a,s=t[0]/255,o=t[1]/255,r=t[2]/255;return a=Math.min(1-s,1-o,1-r),e=(1-s-a)/(1-a)||0,i=(1-o-a)/(1-a)||0,n=(1-r-a)/(1-a)||0,[100*e,100*i,100*n,100*a]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*e+.3576*i+.1805*n,s=.2126*e+.7152*i+.0722*n,o=.0193*e+.1192*i+.9505*n;return[100*a,100*s,100*o]}function c(t){var e,i,n,a=l(t),s=a[0],o=a[1],r=a[2];return s/=95.047,o/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(s-o),n=200*(o-r),[e,i,n]}function u(t){return O(c(t))}function d(t){var e,i,n,a,s,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,a=[0,0,0];for(var l=0;3>l;l++)n=o+1/3*-(l-1),0>n&&n++,n>1&&n--,s=1>6*n?e+6*(i-e)*n:1>2*n?i:2>3*n?e+(i-e)*(2/3-n)*6:e,a[l]=255*s;return a}function f(t){var e,i,n=t[0],a=t[1]/100,s=t[2]/100;return s*=2,a*=1>=s?s:2-s,i=(s+a)/2,e=2*a/(s+a),[n,100*e,100*i]}function p(t){return s(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,n=t[2]/100,a=Math.floor(e)%6,s=e-Math.floor(e),o=255*n*(1-i),r=255*n*(1-i*s),h=255*n*(1-i*(1-s)),n=255*n;switch(a){case 0:return[n,h,o];case 1:return[r,n,o];case 2:return[o,n,h];case 3:return[o,r,n];case 4:return[h,o,n];case 5:return[n,o,r]}}function y(t){var e,i,n=t[0],a=t[1]/100,s=t[2]/100;return i=(2-a)*s,e=a*s,e/=1>=i?i:2-i,e=e||0,i/=2,[n,100*e,100*i]}function w(t){return s(x(t))}function _(t){return o(x(t))}function k(t){return h(x(t))}function C(t){var e,i,n,a,s=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*s),i=1-h,n=6*s-e,0!=(1&e)&&(n=1-n),a=o+n*(i-o),e){default:case 6:case 0:r=i,g=a,b=o;break;case 1:r=a,g=i,b=o;break;case 2:r=o,g=i,b=a;break;case 3:r=o,g=a,b=i;break;case 4:r=a,g=o,b=i;break;case 5:r=i,g=o,b=a}return[255*r,255*g,255*b]}function S(t){return n(C(t))}function P(t){return a(C(t))}function A(t){return o(C(t))}function M(t){return h(C(t))}function D(t){var e,i,n,a=t[0]/100,s=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,a*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),n=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*n]}function I(t){return n(D(t))}function F(t){return a(D(t))}function z(t){return s(D(t))}function L(t){return h(D(t))}function T(t){var e,i,n,a=t[0]/100,s=t[1]/100,o=t[2]/100;return e=3.2406*a+-1.5372*s+o*-.4986,i=a*-.9689+1.8758*s+.0415*o,n=.0557*a+s*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),n=Math.min(Math.max(0,n),1),[255*e,255*i,255*n]}function R(t){var e,i,n,a=t[0],s=t[1],o=t[2];return a/=95.047,s/=100,o/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*s-16,i=500*(a-s),n=200*(s-o),[e,i,n]}function W(t){return O(R(t))}function V(t){var e,i,n,a,s=t[0],o=t[1],r=t[2];return 8>=s?(i=100*s/903.3,a=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),a=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+a-16/116)/7.787:95.047*Math.pow(o/500+a,3),n=.008859>=n/108.883?n=108.883*(a-r/200-16/116)/7.787:108.883*Math.pow(a-r/200,3),[e,i,n]}function O(t){var e,i,n,a=t[0],s=t[1],o=t[2];return e=Math.atan2(o,s),i=360*e/2/Math.PI,0>i&&(i+=360),n=Math.sqrt(s*s+o*o),[a,n,i]}function N(t){return T(V(t))}function H(t){var e,i,n,a=t[0],s=t[1],o=t[2];return n=o/360*2*Math.PI,e=s*Math.cos(n),i=s*Math.sin(n),[a,e,i]}function B(t){return V(H(t))}function E(t){return N(H(t))}function q(t){return $[t]}function j(t){return n(q(t))}function Y(t){return a(q(t))}function X(t){return s(q(t))}function Q(t){return o(q(t))}function Z(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:n,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:f,hsl2hwb:p,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:_,hsv2keyword:k,hwb2rgb:C,hwb2hsl:S,hwb2hsv:P,hwb2cmyk:A,hwb2keyword:M,cmyk2rgb:D,cmyk2hsl:I,cmyk2hsv:F,cmyk2hwb:z,cmyk2keyword:L,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:Z,keyword2xyz:U,xyz2rgb:T,xyz2lab:R,xyz2lch:W,lab2xyz:V,lab2rgb:N,lab2lch:O,lch2lab:H,lch2xyz:B,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var n=t("./conversions"),a=function(){return new l};for(var s in n){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),n[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),r=o[1],h=o[2];a[r]=a[r]||{},a[r][h]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=n[t](e);if("string"==typeof i||void 0===i)return i;for(var a=0;ae||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),a=Math.round(t[2]/255*100);return"rgb("+i+"%, "+n+"%, "+a+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),a=Math.round(t[2]/255*100);return"rgba("+i+"%, "+n+"%, "+a+"%, "+(e||t[3]||1)+")"}function f(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:n,getHsla:a,getRgb:o,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:f,hslaString:p,hwbString:v,keyword:m};var w={};for(var _ in y)w[y[_]]=_},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/samples/line.html b/samples/line.html index a20b6773e27..b920a04ddeb 100644 --- a/samples/line.html +++ b/samples/line.html @@ -28,6 +28,7 @@ }; var config = { + type: 'line', data: { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ @@ -64,7 +65,7 @@ window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myLine = new Chart(ctx).Line(config); + window.myLine = new Chart(ctx, config); }; $('#randomizeData').click(function() { From 8e3d3c2c226f55695b5d35a0e6f9795e23b03cd4 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 15 Jun 2015 18:54:46 -0400 Subject: [PATCH 171/424] Fix animations --- src/controllers/controller.bar.js | 2 +- src/controllers/controller.line.js | 2 +- src/core/core.controller.js | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 7abc60df6b5..9ade9287930 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -103,7 +103,7 @@ // Desired view properties _model: { x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), - y: reset ? yScalePoint : yScale.getPixelForValue(this.getDataset().data[index]), + y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), // Tooltip label: this.chart.data.labels[index], diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index 14462210993..c9fc366822f 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -132,7 +132,7 @@ // Desired view properties _model: { x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - y: yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 55c4159d39c..aaa23a262c9 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -47,8 +47,11 @@ // If BeforeInit(this) doesn't return false, proceed this.bindEvents(); - this.buildScales(); + + // Make sure controllers are built first so that each dataset is bound to an axis before the scales + // are built this.buildControllers(); + this.buildScales(); this.resetElements(); this.initToolTip(); this.update(); From b21061c164e265490fe3eb80df266cc62b334044 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 15 Jun 2015 19:10:47 -0400 Subject: [PATCH 172/424] Remove hover styles --- src/controllers/controller.bar.js | 9 ++++++--- src/controllers/controller.line.js | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 9ade9287930..0bb92041d69 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -128,8 +128,6 @@ }, this); }, - - setHoverStyle: function(rectangle) { var dataset = this.chart.data.datasets[rectangle._datasetIndex]; var index = rectangle._index; @@ -140,7 +138,12 @@ }, removeHoverStyle: function(rectangle) { - // TODO + var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + var index = rectangle._index; + + rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor); + rectangle._model.borderColor = rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth); } }); diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index c9fc366822f..79bc1c7822e 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -215,7 +215,13 @@ }, removeHoverStyle: function(point) { - // TODO + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; + + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius); + point._model.backgroundColor = point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor); + point._model.borderColor = point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor); + point._model.borderWidth = point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth); } }); From d3538a1fbde0d0468f123531dd92eae215d75bd3 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 15 Jun 2015 19:21:13 -0400 Subject: [PATCH 173/424] use inLabelRange when tooltips are in label mode --- src/core/core.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index aaa23a262c9..1f349d6e5ca 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -223,7 +223,7 @@ helpers.each(this.data.datasets, function(dataset, datasetIndex) { helpers.each(dataset.metaData, function(element, index) { - if (element.inRange(eventPosition.x, eventPosition.y)) { + if (element.inLabelRange(eventPosition.x, eventPosition.y)) { elementsArray.push(element); } }, this); From 22c40fe752fd6754ba16963c3af7ac235eeb3f0e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 15 Jun 2015 19:34:29 -0400 Subject: [PATCH 174/424] Fix 2 bar samples --- samples/bar-multi-axis.html | 3 ++- samples/bar-stacked.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/bar-multi-axis.html b/samples/bar-multi-axis.html index d6ae2595156..ff5c360fa9f 100644 --- a/samples/bar-multi-axis.html +++ b/samples/bar-multi-axis.html @@ -45,7 +45,8 @@ }; window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myBar = new Chart(ctx).Bar({ + window.myBar = new Chart(ctx, { + type: 'bar', data: barChartData, options: { responsive: true, diff --git a/samples/bar-stacked.html b/samples/bar-stacked.html index 573be2c183c..5c03e4aa1a0 100644 --- a/samples/bar-stacked.html +++ b/samples/bar-stacked.html @@ -39,7 +39,8 @@ }; window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myBar = new Chart(ctx).Bar({ + window.myBar = new Chart(ctx, { + type: 'bar', data: barChartData, options: { responsive: true, From fa1b0db453c679320d97513692cf1aac4819da02 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 15 Jun 2015 19:34:40 -0400 Subject: [PATCH 175/424] Apply correct hover styles --- src/core/core.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 1f349d6e5ca..3130c1c02bf 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -331,7 +331,7 @@ break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { - this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + this.data.datasets[this.lastActive[i]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); } break; case 'dataset': @@ -349,7 +349,7 @@ break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[i]); + this.data.datasets[this.active[i]._datasetIndex].controller.setHoverStyle(this.active[i]); } break; case 'dataset': From 74f161b548300b0144bf5cf520ef8d4e61bfce48 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 19:14:11 -0600 Subject: [PATCH 176/424] Core improvements, arc & doughnut partially working --- samples/doughnut.html | 4 +- src/controllers/controller.doughnut.js | 307 ++++++++++++++++--------- src/core/core.controller.js | 52 +++-- src/elements/element.arc.js | 2 +- 4 files changed, 225 insertions(+), 140 deletions(-) diff --git a/samples/doughnut.html b/samples/doughnut.html index dc874e754d9..7e529acd3b9 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -31,6 +31,7 @@ }; var config = { + type: 'doughnut', data: { datasets: [{ data: [ @@ -93,7 +94,8 @@ window.onload = function() { var ctx = document.getElementById("chart-area").getContext("2d"); - window.myDoughnut = new Chart(ctx).Doughnut(config); + window.myDoughnut = new Chart(ctx, config); + console.log(window.myDoughnut); }; $('#randomizeData').click(function() { diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 2324a78505f..21ae0c96a30 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -1,33 +1,179 @@ (function() { "use strict"; - return; - var root = this, Chart = root.Chart, //Cache a local reference to Chart.helpers helpers = Chart.helpers; - var defaultConfig = { - + Chart.defaults.doughnut = { animation: { //Boolean - Whether we animate the rotation of the Doughnut animateRotate: true, - //Boolean - Whether we animate scaling the Doughnut from the centre animateScale: false, }, - hover: { mode: 'single' }, - //The percentage of the chart that we cut out of the middle. - cutoutPercentage: 50, }; + + Chart.controllers.doughnut = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; + + helpers.extend(Chart.controllers.doughnut.prototype, { + + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, + + linkScales: function() { + // no scales for doughnut + }, + + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, + + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + + addElements: function() { + this.getDataset().metaData = this.getDataset().metaData || []; + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + }, this); + }, + + reset: function() { + this.update(true); + }, + + update: function(reset) { + + this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; + this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; + this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; + + + this.getDataset().total = 0; + helpers.each(this.getDataset().data, function(value) { + this.getDataset().total += Math.abs(value); + }, this); + + this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index); + this.innerRadius = this.chart.outerRadius - this.chart.radiusLength; + + helpers.each(this.getDataset().metaData, function(arc, index) { + + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(this.getDataset().data[index]), + outerRadius: (this.chart.options.animation.animateScale) ? 0 : this.outerRadius, + innerRadius: (this.chart.options.animation.animateScale) ? 0 : this.innerRadius, + }; + + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: reset ? resetModel : { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + circumference: this.calculateCircumference(this.getDataset().data[index]), + outerRadius: this.outerRadius, + innerRadius: this.innerRadius, + + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index]) + }, + }); + + if (!reset) { + + if (index === 0) { + arc._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + } else { + arc._model.startAngle = this.getDataset().metaData[index - 1]._model.endAngle; + } + + arc._model.endAngle = arc._model.startAngle + arc._model.circumference; + + + //Check to see if it's the last arc, if not get the next and update its start angle + if (index < this.getDataset().data.length - 1) { + this.getDataset().metaData[index + 1]._model.startAngle = arc._model.endAngle; + } + } + + arc.pivot(); + }, this); + }, + + draw: function(ease) { + var easingDecimal = ease || 1; + helpers.each(this.getDataset().metaData, function(arc, index) { + arc.transition(easingDecimal).draw(); + }, this); + }, + + + + setHoverStyle: function(rectangle) { + var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + var index = rectangle._index; + + rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + }, + + removeHoverStyle: function(rectangle) { + // TODO + }, + + calculateCircumference: function(value) { + if (this.getDataset().total > 0) { + return (Math.PI * 2) * (value / this.getDataset().total); + } else { + return 0; + } + }, + + }); + + + + + + + + + + return; + Chart.Type.extend({ //Passing in a name registers this chart in the Chart namespace name: "Doughnut", @@ -38,7 +184,7 @@ initialize: function() { //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); + helpers.bindEvents(this, this.chart.options.events, this.events); //Create a new bar for each piece of data helpers.each(this.data.datasets, function(dataset, datasetIndex) { @@ -67,16 +213,9 @@ }, - calculateCircumference: function(dataset, value) { - if (dataset.total > 0) { - return (Math.PI * 2) * (value / dataset.total); - } else { - return 0; - } - }, resetElements: function() { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; + this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; + this.innerRadius = this.chart.options.cutoutPercentage ? (this.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; // Update the points @@ -90,102 +229,40 @@ dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); dataset.innerRadius = dataset.outerRadius - this.radiusLength; - helpers.each(dataset.metaData, function(slice, index) { - helpers.extend(slice, { + helpers.each(dataset.metaData, function(arc, index) { + helpers.extend(arc, { _model: { x: this.chart.width / 2, y: this.chart.height / 2, startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, - innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, + circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), + outerRadius: (this.chart.options.animation.animateScale) ? 0 : dataset.outerRadius, + innerRadius: (this.chart.options.animation.animateScale) ? 0 : dataset.innerRadius, - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.chart.options.elements.arc.borderColor), - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) + label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.chart.data.labels[index]) }, }); - slice.pivot(); + arc.pivot(); }, this); }, this); }, update: function(animationDuration) { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(slice, index) { - - helpers.extend(slice, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - - // Desired view properties - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - circumference: this.calculateCircumference(dataset, dataset.data[index]), - outerRadius: dataset.outerRadius, - innerRadius: dataset.innerRadius, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); - - if (index === 0) { - slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - } else { - slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; - } - - slice._model.endAngle = slice._model.startAngle + slice._model.circumference; - - - //Check to see if it's the last slice, if not get the next and update its start angle - if (index < dataset.data.length - 1) { - dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; - } - - slice.pivot(); - }, this); - - }, this); - this.render(animationDuration); }, draw: function(easeDecimal) { easeDecimal = easeDecimal || 1; this.clear(); - this.eachElement(function(slice) { - slice.transition(easeDecimal).draw(); + this.eachElement(function(arc) { + arc.transition(easeDecimal).draw(); }, this); this.tooltip.transition(easeDecimal).draw(); @@ -200,7 +277,7 @@ } else { this.active = function() { - switch (this.options.hover.mode) { + switch (this.chart.options.hover.mode) { case 'single': return this.getSliceAtEvent(e); case 'label': @@ -214,13 +291,13 @@ } // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); + if (this.chart.options.hover.onHover) { + this.chart.options.hover.onHover.call(this, this.active); } if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); + if (this.chart.options.onClick) { + this.chart.options.onClick.call(this, e, this.active); } } @@ -228,23 +305,23 @@ var index; // Remove styling for last active (even if it may still be active) if (this.lastActive.length) { - switch (this.options.hover.mode) { + switch (this.chart.options.hover.mode) { case 'single': dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; index = this.lastActive[0]._index; - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.chart.options.elements.arc.backgroundColor); + this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.chart.options.elements.arc.borderColor); + this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.chart.options.elements.arc.borderWidth); break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; index = this.lastActive[i]._index; - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); + this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.chart.options.elements.arc.backgroundColor); + this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.chart.options.elements.arc.borderColor); + this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.chart.options.elements.arc.borderWidth); } break; case 'dataset': @@ -255,8 +332,8 @@ } // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { + if (this.active.length && this.chart.options.hover.mode) { + switch (this.chart.options.hover.mode) { case 'single': dataset = this.data.datasets[this.active[0]._datasetIndex]; index = this.active[0]._index; @@ -284,7 +361,7 @@ // Built in Tooltips - if (this.options.tooltips.enabled) { + if (this.chart.options.tooltips.enabled) { // The usual updates this.tooltip.initialize(); @@ -323,7 +400,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hover.animationDuration); + this.render(this.chart.options.hover.animationDuration); } } @@ -336,9 +413,9 @@ var location = helpers.getRelativePosition(e); - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); + this.eachElement(function(arc, index) { + if (arc.inRange(location.x, location.y)) { + elements.push(arc); } }, this); return elements; @@ -348,9 +425,9 @@ var location = helpers.getRelativePosition(e); - this.eachElement(function(slice, index) { - if (slice.inLabelRange(location.x, location.y)) { - elements.push(slice); + this.eachElement(function(arc, index) { + if (arc.inLabelRange(location.x, location.y)) { + elements.push(arc); } }, this); return elements; diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 55c4159d39c..b7be643f031 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -89,30 +89,36 @@ this.scales = {}; // Build the x axes - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - data: this.data, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); + if (this.options.scales) { + if (this.options.scales.xAxes && this.options.scales.xAxes.length) { + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + } - // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: yAxisOptions, - data: this.data, - id: yAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); + if (this.options.scales.yAxes && this.options.scales.yAxes.length) { + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + } + } Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); }, diff --git a/src/elements/element.arc.js b/src/elements/element.arc.js index f5a3c628a73..e09f0cf5795 100644 --- a/src/elements/element.arc.js +++ b/src/elements/element.arc.js @@ -23,7 +23,7 @@ borderWidth: 2 }; - Chart.Arc = Chart.Element.extend({ + Chart.elements.Arc = Chart.Element.extend({ inLabelRange: function(mouseX) { var vm = this._view; From 2aa489643a9c8ac67af47dac80d629f635396b3c Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 22:43:24 -0600 Subject: [PATCH 177/424] Doughnut/Pie accurate radii --- src/controllers/controller.doughnut.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 21ae0c96a30..110b2b5c721 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -75,7 +75,7 @@ }, this); this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index); - this.innerRadius = this.chart.outerRadius - this.chart.radiusLength; + this.innerRadius = this.outerRadius - this.chart.radiusLength; helpers.each(this.getDataset().metaData, function(arc, index) { @@ -141,17 +141,22 @@ - setHoverStyle: function(rectangle) { - var dataset = this.chart.data.datasets[rectangle._datasetIndex]; - var index = rectangle._index; + setHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; - rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(arc._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, arc._model.borderWidth); }, - removeHoverStyle: function(rectangle) { - // TODO + removeHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; + + arc._model.backgroundColor = arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor); + arc._model.borderColor = arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor); + arc._model.borderWidth = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth); }, calculateCircumference: function(value) { From 76e060cf97b2be1377106c2b9ba945042a4797cc Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 22:43:45 -0600 Subject: [PATCH 178/424] Better getElementAtEvent function --- src/core/core.controller.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 0bf8aeae2cd..694af766113 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -209,18 +209,18 @@ getElementAtEvent: function(e) { var eventPosition = helpers.getRelativePosition(e); - var element = []; + var elementsArray = []; helpers.each(this.data.datasets, function(dataset, datasetIndex) { helpers.each(dataset.metaData, function(element, index) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); - return element; + if (element.inRange(eventPosition.x, eventPosition.y)) { + elementsArray.push(element); + return elementsArray; } }, this); }, this); - return []; + return elementsArray; }, getElementsAtEvent: function(e) { From 8b3424bd09af76f79967d0314ea229ff95ca38e3 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 22:44:06 -0600 Subject: [PATCH 179/424] Responsive used proper "each" from helpers --- src/core/core.responsive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.responsive.js b/src/core/core.responsive.js index 73c12ea3057..23295feba6d 100644 --- a/src/core/core.responsive.js +++ b/src/core/core.responsive.js @@ -15,7 +15,7 @@ return function() { clearTimeout(timeout); timeout = setTimeout(function() { - each(Chart.instances, function(instance) { + helpers.each(Chart.instances, function(instance) { // If the responsive flag is set in the chart instance config // Cascade the resize event down to the chart. if (instance.options.responsive) { From 5759f419c06b0882bfe28579c73aa745de43014b Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 22:47:20 -0600 Subject: [PATCH 180/424] Pie used new doughnut controller --- samples/pie.html | 3 ++- src/controllers/controller.doughnut.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/samples/pie.html b/samples/pie.html index 34b126ec062..6f97bd43eec 100644 --- a/samples/pie.html +++ b/samples/pie.html @@ -21,6 +21,7 @@ }; var config = { + type: 'pie', data: { datasets: [{ data: [ @@ -83,7 +84,7 @@ window.onload = function() { var ctx = document.getElementById("chart-area").getContext("2d"); - window.myPie = new Chart(ctx).Pie(config); + window.myPie = new Chart(ctx, config); }; $('#randomizeData').click(function() { diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 110b2b5c721..63aad31735f 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -18,11 +18,15 @@ }, //The percentage of the chart that we cut out of the middle. cutoutPercentage: 50, - }; + Chart.defaults.pie = helpers.clone(Chart.defaults.doughnut); + helpers.extend(Chart.defaults.pie, { + cutoutPercentage: 0 + }); + - Chart.controllers.doughnut = function(chart, datasetIndex) { + Chart.controllers.doughnut = Chart.controllers.pie = function(chart, datasetIndex) { this.initialize.call(this, chart, datasetIndex); }; From ef1acfa0e85f5b2d5aca473eb5027b91f89d6fb1 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 23:54:25 -0600 Subject: [PATCH 181/424] Build single scales in core --- src/core/core.controller.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 694af766113..562978f1354 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -121,6 +121,20 @@ this.scales[scale.id] = scale; }, this); } + + if (this.options.scale) { + // Build radial axes + var ScaleClass = Chart.scaleService.getScaleConstructor(axisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: axisOptions, + data: this.data, + id: axisOptions.id, + chart: this.chart, + }); + + this.scale = scale; + } } Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); From 4c749e78b2a72e024c386cdc44ecb1e92d158239 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 23:58:31 -0600 Subject: [PATCH 182/424] Single scale again. --- src/core/core.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 562978f1354..242d1935677 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -124,7 +124,7 @@ if (this.options.scale) { // Build radial axes - var ScaleClass = Chart.scaleService.getScaleConstructor(axisOptions.type); + var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); var scale = new ScaleClass({ ctx: this.chart.ctx, options: axisOptions, From 42648d0a83507830b70cf1865fb657cf5ba7bf24 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 15 Jun 2015 23:59:04 -0600 Subject: [PATCH 183/424] Build radial scale details inside itself --- src/scales/scale.radialLinear.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 530c1ebe8f0..130a43a5ac2 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -68,7 +68,13 @@ var LinearRadialScale = Chart.Element.extend({ initialize: function() { + this.height = this.chart.height; + this.width = this.chart.width; + this.xCenter = this.chart.width / 2; + this.yCenter = this.chart.height / 2; this.size = helpers.min([this.height, this.width]); + this.valuesCount = this.data.labels.length; + this.labels = this.data.labels; this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, update: function() { From 2d5eb6d57e97f9434c8483f6ef23f2bea6f1a969 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 00:17:26 -0600 Subject: [PATCH 184/424] Radar chart and radialLinear scale --- samples/radar.html | 6 +- src/controllers/controller.radar.js | 491 ++++++++-------------------- src/core/core.controller.js | 29 +- src/scales/scale.radialLinear.js | 3 +- 4 files changed, 157 insertions(+), 372 deletions(-) diff --git a/samples/radar.html b/samples/radar.html index 199791904d1..0630bc1edce 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -21,6 +21,7 @@ }; var config = { + type: 'radar', data: { labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"], datasets: [{ @@ -36,14 +37,11 @@ pointHighlightStroke: "rgba(151,187,205,1)", data: [null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }] - }, - options: { - responsive: true } }; window.onload = function() { - window.myRadar = new Chart(document.getElementById("canvas").getContext("2d")).Radar(config); + window.myRadar = new Chart(document.getElementById("canvas"), config); }; $('#randomizeData').click(function() { diff --git a/src/controllers/controller.radar.js b/src/controllers/controller.radar.js index b813764bfc1..28c0f2ca8fb 100644 --- a/src/controllers/controller.radar.js +++ b/src/controllers/controller.radar.js @@ -1,221 +1,158 @@ (function() { "use strict"; - return; - var root = this, Chart = root.Chart, helpers = Chart.helpers; - Chart.Type.extend({ - name: "Radar", - defaults: { - - scale: { - type: "radialLinear", - }, - - elements: { - line: { - tension: 0, // no bezier in radar - } - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - + Chart.defaults.radar = { + scale: { + type: "radialLinear", }, + elements: { + line: { + tension: 0, // no bezier in radar + } + }, + }; - initialize: function() { - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { + Chart.controllers.radar = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - _loop: true - }); - dataset.metaData = []; + helpers.extend(Chart.controllers.radar.prototype, { - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, - }, this); - }, this); + linkScales: function() { + // No need. Single scale only + }, - // Build the scale. - this.buildScale(); + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + addElements: function() { - // Reset so that we animation from the baseline - this.resetElements(); + this.getDataset().metaData = this.getDataset().metaData || []; - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[0]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[collection.length - 1]; - }, - resetElements: function() { + this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _points: this.getDataset().metaData, + _loop: true + }); - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, _index: index, - _scale: this.scale, - - // Desired view properties _model: { - x: this.scale.xCenter, - y: this.scale.yCenter, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, }, }); }, this); + }, - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); + reset: function() { + this.update(true); + }, - point._model.controlPointPreviousX = this.scale.xCenter; - point._model.controlPointPreviousY = this.scale.yCenter; - point._model.controlPointNextX = this.scale.xCenter; - point._model.controlPointNextY = this.scale.yCenter; + update: function(reset) { - // Now pivot the point for animation - point.pivot(); - }, this); - }, - update: function(animationDuration) { - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var scaleBase; - - if (this.scale.min < 0 && this.scale.max < 0) { - scaleBase = this.scale.getPointPositionForValue(0, this.scale.max); - } else if (this.scale.min > 0 && this.scale.max > 0) { - scaleBase = this.scale.getPointPositionForValue(0, this.scale.min); - } else { - scaleBase = this.scale.getPointPositionForValue(0, 0); - } + var line = this.getDataset().metaDataset; + var points = this.getDataset().metaData; - helpers.extend(dataset.metaDataset, { - // Utility - _datasetIndex: datasetIndex, + var scale = this.chart.scale; + var scaleBase; - // Data - _children: dataset.metaData, + scale.setScaleSize(); + scale.calculateRange(); + scale.generateTicks(); + scale.buildYLabels(); - // Model - _model: { - // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - - // Scale - scaleTop: this.scale.top, - scaleBottom: this.scale.bottom, - scaleZero: scaleBase, - }, - }); + if (scale.min < 0 && scale.max < 0) { + scaleBase = scale.getPointPositionForValue(0, scale.max); + } else if (scale.min > 0 && scale.max > 0) { + scaleBase = scale.getPointPositionForValue(0, scale.min); + } else { + scaleBase = scale.getPointPositionForValue(0, 0); + } - dataset.metaDataset.pivot(); + helpers.extend(this.getDataset().metaDataset, { + // Utility + _datasetIndex: this.index, + // Data + _children: this.getDataset().metaData, + // Model + _model: { + // Appearance + tension: this.getDataset().tension || this.chart.options.elements.line.tension, + backgroundColor: this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor, + borderWidth: this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth, + borderColor: this.getDataset().borderColor || this.chart.options.elements.line.borderColor, + fill: this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill, // use the value from the this.getDataset() if it was provided. else fall back to the default + skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, + drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, + + // Scale + scaleTop: scale.top, + scaleBottom: scale.bottom, + scaleZero: scaleBase, + }, }); - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var pointPosition = this.scale.getPointPositionForValue(index, this.data.datasets[datasetIndex].data[index]); + this.getDataset().metaDataset.pivot(); + + // Update Points + helpers.each(points, function(point, index) { + var pointPosition = scale.getPointPositionForValue(index, this.getDataset().data[index]); helpers.extend(point, { // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, + _datasetIndex: this.index, _index: index, // Desired view properties _model: { - x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: pointPosition.y, + x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: reset ? scale.yCenter : pointPosition.y, // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: this.getDataset().data[index] === null, // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), }, }); }, this); - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { + // Update bezier control points + helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, + helpers.previousItem(this.getDataset().metaData, index, true)._model, point._model, - this.nextPoint(dataset, index)._model, + helpers.nextItem(this.getDataset().metaData, index, true)._model, point._model.tension ); @@ -225,19 +162,19 @@ // Prevent the bezier going outside of the bounds of the graph // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; + if (controlPoints.next.y > this.chart.chartArea.bottom) { + point._model.controlPointNextY = this.chart.chartArea.bottom; + } else if (controlPoints.next.y < this.chart.chartArea.top) { + point._model.controlPointNextY = this.chart.chartArea.top; } else { point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; + if (controlPoints.previous.y > this.chart.chartArea.bottom) { + point._model.controlPointPreviousY = this.chart.chartArea.bottom; + } else if (controlPoints.previous.y < this.chart.chartArea.top) { + point._model.controlPointPreviousY = this.chart.chartArea.top; } else { point._model.controlPointPreviousY = controlPoints.previous.y; } @@ -246,200 +183,48 @@ point.pivot(); }, this); - this.render(animationDuration); }, - buildScale: function() { - var self = this; - - var ScaleConstructor = Chart.scaleService.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleConstructor({ - options: this.options.scale, - height: this.chart.height, - width: this.chart.width, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - labels: this.data.labels, - valuesCount: this.data.datasets[0].data.length, - data: this.data, - }); - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - }, draw: function(ease) { var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - this.scale.draw(this.chartArea); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); + // Transition Point Locations + helpers.each(this.getDataset().metaData, function(point, index) { + point.transition(easingDecimal); + }, this); - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } + // Transition and Draw the line + this.getDataset().metaDataset.transition(easingDecimal).draw(); - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); + // Draw the points + helpers.each(this.getDataset().metaData, function(point) { + point.draw(); + }); }, - events: function(e) { - this.lastActive = this.lastActive || []; + setHoverStyle: function(point) { + // Point + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; - // Find Active Elements - // If exiting chart - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + }, - // Hover animations - this.tooltip.pivot(); + removeHoverStyle: function(point) { + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; - if (!this.animating) { - var changed; + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius); + point._model.backgroundColor = point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor); + point._model.borderColor = point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor); + point._model.borderWidth = point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth); + } - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); + }); - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); }).call(this); diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 242d1935677..577e3e30c57 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -121,20 +121,18 @@ this.scales[scale.id] = scale; }, this); } - - if (this.options.scale) { - // Build radial axes - var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: axisOptions, - data: this.data, - id: axisOptions.id, - chart: this.chart, - }); - - this.scale = scale; - } + } + if (this.options.scale) { + // Build radial axes + var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: this.options.scale, + data: this.data, + chart: this.chart, + }); + + this.scale = scale; } Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); @@ -203,6 +201,9 @@ helpers.each(this.scales, function(scale) { scale.draw(this.chartArea); }, this); + if (this.scale) { + this.scale.draw(); + } // Draw each dataset via its respective controller // TODO: needs support for reverse stacking (line chart) diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 130a43a5ac2..fe47b0c067d 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -9,7 +9,7 @@ display: true, //Boolean - Whether to animate scaling the chart from the centre - animate: false, + animate: true, lineArc: false, @@ -180,6 +180,7 @@ // range of the scale this.max = helpers.max(this.ticks); this.min = helpers.min(this.ticks); + console.log(this); }, buildYLabels: function() { this.yLabels = []; From 902305790679ce3b01e64c5cdf44921906ce8c40 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 00:20:06 -0600 Subject: [PATCH 185/424] Old doughnuts are no good. --- src/controllers/controller.doughnut.js | 276 ------------------------- 1 file changed, 276 deletions(-) diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 63aad31735f..8e5b4e13155 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -174,280 +174,4 @@ }); - - - - - - - - return; - - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.chart.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - - }, - - resetElements: function() { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.chart.options.cutoutPercentage ? (this.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // So that calculateCircumference works - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(arc, index) { - helpers.extend(arc, { - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.chart.options.animation.animateScale) ? 0 : dataset.outerRadius, - innerRadius: (this.chart.options.animation.animateScale) ? 0 : dataset.innerRadius, - - backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.chart.options.elements.arc.backgroundColor), - hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), - borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.chart.options.elements.arc.borderWidth), - borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.chart.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.chart.data.labels[index]) - }, - }); - - arc.pivot(); - }, this); - - }, this); - }, - update: function(animationDuration) { - - - }, - draw: function(easeDecimal) { - easeDecimal = easeDecimal || 1; - this.clear(); - - this.eachElement(function(arc) { - arc.transition(easeDecimal).draw(); - }, this); - - this.tooltip.transition(easeDecimal).draw(); - }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - - this.active = function() { - switch (this.chart.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.chart.options.hover.onHover) { - this.chart.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.chart.options.onClick) { - this.chart.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.chart.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.chart.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.chart.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.chart.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.chart.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.chart.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.chart.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.chart.options.hover.mode) { - switch (this.chart.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.chart.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.chart.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(arc, index) { - if (arc.inRange(location.x, location.y)) { - elements.push(arc); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; - - var location = helpers.getRelativePosition(e); - - this.eachElement(function(arc, index) { - if (arc.inLabelRange(location.x, location.y)) { - elements.push(arc); - } - }, this); - return elements; - },*/ - }); - - Chart.types.Doughnut.extend({ - name: "Pie", - defaults: helpers.merge(defaultConfig, { - cutoutPercentage: 0 - }) - }); - }).call(this); From c0ccae1031e90b255f30018ab150e50672b5c4c1 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 00:20:22 -0600 Subject: [PATCH 186/424] No logging --- src/scales/scale.radialLinear.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index fe47b0c067d..15169aa8673 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -180,7 +180,6 @@ // range of the scale this.max = helpers.max(this.ticks); this.min = helpers.min(this.ticks); - console.log(this); }, buildYLabels: function() { this.yLabels = []; From 1f302f09bb9c6552df67062d9749deba48f5a8c6 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 00:20:46 -0600 Subject: [PATCH 187/424] Fixed polar-area sample --- samples/polar-area.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/polar-area.html b/samples/polar-area.html index d77291a001e..8119fd517ec 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -21,6 +21,7 @@ }; var config = { + type: 'polarArea', data: { datasets: [{ data: [ @@ -52,8 +53,8 @@ }; window.onload = function() { - var ctx = document.getElementById("chart-area").getContext("2d"); - window.myPolarArea = new Chart(ctx).PolarArea(config); + var ctx = document.getElementById("chart-area"); + window.myPolarArea = new Chart(ctx, config); }; $('#randomizeData').click(function() { From db981807bb48ed0853de6a28bec83fc424b95ad9 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 00:39:04 -0600 Subject: [PATCH 188/424] Polar Area Draws, but has scale resizing issues --- samples/polar-area.html | 14 +- src/controllers/controller.polarArea.js | 393 +++++++----------------- 2 files changed, 122 insertions(+), 285 deletions(-) diff --git a/samples/polar-area.html b/samples/polar-area.html index 8119fd517ec..4388a73cad0 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -38,14 +38,14 @@ "#949FB1", "#4D5360", ], - labels: [ - "Red", - "Green", - "Yellow", - "Grey", - "Dark Grey" - ] }], + labels: [ + "Red", + "Green", + "Yellow", + "Grey", + "Dark Grey" + ] }, options: { responsive: true diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 22b0fbb3ab3..2aa0e498916 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -1,14 +1,13 @@ (function() { "use strict"; - return; - var root = this, Chart = root.Chart, //Cache a local reference to Chart.helpers helpers = Chart.helpers; - var defaultConfig = { + + Chart.defaults.polarArea = { scale: { type: "radialLinear", @@ -19,330 +18,168 @@ animateRotate: true, }; + Chart.controllers.polarArea = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "PolarArea", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { - - // Scale setup - var self = this; - var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleClass({ - options: this.options.scale, - lineArc: true, - width: this.chart.width, - height: this.chart.height, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - valuesCount: this.data.length, - data: this.data - }); - - helpers.bindEvents(this, this.options.events, this.events); - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Fit the scale before we animate - this.updateScaleRange(); - this.scale.calculateRange(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // so that we animate nicely - this.resetElements(); - - // Update the chart with the latest data. - this.update(); + helpers.extend(Chart.controllers.polarArea.prototype, { + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); }, - updateScaleRange: function() { - helpers.extend(this.scale, { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2 - }); + + linkScales: function() { + // no scales for doughnut }, - resetElements: function() { - var circumference = 1 / this.data.datasets[0].data.length * 2; - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, - var value = this.data.datasets[0].data[index]; + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, - helpers.extend(slice, { + addElements: function() { + this.getDataset().metaData = this.getDataset().metaData || []; + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) - }, }); - - slice.pivot(); }, this); }, - update: function(animationDuration) { - this.updateScaleRange(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); + reset: function() { + this.update(true); + }, + + update: function(reset) { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + //this.chart.scale.setScaleSize(); + this.chart.scale.calculateRange(); + this.chart.scale.generateTicks(); + this.chart.scale.buildYLabels(); + + this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; + this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; + this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; + + this.getDataset().total = 0; + helpers.each(this.getDataset().data, function(value) { + this.getDataset().total += Math.abs(value); + }, this); + + this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index); + this.innerRadius = this.outerRadius - this.chart.radiusLength; + + helpers.each(this.getDataset().metaData, function(arc, index) { - var circumference = 1 / this.data.datasets[0].data.length * 2; + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + innerRadius: 0, + outerRadius: 0, + startAngle: Math.PI * -0.5, + endAngle: Math.PI * -0.5, - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - var value = this.data.datasets[0].data[index]; + label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) + }; + var circumference = 1 / this.getDataset().data.length * 2; var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; var endAngle = startAngle + (circumference * Math.PI); - helpers.extend(slice, { + console.log() + + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, + + // Desired view properties + _model: reset ? resetModel : { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, innerRadius: 0, - outerRadius: this.scale.getDistanceFromCenterForValue(value), + outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), startAngle: startAngle, endAngle: endAngle, - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) }, }); - slice.pivot(); - - console.log(slice); + arc.pivot(); }, this); - - this.render(animationDuration); }, + draw: function(ease) { var easingDecimal = ease || 1; - - this.clear(); - - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - slice.transition(easingDecimal).draw(); + helpers.each(this.getDataset().metaData, function(arc, index) { + arc.transition(easingDecimal).draw(); + console.log(arc); }, this); - - this.scale.draw(); - - this.tooltip.transition(easingDecimal).draw(); }, - events: function(e) { - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - // Built in Tooltips - if (this.options.tooltips.enabled) { + setHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; - // The usual updates - this.tooltip.initialize(); + arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(arc._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, arc._model.borderWidth); + }, - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; + removeHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; - helpers.extend(this.tooltip, { - _active: this.active, - }); + arc._model.backgroundColor = arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor); + arc._model.borderColor = arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor); + arc._model.borderWidth = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth); + }, - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } + calculateCircumference: function(value) { + if (this.getDataset().total > 0) { + return (Math.PI * 2) * (value / this.getDataset().total); + } else { + return 0; } + }, + updateScaleRange: function() { + helpers.extend(this.chart.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2 + }); + }, + }); - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; - var location = helpers.getRelativePosition(e); - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; + return; - var location = helpers.getRelativePosition(e); - this.eachElement(function(slice, index) { - if (slice.inLabelRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ - }); + Chart.Type.extend({}); }).call(this); From 37b13265c96b19c7501d3832c43592c180fa6f7f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 11:22:28 -0600 Subject: [PATCH 189/424] Build --- Chart.js | 1408 ++++++++++++++++---------------------------------- Chart.min.js | 11 +- 2 files changed, 451 insertions(+), 968 deletions(-) diff --git a/Chart.js b/Chart.js index f620d39f0af..5a49a4ea56d 100644 --- a/Chart.js +++ b/Chart.js @@ -1241,8 +1241,11 @@ // If BeforeInit(this) doesn't return false, proceed this.bindEvents(); - this.buildScales(); + + // Make sure controllers are built first so that each dataset is bound to an axis before the scales + // are built this.buildControllers(); + this.buildScales(); this.resetElements(); this.initToolTip(); this.update(); @@ -1283,30 +1286,48 @@ this.scales = {}; // Build the x axes - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); - var scale = new ScaleClass({ - ctx: this.chart.ctx, - options: xAxisOptions, - data: this.data, - id: xAxisOptions.id, - }); - - this.scales[scale.id] = scale; - }, this); + if (this.options.scales) { + if (this.options.scales.xAxes && this.options.scales.xAxes.length) { + helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: xAxisOptions, + data: this.data, + id: xAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + } - // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { - var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + if (this.options.scales.yAxes && this.options.scales.yAxes.length) { + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); + var scale = new ScaleClass({ + ctx: this.chart.ctx, + options: yAxisOptions, + data: this.data, + id: yAxisOptions.id, + }); + + this.scales[scale.id] = scale; + }, this); + } + } + if (this.options.scale) { + // Build radial axes + var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); var scale = new ScaleClass({ ctx: this.chart.ctx, - options: yAxisOptions, + options: this.options.scale, data: this.data, - id: yAxisOptions.id, + chart: this.chart, }); - this.scales[scale.id] = scale; - }, this); + this.scale = scale; + } Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); }, @@ -1374,6 +1395,9 @@ helpers.each(this.scales, function(scale) { scale.draw(this.chartArea); }, this); + if (this.scale) { + this.scale.draw(); + } // Draw each dataset via its respective controller // TODO: needs support for reverse stacking (line chart) @@ -1394,18 +1418,18 @@ getElementAtEvent: function(e) { var eventPosition = helpers.getRelativePosition(e); - var element = []; + var elementsArray = []; helpers.each(this.data.datasets, function(dataset, datasetIndex) { helpers.each(dataset.metaData, function(element, index) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inRange(eventPosition.x, eventPosition.y)) { - element.push(this.chart.data.datasets[datasetIndex].metaData[elementIndex]); - return element; + if (element.inRange(eventPosition.x, eventPosition.y)) { + elementsArray.push(element); + return elementsArray; } }, this); }, this); - return []; + return elementsArray; }, getElementsAtEvent: function(e) { @@ -1414,7 +1438,7 @@ helpers.each(this.data.datasets, function(dataset, datasetIndex) { helpers.each(dataset.metaData, function(element, index) { - if (element.inRange(eventPosition.x, eventPosition.y)) { + if (element.inLabelRange(eventPosition.x, eventPosition.y)) { elementsArray.push(element); } }, this); @@ -1522,7 +1546,7 @@ break; case 'label': for (var i = 0; i < this.lastActive.length; i++) { - this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); + this.data.datasets[this.lastActive[i]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); } break; case 'dataset': @@ -1540,7 +1564,7 @@ break; case 'label': for (var i = 0; i < this.active.length; i++) { - this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[i]); + this.data.datasets[this.active[i]._datasetIndex].controller.setHoverStyle(this.active[i]); } break; case 'dataset': @@ -1619,7 +1643,7 @@ return function() { clearTimeout(timeout); timeout = setTimeout(function() { - each(Chart.instances, function(instance) { + helpers.each(Chart.instances, function(instance) { // If the responsive flag is set in the chart instance config // Cascade the resize event down to the chart. if (instance.options.responsive) { @@ -2342,7 +2366,7 @@ // Desired view properties _model: { x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), - y: reset ? yScalePoint : yScale.getPixelForValue(this.getDataset().data[index]), + y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), // Tooltip label: this.chart.data.labels[index], @@ -2367,8 +2391,6 @@ }, this); }, - - setHoverStyle: function(rectangle) { var dataset = this.chart.data.datasets[rectangle._datasetIndex]; var index = rectangle._index; @@ -2379,7 +2401,12 @@ }, removeHoverStyle: function(rectangle) { - // TODO + var dataset = this.chart.data.datasets[rectangle._datasetIndex]; + var index = rectangle._index; + + rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor); + rectangle._model.borderColor = rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth); } }); @@ -2391,368 +2418,178 @@ (function() { "use strict"; - return; - var root = this, Chart = root.Chart, //Cache a local reference to Chart.helpers helpers = Chart.helpers; - var defaultConfig = { - + Chart.defaults.doughnut = { animation: { //Boolean - Whether we animate the rotation of the Doughnut animateRotate: true, - //Boolean - Whether we animate scaling the Doughnut from the centre animateScale: false, }, - hover: { mode: 'single' }, - //The percentage of the chart that we cut out of the middle. - cutoutPercentage: 50, - }; - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "Doughnut", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { - - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); - - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); + Chart.defaults.pie = helpers.clone(Chart.defaults.doughnut); + helpers.extend(Chart.defaults.pie, { + cutoutPercentage: 0 + }); - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - this.resetElements(); + Chart.controllers.doughnut = Chart.controllers.pie = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; - // Update the chart with the latest data. - this.update(); + helpers.extend(Chart.controllers.doughnut.prototype, { + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); }, - calculateCircumference: function(dataset, value) { - if (dataset.total > 0) { - return (Math.PI * 2) * (value / dataset.total); - } else { - return 0; - } + linkScales: function() { + // no scales for doughnut }, - resetElements: function() { - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; - - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - // So that calculateCircumference works - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); - dataset.innerRadius = dataset.outerRadius - this.radiusLength; - - helpers.each(dataset.metaData, function(slice, index) { - helpers.extend(slice, { - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.options.animation.animateRotate) ? 0 : this.calculateCircumference(metaSlice.value), - outerRadius: (this.options.animation.animateScale) ? 0 : dataset.outerRadius, - innerRadius: (this.options.animation.animateScale) ? 0 : dataset.innerRadius, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, - slice.pivot(); - }, this); + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, + addElements: function() { + this.getDataset().metaData = this.getDataset().metaData || []; + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); }, this); }, - update: function(animationDuration) { - - this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.elements.arc.borderWidth / 2) / 2; - this.innerRadius = this.options.cutoutPercentage ? (this.outerRadius / 100) * (this.options.cutoutPercentage) : 1; - this.radiusLength = (this.outerRadius - this.innerRadius) / this.data.datasets.length; + reset: function() { + this.update(true); + }, - // Update the points - helpers.each(this.data.datasets, function(dataset, datasetIndex) { + update: function(reset) { - dataset.total = 0; - helpers.each(dataset.data, function(value) { - dataset.total += Math.abs(value); - }, this); + this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; + this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; + this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; - dataset.outerRadius = this.outerRadius - (this.radiusLength * datasetIndex); + this.getDataset().total = 0; + helpers.each(this.getDataset().data, function(value) { + this.getDataset().total += Math.abs(value); + }, this); - dataset.innerRadius = dataset.outerRadius - this.radiusLength; + this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index); + this.innerRadius = this.outerRadius - this.chart.radiusLength; - helpers.each(dataset.metaData, function(slice, index) { + helpers.each(this.getDataset().metaData, function(arc, index) { - helpers.extend(slice, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(this.getDataset().data[index]), + outerRadius: (this.chart.options.animation.animateScale) ? 0 : this.outerRadius, + innerRadius: (this.chart.options.animation.animateScale) ? 0 : this.innerRadius, + }; - // Desired view properties - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - circumference: this.calculateCircumference(dataset, dataset.data[index]), - outerRadius: dataset.outerRadius, - innerRadius: dataset.innerRadius, + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor), + // Desired view properties + _model: reset ? resetModel : { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + circumference: this.calculateCircumference(this.getDataset().data[index]), + outerRadius: this.outerRadius, + innerRadius: this.innerRadius, + + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index]) + }, + }); - label: helpers.getValueAtIndexOrDefault(dataset.label, index, this.data.labels[index]) - }, - }); + if (!reset) { if (index === 0) { - slice._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + arc._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function } else { - slice._model.startAngle = dataset.metaData[index - 1]._model.endAngle; + arc._model.startAngle = this.getDataset().metaData[index - 1]._model.endAngle; } - slice._model.endAngle = slice._model.startAngle + slice._model.circumference; + arc._model.endAngle = arc._model.startAngle + arc._model.circumference; - //Check to see if it's the last slice, if not get the next and update its start angle - if (index < dataset.data.length - 1) { - dataset.metaData[index + 1]._model.startAngle = slice._model.endAngle; + //Check to see if it's the last arc, if not get the next and update its start angle + if (index < this.getDataset().data.length - 1) { + this.getDataset().metaData[index + 1]._model.startAngle = arc._model.endAngle; } + } - slice.pivot(); - }, this); - + arc.pivot(); }, this); - - this.render(animationDuration); }, - draw: function(easeDecimal) { - easeDecimal = easeDecimal || 1; - this.clear(); - this.eachElement(function(slice) { - slice.transition(easeDecimal).draw(); + draw: function(ease) { + var easingDecimal = ease || 1; + helpers.each(this.getDataset().metaData, function(arc, index) { + arc.transition(easingDecimal).draw(); }, this); - - this.tooltip.transition(easeDecimal).draw(); }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - if (e.type == 'mouseout') { - this.active = []; - } else { - - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, this.active[0]._model.borderColor); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); - - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } - - - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - this.stop(); - this.render(this.options.hover.animationDuration); - } - } + setHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; - // Remember Last Active - this.lastActive = this.active; - return this; + arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(arc._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, arc._model.borderWidth); }, - getSliceAtEvent: function(e) { - var elements = []; - var location = helpers.getRelativePosition(e); + removeHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; + arc._model.backgroundColor = arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor); + arc._model.borderColor = arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor); + arc._model.borderWidth = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth); }, - /*getSlicesAtEvent: function(e) { - var elements = []; - var location = helpers.getRelativePosition(e); + calculateCircumference: function(value) { + if (this.getDataset().total > 0) { + return (Math.PI * 2) * (value / this.getDataset().total); + } else { + return 0; + } + }, - this.eachElement(function(slice, index) { - if (slice.inLabelRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ }); - Chart.types.Doughnut.extend({ - name: "Pie", - defaults: helpers.merge(defaultConfig, { - cutoutPercentage: 0 - }) - }); }).call(this); @@ -2890,7 +2727,7 @@ // Desired view properties _model: { x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - y: yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), // Appearance tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), @@ -2973,7 +2810,13 @@ }, removeHoverStyle: function(point) { - // TODO + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; + + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius); + point._model.backgroundColor = point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor); + point._model.borderColor = point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor); + point._model.borderWidth = point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth); } }); @@ -2985,14 +2828,13 @@ (function() { "use strict"; - return; - var root = this, Chart = root.Chart, //Cache a local reference to Chart.helpers helpers = Chart.helpers; - var defaultConfig = { + + Chart.defaults.polarArea = { scale: { type: "radialLinear", @@ -3003,552 +2845,327 @@ animateRotate: true, }; + Chart.controllers.polarArea = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; - Chart.Type.extend({ - //Passing in a name registers this chart in the Chart namespace - name: "PolarArea", - //Providing a defaults will also register the deafults in the chart namespace - defaults: defaultConfig, - //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() { + helpers.extend(Chart.controllers.polarArea.prototype, { - // Scale setup - var self = this; - var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleClass({ - options: this.options.scale, - lineArc: true, - width: this.chart.width, - height: this.chart.height, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - valuesCount: this.data.length, - data: this.data - }); + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, - helpers.bindEvents(this, this.options.events, this.events); + linkScales: function() { + // no scales for doughnut + }, - //Set up tooltip events on the chart - helpers.bindEvents(this, this.options.events, this.events); + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, - //Create a new bar for each piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { - dataset.metaData = []; - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Arc({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _index: index, - _model: {} - })); - }, this); - }, this); - - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); - - // Fit the scale before we animate - this.updateScaleRange(); - this.scale.calculateRange(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); - - // so that we animate nicely - this.resetElements(); - - // Update the chart with the latest data. - this.update(); - - }, - updateScaleRange: function() { - helpers.extend(this.scale, { - size: helpers.min([this.chart.width, this.chart.height]), - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2 - }); + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; }, - resetElements: function() { - var circumference = 1 / this.data.datasets[0].data.length * 2; - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - - var value = this.data.datasets[0].data[index]; - - helpers.extend(slice, { + addElements: function() { + this.getDataset().metaData = this.getDataset().metaData || []; + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, - innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, - - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) - }, }); - - slice.pivot(); }, this); }, - update: function(animationDuration) { - this.updateScaleRange(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); + reset: function() { + this.update(true); + }, + + update: function(reset) { Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + //this.chart.scale.setScaleSize(); + this.chart.scale.calculateRange(); + this.chart.scale.generateTicks(); + this.chart.scale.buildYLabels(); + + this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; + this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; + this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; + + this.getDataset().total = 0; + helpers.each(this.getDataset().data, function(value) { + this.getDataset().total += Math.abs(value); + }, this); - var circumference = 1 / this.data.datasets[0].data.length * 2; + this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index); + this.innerRadius = this.outerRadius - this.chart.radiusLength; - // Map new data to data points - helpers.each(this.data.datasets[0].metaData, function(slice, index) { + helpers.each(this.getDataset().metaData, function(arc, index) { - var value = this.data.datasets[0].data[index]; + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + innerRadius: 0, + outerRadius: 0, + startAngle: Math.PI * -0.5, + endAngle: Math.PI * -0.5, + + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) + }; + var circumference = 1 / this.getDataset().data.length * 2; var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; var endAngle = startAngle + (circumference * Math.PI); - helpers.extend(slice, { + console.log() + + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, _index: index, - _model: { - x: this.chart.width / 2, - y: this.chart.height / 2, + + // Desired view properties + _model: reset ? resetModel : { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, innerRadius: 0, - outerRadius: this.scale.getDistanceFromCenterForValue(value), + outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), startAngle: startAngle, endAngle: endAngle, - backgroundColor: slice.custom && slice.custom.backgroundColor ? slice.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].backgroundColor, index, this.options.elements.arc.backgroundColor), - hoverBackgroundColor: slice.custom && slice.custom.hoverBackgroundColor ? slice.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].hoverBackgroundColor, index, this.options.elements.arc.hoverBackgroundColor), - borderWidth: slice.custom && slice.custom.borderWidth ? slice.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderWidth, index, this.options.elements.arc.borderWidth), - borderColor: slice.custom && slice.custom.borderColor ? slice.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[0].borderColor, index, this.options.elements.arc.borderColor), + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - label: helpers.getValueAtIndexOrDefault(this.data.datasets[0].labels, index, this.data.datasets[0].labels[index]) + label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) }, }); - slice.pivot(); - - console.log(slice); + arc.pivot(); }, this); - - this.render(animationDuration); }, + draw: function(ease) { var easingDecimal = ease || 1; - - this.clear(); - - helpers.each(this.data.datasets[0].metaData, function(slice, index) { - slice.transition(easingDecimal).draw(); + helpers.each(this.getDataset().metaData, function(arc, index) { + arc.transition(easingDecimal).draw(); + console.log(arc); }, this); - - this.scale.draw(); - - this.tooltip.transition(easingDecimal).draw(); }, - events: function(e) { - - // If exiting chart - if (e.type == 'mouseout') { - return this; - } - - this.lastActive = this.lastActive || []; - - // Find Active Elements - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getSliceAtEvent(e); - case 'label': - return this.getSlicesAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, this.options.elements.arc.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, this.options.elements.arc.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, this.options.elements.arc.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 1); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; + setHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 1); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - - // Built in Tooltips - if (this.options.tooltips.enabled) { - - // The usual updates - this.tooltip.initialize(); + arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(arc._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, arc._model.borderWidth); + }, - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; + removeHoverStyle: function(arc) { + var dataset = this.chart.data.datasets[arc._datasetIndex]; + var index = arc._index; - helpers.extend(this.tooltip, { - _active: this.active, - }); + arc._model.backgroundColor = arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor); + arc._model.borderColor = arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor); + arc._model.borderWidth = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth); + }, - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } + calculateCircumference: function(value) { + if (this.getDataset().total > 0) { + return (Math.PI * 2) * (value / this.getDataset().total); + } else { + return 0; } + }, + updateScaleRange: function() { + helpers.extend(this.chart.scale, { + size: helpers.min([this.chart.width, this.chart.height]), + xCenter: this.chart.width / 2, + yCenter: this.chart.height / 2 + }); + }, + }); - // Hover animations - this.tooltip.pivot(); - - if (!this.animating) { - var changed; - - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); - - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - // Remember Last Active - this.lastActive = this.active; - return this; - }, - getSliceAtEvent: function(e) { - var elements = []; - var location = helpers.getRelativePosition(e); - - this.eachElement(function(slice, index) { - if (slice.inRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - }, - /*getSlicesAtEvent: function(e) { - var elements = []; + return; - var location = helpers.getRelativePosition(e); - this.eachElement(function(slice, index) { - if (slice.inLabelRange(location.x, location.y)) { - elements.push(slice); - } - }, this); - return elements; - },*/ - }); + Chart.Type.extend({}); }).call(this); (function() { "use strict"; - return; - var root = this, Chart = root.Chart, helpers = Chart.helpers; - Chart.Type.extend({ - name: "Radar", - defaults: { - - scale: { - type: "radialLinear", - }, - - elements: { - line: { - tension: 0, // no bezier in radar - } - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " - + Chart.defaults.radar = { + scale: { + type: "radialLinear", }, + elements: { + line: { + tension: 0, // no bezier in radar + } + }, + }; - initialize: function() { - - // Events - helpers.bindEvents(this, this.options.events, this.events); - - // Create a new line and its points for each dataset and piece of data - helpers.each(this.data.datasets, function(dataset, datasetIndex) { + Chart.controllers.radar = function(chart, datasetIndex) { + this.initialize.call(this, chart, datasetIndex); + }; - dataset.metaDataset = new Chart.Line({ - _chart: this.chart, - _datasetIndex: datasetIndex, - _points: dataset.metaData, - _loop: true - }); - dataset.metaData = []; + helpers.extend(Chart.controllers.radar.prototype, { - helpers.each(dataset.data, function(dataPoint, index) { - dataset.metaData.push(new Chart.Point({ - _datasetIndex: datasetIndex, - _index: index, - _chart: this.chart, - _model: { - x: 0, //xScale.getPixelForValue(null, index, true), - y: 0, //this.chartArea.bottom, - }, - })); + initialize: function(chart, datasetIndex) { + this.chart = chart; + this.index = datasetIndex; + this.linkScales(); + this.addElements(); + }, - }, this); - }, this); + linkScales: function() { + // No need. Single scale only + }, - // Build the scale. - this.buildScale(); + getDataset: function() { + return this.chart.data.datasets[this.index]; + }, - // Create tooltip instance exclusively for this chart with some defaults. - this.tooltip = new Chart.Tooltip({ - _chart: this.chart, - _data: this.data, - _options: this.options, - }, this); + getScaleForId: function(scaleID) { + return this.chart.scales[scaleID]; + }, - // Need to fit scales before we reset elements. - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + addElements: function() { - // Reset so that we animation from the baseline - this.resetElements(); + this.getDataset().metaData = this.getDataset().metaData || []; - // Update that shiz - this.update(); - }, - nextPoint: function(collection, index) { - return collection[index + 1] || collection[0]; - }, - previousPoint: function(collection, index) { - return collection[index - 1] || collection[collection.length - 1]; - }, - resetElements: function() { + this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _points: this.getDataset().metaData, + _loop: true + }); - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - helpers.extend(point, { - // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, + helpers.each(this.getDataset().data, function(value, index) { + this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, _index: index, - _scale: this.scale, - - // Desired view properties _model: { - x: this.scale.xCenter, - y: this.scale.yCenter, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + x: 0, //xScale.getPixelForValue(null, index, true), + y: 0, //this.chartArea.bottom, }, }); }, this); + }, - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { - var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, - point._model, - this.nextPoint(dataset, index)._model, - point._model.tension - ); - - point._model.controlPointPreviousX = this.scale.xCenter; - point._model.controlPointPreviousY = this.scale.yCenter; - point._model.controlPointNextX = this.scale.xCenter; - point._model.controlPointNextY = this.scale.yCenter; - - // Now pivot the point for animation - point.pivot(); - }, this); + reset: function() { + this.update(true); }, - update: function(animationDuration) { - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); + update: function(reset) { - // Update the lines - this.eachDataset(function(dataset, datasetIndex) { - var scaleBase; + var line = this.getDataset().metaDataset; + var points = this.getDataset().metaData; - if (this.scale.min < 0 && this.scale.max < 0) { - scaleBase = this.scale.getPointPositionForValue(0, this.scale.max); - } else if (this.scale.min > 0 && this.scale.max > 0) { - scaleBase = this.scale.getPointPositionForValue(0, this.scale.min); - } else { - scaleBase = this.scale.getPointPositionForValue(0, 0); - } + var scale = this.chart.scale; + var scaleBase; - helpers.extend(dataset.metaDataset, { - // Utility - _datasetIndex: datasetIndex, + scale.setScaleSize(); + scale.calculateRange(); + scale.generateTicks(); + scale.buildYLabels(); - // Data - _children: dataset.metaData, + if (scale.min < 0 && scale.max < 0) { + scaleBase = scale.getPointPositionForValue(0, scale.max); + } else if (scale.min > 0 && scale.max > 0) { + scaleBase = scale.getPointPositionForValue(0, scale.min); + } else { + scaleBase = scale.getPointPositionForValue(0, 0); + } - // Model - _model: { - // Appearance - tension: dataset.tension || this.options.elements.line.tension, - backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, - borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, - borderColor: dataset.borderColor || this.options.elements.line.borderColor, - fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default - skipNull: dataset.skipNull !== undefined ? dataset.skipNull : this.options.elements.line.skipNull, - drawNull: dataset.drawNull !== undefined ? dataset.drawNull : this.options.elements.line.drawNull, - - // Scale - scaleTop: this.scale.top, - scaleBottom: this.scale.bottom, - scaleZero: scaleBase, - }, - }); + helpers.extend(this.getDataset().metaDataset, { + // Utility + _datasetIndex: this.index, + // Data + _children: this.getDataset().metaData, + // Model + _model: { + // Appearance + tension: this.getDataset().tension || this.chart.options.elements.line.tension, + backgroundColor: this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor, + borderWidth: this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth, + borderColor: this.getDataset().borderColor || this.chart.options.elements.line.borderColor, + fill: this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill, // use the value from the this.getDataset() if it was provided. else fall back to the default + skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, + drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, - dataset.metaDataset.pivot(); + // Scale + scaleTop: scale.top, + scaleBottom: scale.bottom, + scaleZero: scaleBase, + }, }); - // Update the points - this.eachElement(function(point, index, dataset, datasetIndex) { - var pointPosition = this.scale.getPointPositionForValue(index, this.data.datasets[datasetIndex].data[index]); + this.getDataset().metaDataset.pivot(); + + // Update Points + helpers.each(points, function(point, index) { + var pointPosition = scale.getPointPositionForValue(index, this.getDataset().data[index]); helpers.extend(point, { // Utility - _chart: this.chart, - _datasetIndex: datasetIndex, + _datasetIndex: this.index, _index: index, // Desired view properties _model: { - x: pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: pointPosition.y, + x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: reset ? scale.yCenter : pointPosition.y, // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointRadius, index, this.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBackgroundColor, index, this.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderColor, index, this.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].pointBorderWidth, index, this.options.elements.point.borderWidth), - skip: this.data.datasets[datasetIndex].data[index] === null, + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: this.getDataset().data[index] === null, // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.data.datasets[datasetIndex].hitRadius, index, this.options.elements.point.hitRadius), + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), }, }); }, this); - // Update control points for the bezier curve - this.eachElement(function(point, index, dataset, datasetIndex) { + // Update bezier control points + helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( - this.previousPoint(dataset, index)._model, + helpers.previousItem(this.getDataset().metaData, index, true)._model, point._model, - this.nextPoint(dataset, index)._model, + helpers.nextItem(this.getDataset().metaData, index, true)._model, point._model.tension ); @@ -3558,19 +3175,19 @@ // Prevent the bezier going outside of the bounds of the graph // Cap puter bezier handles to the upper/lower scale bounds - if (controlPoints.next.y > this.chartArea.bottom) { - point._model.controlPointNextY = this.chartArea.bottom; - } else if (controlPoints.next.y < this.chartArea.top) { - point._model.controlPointNextY = this.chartArea.top; + if (controlPoints.next.y > this.chart.chartArea.bottom) { + point._model.controlPointNextY = this.chart.chartArea.bottom; + } else if (controlPoints.next.y < this.chart.chartArea.top) { + point._model.controlPointNextY = this.chart.chartArea.top; } else { point._model.controlPointNextY = controlPoints.next.y; } // Cap inner bezier handles to the upper/lower scale bounds - if (controlPoints.previous.y > this.chartArea.bottom) { - point._model.controlPointPreviousY = this.chartArea.bottom; - } else if (controlPoints.previous.y < this.chartArea.top) { - point._model.controlPointPreviousY = this.chartArea.top; + if (controlPoints.previous.y > this.chart.chartArea.bottom) { + point._model.controlPointPreviousY = this.chart.chartArea.bottom; + } else if (controlPoints.previous.y < this.chart.chartArea.top) { + point._model.controlPointPreviousY = this.chart.chartArea.top; } else { point._model.controlPointPreviousY = controlPoints.previous.y; } @@ -3579,202 +3196,50 @@ point.pivot(); }, this); - this.render(animationDuration); }, - buildScale: function() { - var self = this; - var ScaleConstructor = Chart.scaleService.getScaleConstructor(this.options.scale.type); - this.scale = new ScaleConstructor({ - options: this.options.scale, - height: this.chart.height, - width: this.chart.width, - xCenter: this.chart.width / 2, - yCenter: this.chart.height / 2, - ctx: this.chart.ctx, - labels: this.data.labels, - valuesCount: this.data.datasets[0].data.length, - data: this.data, - }); - - this.scale.setScaleSize(); - this.scale.calculateRange(); - this.scale.generateTicks(); - this.scale.buildYLabels(); - }, draw: function(ease) { var easingDecimal = ease || 1; - this.clear(); - - // Draw all the scales - this.scale.draw(this.chartArea); - - // reverse for-loop for proper stacking - for (var i = this.data.datasets.length - 1; i >= 0; i--) { - - var dataset = this.data.datasets[i]; - - // Transition Point Locations - helpers.each(dataset.metaData, function(point, index) { - point.transition(easingDecimal); - }, this); - // Transition and Draw the line - dataset.metaDataset.transition(easingDecimal).draw(); + // Transition Point Locations + helpers.each(this.getDataset().metaData, function(point, index) { + point.transition(easingDecimal); + }, this); - // Draw the points - helpers.each(dataset.metaData, function(point) { - point.draw(); - }); - } + // Transition and Draw the line + this.getDataset().metaDataset.transition(easingDecimal).draw(); - // Finally draw the tooltip - this.tooltip.transition(easingDecimal).draw(); + // Draw the points + helpers.each(this.getDataset().metaData, function(point) { + point.draw(); + }); }, - events: function(e) { - - this.lastActive = this.lastActive || []; - - // Find Active Elements - // If exiting chart - if (e.type == 'mouseout') { - this.active = []; - } else { - this.active = function() { - switch (this.options.hover.mode) { - case 'single': - return this.getElementAtEvent(e); - case 'label': - return this.getElementsAtEvent(e); - case 'dataset': - return this.getDatasetAtEvent(e); - default: - return e; - } - }.call(this); - } - - // On Hover hook - if (this.options.hover.onHover) { - this.options.hover.onHover.call(this, this.active); - } - - if (e.type == 'mouseup' || e.type == 'click') { - if (this.options.onClick) { - this.options.onClick.call(this, e, this.active); - } - } - - var dataset; - var index; - // Remove styling for last active (even if it may still be active) - if (this.lastActive.length) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.lastActive[0]._datasetIndex]; - index = this.lastActive[0]._index; - - this.lastActive[0]._model.radius = this.lastActive[0].custom && this.lastActive[0].custom.radius ? this.lastActive[0].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[0]._model.backgroundColor = this.lastActive[0].custom && this.lastActive[0].custom.backgroundColor ? this.lastActive[0].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[0]._model.borderColor = this.lastActive[0].custom && this.lastActive[0].custom.borderColor ? this.lastActive[0].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[0]._model.borderWidth = this.lastActive[0].custom && this.lastActive[0].custom.borderWidth ? this.lastActive[0].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - break; - case 'label': - for (var i = 0; i < this.lastActive.length; i++) { - dataset = this.data.datasets[this.lastActive[i]._datasetIndex]; - index = this.lastActive[i]._index; - - this.lastActive[i]._model.radius = this.lastActive[i].custom && this.lastActive[i].custom.radius ? this.lastActive[i].custom.pointRadius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, this.options.elements.point.radius); - this.lastActive[i]._model.backgroundColor = this.lastActive[i].custom && this.lastActive[i].custom.backgroundColor ? this.lastActive[i].custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, this.options.elements.point.backgroundColor); - this.lastActive[i]._model.borderColor = this.lastActive[i].custom && this.lastActive[i].custom.borderColor ? this.lastActive[i].custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, this.options.elements.point.borderColor); - this.lastActive[i]._model.borderWidth = this.lastActive[i].custom && this.lastActive[i].custom.borderWidth ? this.lastActive[i].custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.options.elements.point.borderWidth); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in hover styling - if (this.active.length && this.options.hover.mode) { - switch (this.options.hover.mode) { - case 'single': - dataset = this.data.datasets[this.active[0]._datasetIndex]; - index = this.active[0]._index; - - this.active[0]._model.radius = this.active[0].custom && this.active[0].custom.hoverRadius ? this.active[0].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[0]._model.radius + 2); - this.active[0]._model.backgroundColor = this.active[0].custom && this.active[0].custom.hoverBackgroundColor ? this.active[0].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[0]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderColor = this.active[0].custom && this.active[0].custom.hoverBorderColor ? this.active[0].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[0]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[0]._model.borderWidth = this.active[0].custom && this.active[0].custom.hoverBorderWidth ? this.active[0].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[0]._model.borderWidth + 2); - break; - case 'label': - for (var i = 0; i < this.active.length; i++) { - dataset = this.data.datasets[this.active[i]._datasetIndex]; - index = this.active[i]._index; - - this.active[i]._model.radius = this.active[i].custom && this.active[i].custom.hoverRadius ? this.active[i].custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.active[i]._model.radius + 2); - this.active[i]._model.backgroundColor = this.active[i].custom && this.active[i].custom.hoverBackgroundColor ? this.active[i].custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(this.active[i]._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderColor = this.active[i].custom && this.active[i].custom.hoverBorderColor ? this.active[i].custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(this.active[i]._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - this.active[i]._model.borderWidth = this.active[i].custom && this.active[i].custom.hoverBorderWidth ? this.active[i].custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, this.active[i]._model.borderWidth + 2); - } - break; - case 'dataset': - break; - default: - // Don't change anything - } - } - - // Built in Tooltips - if (this.options.tooltips.enabled) { - // The usual updates - this.tooltip.initialize(); - - // Active - if (this.active.length) { - this.tooltip._model.opacity = 1; - - helpers.extend(this.tooltip, { - _active: this.active, - }); + setHoverStyle: function(point) { + // Point + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; - this.tooltip.update(); - } else { - // Inactive - this.tooltip._model.opacity = 0; - } - } + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); + point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + }, - // Hover animations - this.tooltip.pivot(); + removeHoverStyle: function(point) { + var dataset = this.chart.data.datasets[point._datasetIndex]; + var index = point._index; - if (!this.animating) { - var changed; + point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius); + point._model.backgroundColor = point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor); + point._model.borderColor = point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor); + point._model.borderWidth = point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth); + } - helpers.each(this.active, function(element, index) { - if (element !== this.lastActive[index]) { - changed = true; - } - }, this); + }); - // If entering, leaving, or changing elements, animate the change via pivot - if ((!this.lastActive.length && this.active.length) || - (this.lastActive.length && !this.active.length) || - (this.lastActive.length && this.active.length && changed)) { - this.stop(); - this.render(this.options.hover.animationDuration); - } - } - // Remember Last Active - this.lastActive = this.active; - return this; - }, - }); }).call(this); (function() { @@ -4112,6 +3577,7 @@ }, // scale numbers + reverse: false, beginAtZero: false, override: null, @@ -4211,6 +3677,16 @@ // range of the scale this.max = helpers.max(this.ticks); this.min = helpers.min(this.ticks); + + if (this.options.reverse) { + this.ticks.reverse(); + + this.start = this.max; + this.end = this.min; + } else { + this.start = this.min; + this.end = this.max; + } }, buildLabels: function() { // We assume that this has been run after ticks have been generated. We try to figure out @@ -4241,13 +3717,13 @@ // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined var pixel; - var range = this.max - this.min; + var range = this.end - this.start; if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.min)); + pixel = this.left + (this.width / range * (value - this.start)); } else { // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.min)); + pixel = this.bottom - (this.height / range * (value - this.start)); } return pixel; @@ -4658,7 +4134,7 @@ display: true, //Boolean - Whether to animate scaling the chart from the centre - animate: false, + animate: true, lineArc: false, @@ -4717,7 +4193,13 @@ var LinearRadialScale = Chart.Element.extend({ initialize: function() { + this.height = this.chart.height; + this.width = this.chart.width; + this.xCenter = this.chart.width / 2; + this.yCenter = this.chart.height / 2; this.size = helpers.min([this.height, this.width]); + this.valuesCount = this.data.labels.length; + this.labels = this.data.labels; this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, update: function() { @@ -5118,7 +4600,7 @@ borderWidth: 2 }; - Chart.Arc = Chart.Element.extend({ + Chart.elements.Arc = Chart.Element.extend({ inLabelRange: function(mouseX) { var vm = this._view; diff --git a/Chart.min.js b/Chart.min.js index 40b369014f2..f79fbcfa3bf 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var n=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},a=this.width=n(t.canvas,"Width")||t.canvas.width,s=this.height=n(t.canvas,"Height")||t.canvas.height;return t.canvas.width=a,t.canvas.height=s,a=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var n=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var a;for(a=0;a=a[n].length||!a[n][i].type?a[n].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==a[n][i].type?a[n][i]=e.configMerge(a[n][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):a[n][i]=e.configMerge(a[n][i],t)}):(a[n]=[],e.each(t,function(t){a[n].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):a.hasOwnProperty(n)&&"object"==typeof a[n]&&null!==a[n]&&"object"==typeof t?a[n]=e.configMerge(a[n],t):a[n]=t)}),a},e.getValueAtIndexOrDefault=function(t,i,n){return t?e.isArray(t)&&i=0;n--){var a=t[n];if(e(a))return a}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},n=function(){this.constructor=i};return n.prototype=e.prototype,i.prototype=new n,i.extend=s,t&&a(i.prototype,t),i.__super__=e.prototype,i}),o=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,n=e.y-t.y,a=Math.sqrt(i*i+n*n),s=Math.atan2(n,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:a}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,n){var a=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),o=n*a/(a+s),r=n*s/(a+s);return{previous:{x:e.x-o*(i.x-t.x),y:e.y-o*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,n,a){var s=2,o=Math.floor(e/(1.5*i)),r=s>=o,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!n?d-=.5:u+=.5);for(var g=Math.abs(u-d),f=c(g),p=Math.ceil(u/(1*Math.pow(10,f)))*Math.pow(10,f),v=n?0:Math.floor(d/(1*Math.pow(10,f)))*Math.pow(10,f),m=p-v,b=Math.pow(10,f),x=Math.round(m/b);(x>o||o>2*x)&&!r;)if(x>o)b*=2,x=Math.round(m/b),x%1!==0&&(r=!0);else if(a&&f>=0){if(b/2%1!==0)break;b/=2,x=Math.round(m/b)}else b/=2,x=Math.round(m/b);return r&&(x=s,b=m/x),{steps:x,stepValue:b,min:v,max:v+x*b}},e.niceNum=function(t,i){var n,a=Math.floor(e.log10(t)),s=t/Math.pow(10,a);return n=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,n*Math.pow(10,a)},e.template=function(t,e){function i(t,e){var i=/\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('');"):n[t]=n[t];return e?i(e):i}if(t instanceof Function)return t(e);var n={};return i(t,e)}),d=(e.generateLabels=function(t,e,n,a){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:n+a*(i+1)})}),s},e.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 e=1.70158,i=0,n=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),nt?-.5*n*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):n*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),f=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,n,a,s){var o=0,r=d[i]||d.linear,h=function(){o++;var i=o/e,l=r(i);t.call(s,l,i,o),n.call(s,l,i),e>o?s.animationFrame=g(h):a.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,n=t.originalEvent||t,a=t.currentTarget||t.srcElement,s=a.getBoundingClientRect();return n.touches?(e=n.touches[0].clientX-s.left,i=n.touches[0].clientY-s.top):(e=n.clientX-s.left,i=n.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),p=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=o},v=(e.bindEvents=function(t,e,n){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){n.apply(t,arguments)},f(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){p(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-left"))+parseInt(v(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(v(e,"padding-bottom"))+parseInt(v(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,n=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=n+"px",e.canvas.height=n*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,n){t.font=e;var a=0;return i(n,function(e){var i=t.measureText(e).width;a=i>a?i:a}),a},e.drawRoundedRectangle=function(t,e,i,n,a,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+a-s),t.quadraticCurveTo(e+n,i+a,e+n-s,i+a),t.lineTo(e+s,i+a),t.quadraticCurveTo(e,i+a,e,i+a-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,n){if("_"!==n[0]&&this._model.hasOwnProperty(n))if(this._view[n])if(this._model[n]===this._view[n]);else if("string"==typeof i)try{var a=e.color(this._start[n]).mix(e.color(this._model[n]),t);this._view[n]=a.rgbString()}catch(s){this._view[n]=i}else if("number"==typeof i){var o=void 0!==this._start[n]?this._start[n]:0;this._view[n]=(this._model[n]-o)*t+o}else this._view[n]=i;else"number"==typeof i?this._view[n]=i*t:this._view[n]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,n){n||(t.animating=!0);for(var a=0;a1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var n=0;nthis.animations[n].animationObject.numSteps&&(this.animations[n].animationObject.currentStep=this.animations[n].animationObject.numSteps),this.animations[n].animationObject.render(this.animations[n].chartInstance,this.animations[n].animationObject),this.animations[n].animationObject.currentStep==this.animations[n].animationObject.numSteps&&(this.animations[n].chartInstance.animating=!1,this.animations.splice(n,1),n--);var a=Date.now(),s=a-t-this.frameDuration,o=s/this.frameDuration;o>1&&(this.dropFrames+=o),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildScales(),this.buildControllers(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),n=this.options.maintainAspectRatio?i/this.chart.aspectRatio:getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=n,e.retinaScale(this.chart),this},buildScales:function(){this.scales={},e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var n=e.easingEffects[i.easing],a=i.currentStep/i.numSteps,s=n(a);t.draw(s,a,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t);return e.each(this.data.datasets,function(t,n){e.each(t.metaData,function(t,e){return this.chart.data.datasets[n].metaData[elementIndex].inRange(i.x,i.y)?(t.push(this.chart.data.datasets[n].metaData[elementIndex]),t):void 0},this)},this),[]},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),n=[];return e.each(this.data.datasets,function(t,a){e.each(t.metaData,function(t,e){t.inRange(i.x,i.y)&&n.push(t)},this)},this),n},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),n=[],a=0;a30?5:2,s=n>30?5:2;if(t){var o=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=n/2;c-=2*a,u-=2*s;var d=(e-c)/(o.length+r.length),g=(n-u)/(h.length+l.length),f=[],p=function(t){var e=t.fit(d,u);f.push({horizontal:!1,minSize:e,scale:t})},v=function(t){var e=t.fit(c,g);f.push({horizontal:!0,minSize:e,scale:t})};i.each(o,p),i.each(r,p),i.each(h,v),i.each(l,v);var m=n-2*s,b=e-2*a;i.each(f,function(t){t.horizontal?m-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t});e&&t.fit(e.minSize.width,m)},y=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),n={left:w,right:_,top:0,bottom:0};e&&t.fit(b,e.minSize.height,n)},w=a,_=a,k=s,C=s;i.each(o,x),i.each(r,x),i.each(o,function(t){w+=t.width}),i.each(r,function(t){_+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){k+=t.height}),i.each(l,function(t){C+=t.height}),i.each(o,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),n={left:0,right:0,top:k,bottom:C};e&&t.fit(e.minSize.width,m,n)}),i.each(r,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),n={left:0,right:0,top:k,bottom:C};e&&t.fit(e.minSize.width,m,n)});var S=a,P=s,A=function(t){t.left=S,t.right=S+t.width,t.top=k,t.bottom=k+m,S=t.right},M=function(t){t.left=w,t.right=w+b,t.top=P,t.bottom=P+t.height,P=t.bottom};i.each(o,A),i.each(h,M),S+=b,P+=m,i.each(r,A),i.each(l,M),t.chartArea={left:w,top:k,right:w+b,bottom:k+m}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var n,a,s=[],o=[],r=this._data.datasets.length-1;r>=0&&(n=this._data.datasets[r].metaData,a=i.indexOf(n,this._active[0]),-1===a);r--);var h=function(t){var e,n,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[a]&&e[a].hasValue()&&c.push(e[a])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),o.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),n=i.max(u),{x:h>this._chart.width/2?h:n,y:(l+r)/2}}.call(this,a);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:o,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var n=e.caretPadding||2,a=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,o=s+e.caretHeight+n;e.x+a/2>this._chart.width?e.xAlign="left":e.x-a/2<0&&(e.xAlign="right"),e.y-o<0&&(e.yAlign="below");var r=e.x-a/2,h=e.y-o;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-n),t.lineTo(e.x+e.caretHeight,e.y-(n+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(n+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+n+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+n),t.lineTo(e.x+e.caretHeight,e.y+n+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+n+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-a+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,a,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+a/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(n,a){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(n,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(a+1)),t.fillStyle=i.color(e.legendColors[a].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(a+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[a].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(a+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(a,s){var o;o=n.min<0&&n.max<0?n.getPixelForValue(n.max):n.min>0&&n.max>0?n.getPixelForValue(n.min):n.getPixelForValue(0),i.extend(a,{_chart:this.chart.chart,_xScale:e,_yScale:n,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?o:n.getPixelForValue(this.getDataset().data[s]),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth)}}),a.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index; -t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,n,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,n,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,n,t._model.borderWidth)},removeHoverStyle:function(t){}})}.call(this),function(){"use strict";return}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,n=this.getDataset().metaDataset,a=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),o=this.getScaleForId(this.getDataset().xAxisID);e=s.min<0&&s.max<0?s.getPixelForValue(s.max):s.min>0&&s.max>0?s.getPixelForValue(s.min):s.getPixelForValue(0),i.extend(n,{_scale:s,_datasetIndex:this.index,_children:a,_model:{tension:n.custom&&n.custom.tension?n.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:n.custom&&n.custom.backgroundColor?n.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:n.custom&&n.custom.borderWidth?n.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:n.custom&&n.custom.borderColor?n.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:n.custom&&n.custom.fill?n.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),n.pivot(),i.each(a,function(t,e){i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:s,_datasetIndex:this.index,_index:e,_model:{x:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:s.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var n=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=n.previous.x,t._model.controlPointNextX=n.next.x,n.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:n.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:n.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},a=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,n){if(this.isHorizontal()){var a=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=a/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),o=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&n&&(o+=s/2),this.left+Math.round(o)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var n=this.calculateBaseWidth(),a=this.getPixelForValue(null,i,e,!0)-n/2,s=this.calculateBarWidth(t);return this.options.stacked?a+s/2:a+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var n=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=n;var a,s,o=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=o/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,n,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),a=h*o,s=h*r,a+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=a+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,n){this.calculateLabelRotation(e,n);var a={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),o=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(a.width=t,this.width=t):this.options.display&&(a.width=Math.min(o+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*o+1.5*this.options.labels.fontSize;a.height=Math.min(r,e)}else this.options.display&&(a.width=Math.min(o+6,t));return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var n="bottom"==this.options.position?this.top:this.bottom-10,a="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(o,r){var h=this.getPixelForValue(o,r,null,!1),l=this.getPixelForValue(o,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,n),this.ctx.lineTo(h,a)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(o,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",a,n)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},a=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var n=0;n<=this.options.override.steps;++n){var a=this.options.override.start+n*this.options.override.stepWidth;ticks.push(a)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var o=i.sign(this.min),r=i.sign(this.max);0>o&&0>r?this.max=0:o>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,n){var a;this.options.labels.userCallback?a=this.options.labels.userCallback(t,e,n):this.options.labels.template&&(a=i.template(this.options.labels.template,{value:t})),this.labels.push(a?a:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.max-this.min;return e=this.isHorizontal()?this.left+this.width/i*(t-this.min):this.bottom-this.height/i*(t-this.min)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(n){(this.isHorizontal()?n.xAxisID===this.id:n.yAxisID===this.id)&&i.each(n.data,function(i,n){var a=this.getRightValue(i);t[n]=t[n]||0,e[n]=e[n]||0,this.options.relativePoints?t[n]=100:0>a?e[n]+=a:t[n]+=a},this)},this);var n=t.concat(e);this.min=i.min(n),this.max=i.max(n)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var n=this.getRightValue(t);if(this.options.stacked){for(var a=0,s=0,o=0;i>o;++o)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]:a+=this.data.datasets[o].data[e];return 0>n?this.getPixelForValue(s+n):this.getPixelForValue(a+n)}return this.getPixelForValue(n)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var n=this.data.datasets[t].data[e];if(0>n)for(var a=0;t>a;a++)this.data.datasets[a].yAxisID===this.id&&(i+=this.data.datasets[a].data[e]<0?this.data.datasets[a].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var n=0,a=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?a+=this.data.datasets[s].data[e]||0:n+=this.data.datasets[s].data[e]||0;return 0>i?this.getPixelForValue(a+i):this.getPixelForValue(n+i)}for(var o=0,r=t;rr?n.width+=r:n.width=t}}return this.width=n.width,this.height=n.height,n},draw:function(t){if(this.options.display){var e,n;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,n=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var a="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(o,r){var h=this.getPixelForValue(o);0===o||!n&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var o;"top"==this.options.position?(o=this.bottom-10,this.ctx.textBaseline="bottom"):(o=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,o)},this)}}else{if(this.options.gridLines.show){e=!0,n=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(a,s){var o=this.getPixelForValue(a);0===a||!n&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),o+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,o),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,o),this.ctx.lineTo(t.right,o)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",a,n)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,n={display:!0,animate:!1,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},a=e.Element.extend({initialize:function(){this.size=i.min([this.height,this.width]),this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var n=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(n=Math.max(2,n),this.options.beginAtZero){var a=i.sign(this.min),s=i.sign(this.max);0>a&&0>s?this.max=0:a>0&&s>0&&(this.min=0)}for(var o=i.niceNum(this.max-this.min,!1),r=i.niceNum(o/(n-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,n){var a;this.options.labels.userCallback?a=this.options.labels.userCallback(t,e,n):this.options.labels.template&&(a=i.template(this.options.labels.template,{value:t})),this.yLabels.push(a?a:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,n,a,s,o,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),f=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ef&&(f=t.x+a,s=e),t.x-af&&(f=t.x+n,s=e):e>this.valuesCount/2&&t.x-n0){var a=this.getDistanceFromCenterForValue(this.ticks[n]),s=this.yCenter-a;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var o=0;o=0;e--){if(this.options.angleLines.show){var n=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(n.x,n.y),t.stroke(),t.closePath()}var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,o=this.labels.length/2,r=o/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===o?t.textAlign="center":o>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],a.x,a.y)}}}}});e.scaleService.registerScaleType("radialLinear",a,n)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;for(o=0;o=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) +}}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?2*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), +i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -17,7 +18,7 @@ t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverB * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?n.startAngle-2*Math.PI:n.startAngle,o=n.endAngle<-.5*Math.PI?n.endAngle+2*Math.PI:n.endAngle>1.5*Math.PI?n.endAngle-2*Math.PI:n.endAngle,r=a.angle>=s&&a.angle<=o,h=a.distance>=n.innerRadius&&a.distance<=n.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.elements.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?a.startAngle-2*Math.PI:a.startAngle,n=a.endAngle<-.5*Math.PI?a.endAngle+2*Math.PI:a.endAngle>1.5*Math.PI?a.endAngle-2*Math.PI:a.endAngle,r=o.angle>=s&&o.angle<=n,h=o.distance>=a.innerRadius&&o.distance<=a.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -26,7 +27,7 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,n=this._chart.ctx,a=this._children[0],s=this._children[this._children.length-1];i.each(this._children,function(e,a){var s=i.previousItem(this._children,a),o=i.nextItem(this._children,a);return 0===a?void n.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(n.lineTo(s._view.x,e._view.y),n.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(n.moveTo(e._view.x,s._view.y),n.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?n.moveTo(e._view.x,e._view.y):t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):n.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!a._view.skip?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,a._view.controlPointPreviousX,a._view.controlPointPreviousY,a._view.x,a._view.y):n.lineTo(a._view.x,a._view.y)),this._children.length>0&&t.fill&&(n.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),n.lineTo(this._children[0]._view.x,t.scaleZero),n.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,n.closePath(),n.fill()),n.lineWidth=t.borderWidth||e.defaults.global.defaultColor,n.strokeStyle=t.borderColor||e.defaults.global.defaultColor,n.beginPath(),i.each(this._children,function(e,a){var s=i.previousItem(this._children,a),o=i.nextItem(this._children,a);return 0===a?void n.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(n.moveTo(s._view.x,e._view.y),void n.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(n.moveTo(e._view.x,s._view.y),void n.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void n.moveTo(e._view.x,e._view.y):void(t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):n.lineTo(e._view.x,e._view.y))},this),this._loop&&!a._view.skip&&(t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,a._view.controlPointPreviousX,a._view.controlPointPreviousY,a._view.x,a._view.y):n.lineTo(a._view.x,a._view.y)),n.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,o=this._children[0],s=this._children[this._children.length-1];i.each(this._children,function(e,o){var s=i.previousItem(this._children,o),n=i.nextItem(this._children,o);return 0===o?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(s._view.x,e._view.y),a.moveTo(n._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,s._view.y),a.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):a.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,o){var s=i.previousItem(this._children,o),n=i.nextItem(this._children,o);return 0===o?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(s._view.x,e._view.y),void a.moveTo(n._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,s._view.y),void a.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):a.lineTo(o._view.x,o._view.y)),a.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -35,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,n=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,n=e.x-i,a=e.x+i,s=e.base-(e.base-e.y),o=e.borderWidth/2;e.borderWidth&&(n+=o,a-=o,s+=o),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(n,e.base),t.lineTo(n,s),t.lineTo(a,s),t.lineTo(a,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,n=this.alpha()-t.alpha(),a=((i*n==-1?i:(i+n)/(1+i*n))+1)/2,s=1-a,o=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),n=(r+h)/2,i=h==r?0:.5>=n?l/(h+r):l/(2-h-r),[e,100*i,100*n]}function a(t){var e,i,n,a=t[0],s=t[1],o=t[2],r=Math.min(a,s,o),h=Math.max(a,s,o),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:a==h?e=(s-o)/l:s==h?e=2+(o-a)/l:o==h&&(e=4+(a-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),n=h/255*1e3/10,[e,i,n]}function s(t){var e=t[0],i=t[1],a=t[2],s=n(t)[0],o=1/255*Math.min(e,Math.min(i,a)),a=1-1/255*Math.max(e,Math.max(i,a));return[s,100*o,100*a]}function o(t){var e,i,n,a,s=t[0]/255,o=t[1]/255,r=t[2]/255;return a=Math.min(1-s,1-o,1-r),e=(1-s-a)/(1-a)||0,i=(1-o-a)/(1-a)||0,n=(1-r-a)/(1-a)||0,[100*e,100*i,100*n,100*a]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*e+.3576*i+.1805*n,s=.2126*e+.7152*i+.0722*n,o=.0193*e+.1192*i+.9505*n;return[100*a,100*s,100*o]}function c(t){var e,i,n,a=l(t),s=a[0],o=a[1],r=a[2];return s/=95.047,o/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,i=500*(s-o),n=200*(o-r),[e,i,n]}function u(t){return O(c(t))}function d(t){var e,i,n,a,s,o=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,a=[0,0,0];for(var l=0;3>l;l++)n=o+1/3*-(l-1),0>n&&n++,n>1&&n--,s=1>6*n?e+6*(i-e)*n:1>2*n?i:2>3*n?e+(i-e)*(2/3-n)*6:e,a[l]=255*s;return a}function f(t){var e,i,n=t[0],a=t[1]/100,s=t[2]/100;return s*=2,a*=1>=s?s:2-s,i=(s+a)/2,e=2*a/(s+a),[n,100*e,100*i]}function p(t){return s(d(t))}function v(t){return o(d(t))}function m(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,n=t[2]/100,a=Math.floor(e)%6,s=e-Math.floor(e),o=255*n*(1-i),r=255*n*(1-i*s),h=255*n*(1-i*(1-s)),n=255*n;switch(a){case 0:return[n,h,o];case 1:return[r,n,o];case 2:return[o,n,h];case 3:return[o,r,n];case 4:return[h,o,n];case 5:return[n,o,r]}}function y(t){var e,i,n=t[0],a=t[1]/100,s=t[2]/100;return i=(2-a)*s,e=a*s,e/=1>=i?i:2-i,e=e||0,i/=2,[n,100*e,100*i]}function w(t){return s(x(t))}function _(t){return o(x(t))}function k(t){return h(x(t))}function C(t){var e,i,n,a,s=t[0]/360,o=t[1]/100,h=t[2]/100,l=o+h;switch(l>1&&(o/=l,h/=l),e=Math.floor(6*s),i=1-h,n=6*s-e,0!=(1&e)&&(n=1-n),a=o+n*(i-o),e){default:case 6:case 0:r=i,g=a,b=o;break;case 1:r=a,g=i,b=o;break;case 2:r=o,g=i,b=a;break;case 3:r=o,g=a,b=i;break;case 4:r=a,g=o,b=i;break;case 5:r=i,g=o,b=a}return[255*r,255*g,255*b]}function S(t){return n(C(t))}function P(t){return a(C(t))}function A(t){return o(C(t))}function M(t){return h(C(t))}function D(t){var e,i,n,a=t[0]/100,s=t[1]/100,o=t[2]/100,r=t[3]/100;return e=1-Math.min(1,a*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),n=1-Math.min(1,o*(1-r)+r),[255*e,255*i,255*n]}function I(t){return n(D(t))}function F(t){return a(D(t))}function z(t){return s(D(t))}function L(t){return h(D(t))}function T(t){var e,i,n,a=t[0]/100,s=t[1]/100,o=t[2]/100;return e=3.2406*a+-1.5372*s+o*-.4986,i=a*-.9689+1.8758*s+.0415*o,n=.0557*a+s*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),n=Math.min(Math.max(0,n),1),[255*e,255*i,255*n]}function R(t){var e,i,n,a=t[0],s=t[1],o=t[2];return a/=95.047,s/=100,o/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*s-16,i=500*(a-s),n=200*(s-o),[e,i,n]}function W(t){return O(R(t))}function V(t){var e,i,n,a,s=t[0],o=t[1],r=t[2];return 8>=s?(i=100*s/903.3,a=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),a=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(o/500+a-16/116)/7.787:95.047*Math.pow(o/500+a,3),n=.008859>=n/108.883?n=108.883*(a-r/200-16/116)/7.787:108.883*Math.pow(a-r/200,3),[e,i,n]}function O(t){var e,i,n,a=t[0],s=t[1],o=t[2];return e=Math.atan2(o,s),i=360*e/2/Math.PI,0>i&&(i+=360),n=Math.sqrt(s*s+o*o),[a,n,i]}function N(t){return T(V(t))}function H(t){var e,i,n,a=t[0],s=t[1],o=t[2];return n=o/360*2*Math.PI,e=s*Math.cos(n),i=s*Math.sin(n),[a,e,i]}function B(t){return V(H(t))}function E(t){return N(H(t))}function q(t){return $[t]}function j(t){return n(q(t))}function Y(t){return a(q(t))}function X(t){return s(q(t))}function Q(t){return o(q(t))}function Z(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:n,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:f,hsl2hwb:p,hsl2cmyk:v,hsl2keyword:m,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:_,hsv2keyword:k,hwb2rgb:C,hwb2hsl:S,hwb2hsv:P,hwb2cmyk:A,hwb2keyword:M,cmyk2rgb:D,cmyk2hsl:I,cmyk2hsv:F,cmyk2hwb:z,cmyk2keyword:L,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:Z,keyword2xyz:U,xyz2rgb:T,xyz2lab:R,xyz2lch:W,lab2xyz:V,lab2rgb:N,lab2lch:O,lch2lab:H,lch2xyz:B,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var n=t("./conversions"),a=function(){return new l};for(var s in n){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),n[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),r=o[1],h=o[2];a[r]=a[r]||{},a[r][h]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=n[t](e);if("string"==typeof i||void 0===i)return i;for(var a=0;ae||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),a=Math.round(t[2]/255*100);return"rgb("+i+"%, "+n+"%, "+a+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),a=Math.round(t[2]/255*100);return"rgba("+i+"%, "+n+"%, "+a+"%, "+(e||t[3]||1)+")"}function f(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function v(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function m(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:n,getHsla:a,getRgb:o,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:f,hslaString:p,hwbString:v,keyword:m};var w={};for(var _ in y)w[y[_]]=_},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,o=e.x+i,s=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,o-=n,s+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,s),t.lineTo(o,s),t.lineTo(o,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),o=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,s=1-o,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function o(t){var e,i,a,o=t[0],s=t[1],n=t[2],r=Math.min(o,s,n),h=Math.max(o,s,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:o==h?e=(s-n)/l:s==h?e=2+(n-o)/l:n==h&&(e=4+(o-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],i=t[1],o=t[2],s=a(t)[0],n=1/255*Math.min(e,Math.min(i,o)),o=1-1/255*Math.max(e,Math.max(i,o));return[s,100*n,100*o]}function n(t){var e,i,a,o,s=t[0]/255,n=t[1]/255,r=t[2]/255;return o=Math.min(1-s,1-n,1-r),e=(1-s-o)/(1-o)||0,i=(1-n-o)/(1-o)||0,a=(1-r-o)/(1-o)||0,[100*e,100*i,100*a,100*o]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var o=.4124*e+.3576*i+.1805*a,s=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*o,100*s,100*n]}function c(t){var e,i,a,o=l(t),s=o[0],n=o[1],r=o[2];return s/=95.047,n/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(s-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,o,s,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,o=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,s=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,o[l]=255*s;return o}function m(t){var e,i,a=t[0],o=t[1]/100,s=t[2]/100;return s*=2,o*=1>=s?s:2-s,i=(s+o)/2,e=2*o/(s+o),[a,100*e,100*i]}function f(t){return s(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,o=Math.floor(e)%6,s=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*s),h=255*a*(1-i*(1-s)),a=255*a;switch(o){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],o=t[1]/100,s=t[2]/100;return i=(2-o)*s,e=o*s,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return s(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,o,s=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*s),i=1-h,a=6*s-e,0!=(1&e)&&(a=1-a),o=n+a*(i-n),e){default:case 6:case 0:r=i,g=o,b=n;break;case 1:r=o,g=i,b=n;break;case 2:r=n,g=i,b=o;break;case 3:r=n,g=o,b=i;break;case 4:r=o,g=n,b=i;break;case 5:r=i,g=n,b=o}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return o(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function M(t){var e,i,a,o=t[0]/100,s=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,o*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return a(M(t))}function W(t){return o(M(t))}function R(t){return s(M(t))}function V(t){return h(M(t))}function O(t){var e,i,a,o=t[0]/100,s=t[1]/100,n=t[2]/100;return e=3.2406*o+-1.5372*s+n*-.4986,i=o*-.9689+1.8758*s+.0415*n,a=.0557*o+s*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function F(t){var e,i,a,o=t[0],s=t[1],n=t[2];return o/=95.047,s/=100,n/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*s-16,i=500*(o-s),a=200*(s-n),[e,i,a]}function z(t){return B(F(t))}function L(t){var e,i,a,o,s=t[0],n=t[1],r=t[2];return 8>=s?(i=100*s/903.3,o=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),o=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+o-16/116)/7.787:95.047*Math.pow(n/500+o,3),a=.008859>=a/108.883?a=108.883*(o-r/200-16/116)/7.787:108.883*Math.pow(o-r/200,3),[e,i,a]}function B(t){var e,i,a,o=t[0],s=t[1],n=t[2];return e=Math.atan2(n,s),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(s*s+n*n),[o,a,i]}function T(t){return O(L(t))}function N(t){var e,i,a,o=t[0],s=t[1],n=t[2];return a=n/360*2*Math.PI,e=s*Math.cos(a),i=s*Math.sin(a),[o,e,i]}function H(t){return L(N(t))}function E(t){return T(N(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return o(q(t))}function X(t){return s(q(t))}function Q(t){return n(q(t))}function Z(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:o,rgb2hwb:s,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:M,cmyk2hsl:I,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:Z,keyword2xyz:U,xyz2rgb:O,xyz2lab:F,xyz2lch:z,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:N,lch2xyz:H,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),o=function(){return new l};for(var s in a){o[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(s);var n=/(\w+)2(\w+)/.exec(s),r=n[1],h=n[2];o[r]=o[r]||{},o[r][h]=o[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var o=0;oe||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),o=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+o+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),o=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+o+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:o,getRgb:n,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From cd5a8d1a50a9e879c23d344497d606e10c6f8093 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 11:24:25 -0600 Subject: [PATCH 190/424] Fix getMaximumHeight function to use helpers --- Chart.js | 2 +- Chart.min.js | 2 +- src/core/core.controller.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Chart.js b/Chart.js index 5a49a4ea56d..e7b0e102e49 100644 --- a/Chart.js +++ b/Chart.js @@ -1271,7 +1271,7 @@ this.stop(); var canvas = this.chart.canvas, newWidth = helpers.getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : helpers.getMaximumHeight(this.chart.canvas); canvas.width = this.chart.width = newWidth; canvas.height = this.chart.height = newHeight; diff --git a/Chart.min.js b/Chart.min.js index f79fbcfa3bf..9dec1bac6a0 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,7 +7,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;for(o=0;o=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;for(o=0;o=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) }}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?2*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 577e3e30c57..518354ba345 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -77,7 +77,7 @@ this.stop(); var canvas = this.chart.canvas, newWidth = helpers.getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas); + newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : helpers.getMaximumHeight(this.chart.canvas); canvas.width = this.chart.width = newWidth; canvas.height = this.chart.height = newHeight; From 6065e8c801c06c21accb1e8f9bc5c537704ff298 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 11:31:15 -0600 Subject: [PATCH 191/424] helpers.each is now reversible --- Chart.js | 12 +++++++++--- Chart.min.js | 2 +- src/core/core.helpers.js | 12 +++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Chart.js b/Chart.js index e7b0e102e49..bea8301d13d 100644 --- a/Chart.js +++ b/Chart.js @@ -115,14 +115,20 @@ var helpers = Chart.helpers = {}; //-- Basic js utility methods - var each = helpers.each = function(loopable, callback, self) { + var each = helpers.each = function(loopable, callback, self, reverse) { var additionalArgs = Array.prototype.slice.call(arguments, 3); // Check to see if null or undefined firstly. if (loopable) { if (loopable.length === +loopable.length) { var i; - for (i = 0; i < loopable.length; i++) { - callback.apply(self, [loopable[i], i].concat(additionalArgs)); + if (reverse) { + for (i = loopable.length - 1; i >= 0; i--) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } + } else { + for (i = 0; i < loopable.length; i++) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } } } else { for (var item in loopable) { diff --git a/Chart.min.js b/Chart.min.js index 9dec1bac6a0..02ef0e40393 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,7 +7,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var a=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;for(o=0;o=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) }}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?2*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 29f925bd509..5fcbec8c48c 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -10,14 +10,20 @@ var helpers = Chart.helpers = {}; //-- Basic js utility methods - var each = helpers.each = function(loopable, callback, self) { + var each = helpers.each = function(loopable, callback, self, reverse) { var additionalArgs = Array.prototype.slice.call(arguments, 3); // Check to see if null or undefined firstly. if (loopable) { if (loopable.length === +loopable.length) { var i; - for (i = 0; i < loopable.length; i++) { - callback.apply(self, [loopable[i], i].concat(additionalArgs)); + if (reverse) { + for (i = loopable.length - 1; i >= 0; i--) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } + } else { + for (i = 0; i < loopable.length; i++) { + callback.apply(self, [loopable[i], i].concat(additionalArgs)); + } } } else { for (var item in loopable) { From a5e4b38252fdea49a67a0ddff4d50f56ccb5536f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 11:37:07 -0600 Subject: [PATCH 192/424] Draw controllers in reverse (for proper line stacking) --- Chart.js | 5 ++--- Chart.min.js | 2 +- src/core/core.controller.js | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Chart.js b/Chart.js index bea8301d13d..b50bd083b41 100644 --- a/Chart.js +++ b/Chart.js @@ -1405,11 +1405,10 @@ this.scale.draw(); } - // Draw each dataset via its respective controller - // TODO: needs support for reverse stacking (line chart) + // Draw each dataset via its respective controller (reversed to support proper line stacking) helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.draw(ease); - }, this); + }, this, true); // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); diff --git a/Chart.min.js b/Chart.min.js index 02ef0e40393..61be55f0358 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,7 +7,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) }}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?2*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 518354ba345..b36e0a9f13b 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -205,11 +205,10 @@ this.scale.draw(); } - // Draw each dataset via its respective controller - // TODO: needs support for reverse stacking (line chart) + // Draw each dataset via its respective controller (reversed to support proper line stacking) helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.draw(ease); - }, this); + }, this, true); // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); From 34f8bc99c6d3c63afb2921d048a986842c0a7e61 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 11:37:14 -0600 Subject: [PATCH 193/424] Better demo for combo --- samples/combo-bar-line.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/samples/combo-bar-line.html b/samples/combo-bar-line.html index a4cd5fbfd9f..cdca070c43f 100644 --- a/samples/combo-bar-line.html +++ b/samples/combo-bar-line.html @@ -23,19 +23,23 @@ var barChartData = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ - type: 'line', label: 'Dataset 1', - backgroundColor: "rgba(220,220,220,0.5)", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + backgroundColor: "rgba(151,187,205,0.5)", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + borderColor: 'white', + borderWidth: 2 }, { label: 'Dataset 2', backgroundColor: "rgba(151,187,205,0.5)", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + borderColor: 'white', + borderWidth: 2 }, { + type: 'line', label: 'Dataset 3', - backgroundColor: "rgba(151,187,205,0.5)", + backgroundColor: "rgba(220,220,220,0.5)", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] - }] + }, ] }; window.onload = function() { From 48b8a3a2c52e7cf7435185324c94ca51c96607ff Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 11:46:50 -0600 Subject: [PATCH 194/424] =?UTF-8?q?Fixed=20issue=20where=20arc.inRange=20w?= =?UTF-8?q?as=20sometimes=20over=20=CF=80=20threshold?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Chart.js | 2 +- Chart.min.js | 2 +- src/controllers/controller.doughnut.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Chart.js b/Chart.js index b50bd083b41..748fb52090e 100644 --- a/Chart.js +++ b/Chart.js @@ -2587,7 +2587,7 @@ calculateCircumference: function(value) { if (this.getDataset().total > 0) { - return (Math.PI * 2) * (value / this.getDataset().total); + return (Math.PI * 1.999999) * (value / this.getDataset().total); } else { return 0; } diff --git a/Chart.min.js b/Chart.min.js index 61be55f0358..3cdd1f2a6b8 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -8,7 +8,7 @@ * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ (function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) -}}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?2*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), +}}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js * http://chartjs.org/ diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 8e5b4e13155..795f0d1155c 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -165,7 +165,7 @@ calculateCircumference: function(value) { if (this.getDataset().total > 0) { - return (Math.PI * 2) * (value / this.getDataset().total); + return (Math.PI * 1.999999) * (value / this.getDataset().total); } else { return 0; } From e3ffbb155f3ed9cc9b754ada0a613efad4418247 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 11:57:35 -0600 Subject: [PATCH 195/424] Deprecate animationLoop function --- Chart.js | 20 -------------------- Chart.min.js | 6 +++--- samples/bar.html | 3 ++- src/core/core.helpers.js | 20 -------------------- 4 files changed, 5 insertions(+), 44 deletions(-) diff --git a/Chart.js b/Chart.js index 748fb52090e..1daa5361f0a 100644 --- a/Chart.js +++ b/Chart.js @@ -836,26 +836,6 @@ return window.clearTimeout(callback, 1000 / 60); }; })(), - animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { - - var currentStep = 0, - easingFunction = easingEffects[easingString] || easingEffects.linear; - - var animationFrame = function() { - currentStep++; - var stepDecimal = currentStep / totalSteps; - var easeDecimal = easingFunction(stepDecimal); - - callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); - onProgress.call(chartInstance, easeDecimal, stepDecimal); - if (currentStep < totalSteps) { - chartInstance.animationFrame = requestAnimFrame(animationFrame); - } else { - onComplete.apply(chartInstance); - } - }; - requestAnimFrame(animationFrame); - }, //-- DOM methods getRelativePosition = helpers.getRelativePosition = function(evt) { var mouseX, mouseY; diff --git a/Chart.min.js b/Chart.min.js index 3cdd1f2a6b8..8b437e9ec6a 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),m=(e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.animationLoop=function(t,e,i,a,o,s){var n=0,r=d[i]||d.linear,h=function(){n++;var i=n/e,l=r(i);t.call(s,l,i,n),a.call(s,l,i),e>n?s.animationFrame=g(h):o.apply(s)};g(h)},e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},m(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) -}}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), -i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth)}}),o.pivot()},this)},draw:function(t){var e=t||1; +i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)), +i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha diff --git a/samples/bar.html b/samples/bar.html index 812b2e0d792..c9a46657271 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -49,9 +49,10 @@ }; $('#randomizeData').click(function() { + var zero = Math.random() < 0.2 ? [0, 0, 0, 0, 0, 0, 0] : false; $.each(barChartData.datasets, function(i, dataset) { dataset.backgroundColor = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)'; - dataset.data = [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; + dataset.data = zero || [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]; }); window.myBar.update(); diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 5fcbec8c48c..8f52854d97b 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -731,26 +731,6 @@ return window.clearTimeout(callback, 1000 / 60); }; })(), - animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) { - - var currentStep = 0, - easingFunction = easingEffects[easingString] || easingEffects.linear; - - var animationFrame = function() { - currentStep++; - var stepDecimal = currentStep / totalSteps; - var easeDecimal = easingFunction(stepDecimal); - - callback.call(chartInstance, easeDecimal, stepDecimal, currentStep); - onProgress.call(chartInstance, easeDecimal, stepDecimal); - if (currentStep < totalSteps) { - chartInstance.animationFrame = requestAnimFrame(animationFrame); - } else { - onComplete.apply(chartInstance); - } - }; - requestAnimFrame(animationFrame); - }, //-- DOM methods getRelativePosition = helpers.getRelativePosition = function(evt) { var mouseX, mouseY; From 088b4fcc556d413eb3fba14f4568982ee0c1f1b6 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 12:04:52 -0600 Subject: [PATCH 196/424] Fixed: scale.linear range min==max resulted in no scale --- Chart.js | 5 +++++ Chart.min.js | 4 ++-- src/scales/scale.linear.js | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Chart.js b/Chart.js index 1daa5361f0a..48fcd6e8e17 100644 --- a/Chart.js +++ b/Chart.js @@ -3770,6 +3770,11 @@ } }, this); } + + if (this.min === this.max) { + this.min--; + this.max++; + } }, getPointPixelForValue: function(rawValue, index, datasetIndex) { diff --git a/Chart.min.js b/Chart.min.js index 8b437e9ec6a..7d087205225 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -8,8 +8,8 @@ * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ (function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth)}}),o.pivot()},this)},draw:function(t){var e=t||1; -i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)), -i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! +i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), +i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index bcd089f53ac..2f2c781fa4f 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -230,6 +230,11 @@ } }, this); } + + if (this.min === this.max) { + this.min--; + this.max++; + } }, getPointPixelForValue: function(rawValue, index, datasetIndex) { From 63530ba66d8ccd7cfbc6c141c538f724754aceb5 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 13:06:34 -0600 Subject: [PATCH 197/424] Better responsive sizing --- Chart.js | 8 +++++--- Chart.min.js | 4 ++-- src/core/core.animation.js | 2 +- src/core/core.js | 2 ++ src/core/core.responsive.js | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Chart.js b/Chart.js index 48fcd6e8e17..2cfaafc1432 100644 --- a/Chart.js +++ b/Chart.js @@ -71,6 +71,7 @@ Chart.defaults = { global: { responsive: true, + responsiveAnimationDuration: 0, maintainAspectRatio: true, events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], hover: { @@ -83,6 +84,7 @@ // Element defaults defined in element extensions elements: {} + }, }; @@ -1092,7 +1094,7 @@ dropFrames: 0, addAnimation: function(chartInstance, animationObject, duration) { - if (!duration) { + if (typeof duration !== 'number' || duration === 0) { chartInstance.animating = true; } @@ -1633,10 +1635,10 @@ // Cascade the resize event down to the chart. if (instance.options.responsive) { instance.resize(); - instance.update(); + instance.update(Chart.defaults.global.responsiveAnimationDuration); } }); - }, 50); + }, 16); }; })()); diff --git a/Chart.min.js b/Chart.min.js index 7d087205225..610a9c83a82 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,8 +7,8 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){a||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth)}}),o.pivot()},this)},draw:function(t){var e=t||1; -i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) +}}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js * http://chartjs.org/ diff --git a/src/core/core.animation.js b/src/core/core.animation.js index 03e7577fbbf..06cf54190e1 100644 --- a/src/core/core.animation.js +++ b/src/core/core.animation.js @@ -29,7 +29,7 @@ dropFrames: 0, addAnimation: function(chartInstance, animationObject, duration) { - if (!duration) { + if (typeof duration !== 'number' || duration === 0) { chartInstance.animating = true; } diff --git a/src/core/core.js b/src/core/core.js index e64f98d2b3a..85a99167148 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -71,6 +71,7 @@ Chart.defaults = { global: { responsive: true, + responsiveAnimationDuration: 0, maintainAspectRatio: true, events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"], hover: { @@ -83,6 +84,7 @@ // Element defaults defined in element extensions elements: {} + }, }; diff --git a/src/core/core.responsive.js b/src/core/core.responsive.js index 23295feba6d..995b6f08bd5 100644 --- a/src/core/core.responsive.js +++ b/src/core/core.responsive.js @@ -20,10 +20,10 @@ // Cascade the resize event down to the chart. if (instance.options.responsive) { instance.resize(); - instance.update(); + instance.update(Chart.defaults.global.responsiveAnimationDuration); } }); - }, 50); + }, 16); }; })()); From 8d1f2807717c8e19cf2c35824076d48e9c6712ed Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 16 Jun 2015 13:19:01 -0600 Subject: [PATCH 198/424] Even better responsive sizing --- Chart.js | 10 +++++++--- Chart.min.js | 2 +- src/core/core.controller.js | 9 +++++++-- src/core/core.responsive.js | 1 - 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Chart.js b/Chart.js index 2cfaafc1432..86718c553a0 100644 --- a/Chart.js +++ b/Chart.js @@ -1213,7 +1213,8 @@ Chart.instances[this.id] = this; if (this.options.responsive) { - this.resize(); + // Silent resize before chart draws + this.resize(true); } this.initialize.call(this); @@ -1255,7 +1256,7 @@ return this; }, - resize: function resize() { + resize: function resize(silent) { this.stop(); var canvas = this.chart.canvas, newWidth = helpers.getMaximumWidth(this.chart.canvas), @@ -1266,6 +1267,10 @@ helpers.retinaScale(this.chart); + if (!silent) { + this.update(this.options.responsiveAnimationDuration); + } + return this; }, @@ -1635,7 +1640,6 @@ // Cascade the resize event down to the chart. if (instance.options.responsive) { instance.resize(); - instance.update(Chart.defaults.global.responsiveAnimationDuration); } }); }, 16); diff --git a/Chart.min.js b/Chart.min.js index 610a9c83a82..2fbf94e0ddb 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,7 +7,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(){this.stop();var t=this.chart.canvas,i=e.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio?i/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return t.width=this.chart.width=i,t.height=this.chart.height=a,e.retinaScale(this.chart),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var i=this.chart.canvas,a=e.getMaximumWidth(this.chart.canvas),o=this.options.maintainAspectRatio?a/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return i.width=this.chart.width=a,i.height=this.chart.height=o,e.retinaScale(this.chart),t||this.update(this.options.responsiveAnimationDuration),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) }}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! * Chart.js diff --git a/src/core/core.controller.js b/src/core/core.controller.js index b36e0a9f13b..77a08bbdf15 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -31,7 +31,8 @@ Chart.instances[this.id] = this; if (this.options.responsive) { - this.resize(); + // Silent resize before chart draws + this.resize(true); } this.initialize.call(this); @@ -73,7 +74,7 @@ return this; }, - resize: function resize() { + resize: function resize(silent) { this.stop(); var canvas = this.chart.canvas, newWidth = helpers.getMaximumWidth(this.chart.canvas), @@ -84,6 +85,10 @@ helpers.retinaScale(this.chart); + if (!silent) { + this.update(this.options.responsiveAnimationDuration); + } + return this; }, diff --git a/src/core/core.responsive.js b/src/core/core.responsive.js index 995b6f08bd5..7a2eb78c751 100644 --- a/src/core/core.responsive.js +++ b/src/core/core.responsive.js @@ -20,7 +20,6 @@ // Cascade the resize event down to the chart. if (instance.options.responsive) { instance.resize(); - instance.update(Chart.defaults.global.responsiveAnimationDuration); } }); }, 16); From 056b9550d0816536ba330ef405e0b2dee312f9f8 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 16 Jun 2015 19:20:26 -0400 Subject: [PATCH 199/424] Create interfaces similar to the old interfaces. Ensure that scales always have IDs before controllers are built. --- gulpfile.js | 2 +- samples/bar-multi-axis.html | 3 +-- samples/line-multi-axis.html | 2 +- samples/polar-area.html | 3 +-- samples/scatter-multi-axis.html | 2 +- samples/scatter.html | 7 +++--- src/charts/Chart.Bar.js | 14 +++++++++++ src/charts/Chart.Doughnut.js | 14 +++++++++++ src/charts/Chart.Line.js | 14 +++++++++++ src/charts/Chart.PolarArea.js | 14 +++++++++++ src/charts/Chart.Radar.js | 14 +++++++++++ .../Chart.Scatter.js} | 21 ++++++++--------- src/controllers/controller.line.js | 2 ++ src/core/core.controller.js | 23 +++++++++++++++++-- src/scales/scale.category.js | 1 - src/scales/scale.linear.js | 1 - 16 files changed, 111 insertions(+), 26 deletions(-) create mode 100644 src/charts/Chart.Bar.js create mode 100644 src/charts/Chart.Doughnut.js create mode 100644 src/charts/Chart.Line.js create mode 100644 src/charts/Chart.PolarArea.js create mode 100644 src/charts/Chart.Radar.js rename src/{controllers/controller.scatter.js => charts/Chart.Scatter.js} (75%) diff --git a/gulpfile.js b/gulpfile.js index 70d58c0083c..9ce3dc3f4bb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,7 +32,7 @@ gulp.task('build', function() { './src/controllers/**', './src/scales/**', './src/elements/**', - './src/charts/chart.bar.js', + './src/charts/**', './node_modules/color/dist/color.min.js' ], isCustom = !!(util.env.types), diff --git a/samples/bar-multi-axis.html b/samples/bar-multi-axis.html index ff5c360fa9f..b1ed3abf0f7 100644 --- a/samples/bar-multi-axis.html +++ b/samples/bar-multi-axis.html @@ -45,8 +45,7 @@ }; window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myBar = new Chart(ctx, { - type: 'bar', + window.myBar = Chart.Bar(ctx, { data: barChartData, options: { responsive: true, diff --git a/samples/line-multi-axis.html b/samples/line-multi-axis.html index 729cf3731b2..e2f0d873b63 100644 --- a/samples/line-multi-axis.html +++ b/samples/line-multi-axis.html @@ -45,7 +45,7 @@ window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myLine = new Chart(ctx).Line({ + window.myLine = Chart.Line(ctx, { data: lineChartData, options: { responsive: true, diff --git a/samples/polar-area.html b/samples/polar-area.html index 4388a73cad0..73d5c604972 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -21,7 +21,6 @@ }; var config = { - type: 'polarArea', data: { datasets: [{ data: [ @@ -54,7 +53,7 @@ window.onload = function() { var ctx = document.getElementById("chart-area"); - window.myPolarArea = new Chart(ctx, config); + window.myPolarArea = Chart.PolarArea(ctx, config); }; $('#randomizeData').click(function() { diff --git a/samples/scatter-multi-axis.html b/samples/scatter-multi-axis.html index ab08e0d2648..a25c5f1b12a 100644 --- a/samples/scatter-multi-axis.html +++ b/samples/scatter-multi-axis.html @@ -90,7 +90,7 @@ window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myScatter = new Chart(ctx).Scatter({ + window.myScatter = Chart.Scatter(ctx, { data: scatterChartData, options: { responsive: true, diff --git a/samples/scatter.html b/samples/scatter.html index b27743762c1..c4c96fbf8dc 100644 --- a/samples/scatter.html +++ b/samples/scatter.html @@ -86,15 +86,14 @@ window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); - window.myScatter = new Chart(ctx).Scatter({ + window.myScatter = Chart.Scatter(ctx, { data: scatterChartData, options: { - responsive: true, - hoverMode: 'single', // should always use single for a scatter chart scales: { xAxes: [{ + position: 'top', gridLines: { - zeroLineColor: "rgba(0,0,0,1)" + zeroLineColor: "rgba(0,255,0,1)" } }] } diff --git a/src/charts/Chart.Bar.js b/src/charts/Chart.Bar.js new file mode 100644 index 00000000000..26db4ada008 --- /dev/null +++ b/src/charts/Chart.Bar.js @@ -0,0 +1,14 @@ +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Bar = function(context, config) { + config.type = 'bar'; + + return new Chart(context, config); + } + +}).call(this); diff --git a/src/charts/Chart.Doughnut.js b/src/charts/Chart.Doughnut.js new file mode 100644 index 00000000000..d01959d448f --- /dev/null +++ b/src/charts/Chart.Doughnut.js @@ -0,0 +1,14 @@ +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Doughnut = function(context, config) { + config.type = 'doughnut'; + + return new Chart(context, config); + } + +}).call(this); diff --git a/src/charts/Chart.Line.js b/src/charts/Chart.Line.js new file mode 100644 index 00000000000..d5e7cf76c06 --- /dev/null +++ b/src/charts/Chart.Line.js @@ -0,0 +1,14 @@ +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Line = function(context, config) { + config.type = 'line'; + + return new Chart(context, config); + } + +}).call(this); diff --git a/src/charts/Chart.PolarArea.js b/src/charts/Chart.PolarArea.js new file mode 100644 index 00000000000..e798f74647d --- /dev/null +++ b/src/charts/Chart.PolarArea.js @@ -0,0 +1,14 @@ +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.PolarArea = function(context, config) { + config.type = 'polarArea'; + + return new Chart(context, config); + } + +}).call(this); diff --git a/src/charts/Chart.Radar.js b/src/charts/Chart.Radar.js new file mode 100644 index 00000000000..f5580783d66 --- /dev/null +++ b/src/charts/Chart.Radar.js @@ -0,0 +1,14 @@ +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Radar = function(context, config) { + config.type = 'radar'; + + return new Chart(context, config); + } + +}).call(this); diff --git a/src/controllers/controller.scatter.js b/src/charts/Chart.Scatter.js similarity index 75% rename from src/controllers/controller.scatter.js rename to src/charts/Chart.Scatter.js index 7048897b9ea..3c784ff3212 100644 --- a/src/controllers/controller.scatter.js +++ b/src/charts/Chart.Scatter.js @@ -1,11 +1,9 @@ (function() { "use strict"; - return; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; var defaultConfig = { hover: { @@ -35,9 +33,10 @@ }; - - Chart.types.Line.extend({ - name: "Scatter", - defaults: defaultConfig, - }); -}).call(this); + Chart.Scatter = function(context, config) { + config.options = helpers.configMerge(defaultConfig, config.options); + config.type = 'line'; + return new Chart(context, config); + } + +}).call(this); \ No newline at end of file diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index 79bc1c7822e..19c9d6f5354 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -14,9 +14,11 @@ scales: { xAxes: [{ type: "category", + id: 'x-axis-0' }], yAxes: [{ type: "linear", + id: 'y-axis-0' }], }, }; diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 77a08bbdf15..ac081a748bc 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -51,6 +51,7 @@ // Make sure controllers are built first so that each dataset is bound to an axis before the scales // are built + this.ensureScalesHaveIDs(); this.buildControllers(); this.buildScales(); this.resetElements(); @@ -91,7 +92,25 @@ return this; }, + ensureScalesHaveIDs: function ensureScalesHaveIDs() { + var defaultXAxisID = 'x-axis-'; + var defaultYAxisID = 'y-axis-'; + if (this.options.scales) { + if (this.options.scales.xAxes && this.options.scales.xAxes.length) { + helpers.each(this.options.scales.xAxes, function(xAxisOptions, index) { + xAxisOptions.id = xAxisOptions.id || (defaultXAxisID + index); + }, this); + } + + if (this.options.scales.yAxes && this.options.scales.yAxes.length) { + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions, index) { + yAxisOptions.id = yAxisOptions.id || (defaultYAxisID + index); + }, this); + } + } + }, buildScales: function buildScales() { // Map of scale ID to scale object so we can lookup later this.scales = {}; @@ -99,7 +118,7 @@ // Build the x axes if (this.options.scales) { if (this.options.scales.xAxes && this.options.scales.xAxes.length) { - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + helpers.each(this.options.scales.xAxes, function(xAxisOptions, index) { var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); var scale = new ScaleClass({ ctx: this.chart.ctx, @@ -114,7 +133,7 @@ if (this.options.scales.yAxes && this.options.scales.yAxes.length) { // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + helpers.each(this.options.scales.yAxes, function(yAxisOptions, index) { var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); var scale = new ScaleClass({ ctx: this.chart.ctx, diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 35773157840..ffac6fe2100 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -9,7 +9,6 @@ var defaultConfig = { display: true, position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale // grid line settings gridLines: { diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 2f2c781fa4f..ce2fa8eb19d 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -8,7 +8,6 @@ var defaultConfig = { display: true, position: "left", - id: "y-axis-1", // grid line settings gridLines: { From 19a30f5090bb806a97dc175660f9a1d2ece5eb69 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 16 Jun 2015 22:04:52 -0400 Subject: [PATCH 200/424] Update controllers to handle adding new datasets --- src/controllers/controller.bar.js | 4 +++- src/controllers/controller.doughnut.js | 4 +++- src/controllers/controller.line.js | 3 +++ src/controllers/controller.polarArea.js | 3 +++ src/controllers/controller.radar.js | 3 +++ src/core/core.controller.js | 21 +++++++++++++++++++-- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 0bb92041d69..e4f7fa918cb 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -40,7 +40,9 @@ this.linkScales(); this.addElements(); }, - + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { if (!this.getDataset().xAxisID) { this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 795f0d1155c..dc8cbdc352b 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -38,7 +38,9 @@ this.linkScales(); this.addElements(); }, - + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { // no scales for doughnut }, diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index 19c9d6f5354..2e3e341e299 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -36,6 +36,9 @@ this.linkScales(); this.addElements(); }, + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { if (!this.getDataset().xAxisID) { diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 2aa0e498916..733ab9dc6d0 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -30,6 +30,9 @@ this.linkScales(); this.addElements(); }, + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { // no scales for doughnut diff --git a/src/controllers/controller.radar.js b/src/controllers/controller.radar.js index 28c0f2ca8fb..df35de5b192 100644 --- a/src/controllers/controller.radar.js +++ b/src/controllers/controller.radar.js @@ -31,6 +31,9 @@ this.linkScales(); this.addElements(); }, + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { // No need. Single scale only diff --git a/src/core/core.controller.js b/src/core/core.controller.js index ac081a748bc..1d098e8907d 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -52,7 +52,7 @@ // Make sure controllers are built first so that each dataset is bound to an axis before the scales // are built this.ensureScalesHaveIDs(); - this.buildControllers(); + this.buildOrUpdateControllers(); this.buildScales(); this.resetElements(); this.initToolTip(); @@ -75,6 +75,23 @@ return this; }, + addDataset: function addDataset(dataset, index) { + if (index !== undefined) { + this.data.datasets.splice(index, 0, dataset); + } else { + this.data.datasets.push(dataset); + } + + this.buildOrUpdateControllers(); + dataset.controller.reset(); // so that animation looks ok + this.update(); + }, + removeDataset: function removeDataset(index) { + this.data.datasets.splice(index, 1); + this.buildOrUpdateControllers(); + this.update(); + }, + resize: function resize(silent) { this.stop(); var canvas = this.chart.canvas, @@ -162,7 +179,7 @@ Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); }, - buildControllers: function() { + buildOrUpdateControllers: function() { helpers.each(this.data.datasets, function(dataset, datasetIndex) { var type = dataset.type || this.config.type; if (dataset.controller) { From e7850a796ee44fbfb3b86b93a7ac7d46adb851a3 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 16 Jun 2015 22:05:06 -0400 Subject: [PATCH 201/424] Update line sample to test adding and removing datasets --- samples/line.html | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/samples/line.html b/samples/line.html index b920a04ddeb..c7ea97c17e5 100644 --- a/samples/line.html +++ b/samples/line.html @@ -19,6 +19,8 @@

    + + From f2298aed77dfc5bffdd30e9890886ce6368e5281 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 16 Jun 2015 22:05:20 -0400 Subject: [PATCH 202/424] Update bar sample to handle adding and removing datasets --- samples/bar.html | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/samples/bar.html b/samples/bar.html index c9a46657271..d79d082c7b4 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -12,6 +12,8 @@
    + + From fd7a4e9bd737b2712e442cd4923585f2dc9c7cd2 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 16 Jun 2015 22:12:59 -0400 Subject: [PATCH 203/424] Update doughnut sample to support adding and removing datasets --- samples/doughnut.html | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/samples/doughnut.html b/samples/doughnut.html index 7e529acd3b9..93f7c8656c7 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -18,10 +18,12 @@ -
    +
    + + From c9c1853c576f0ce0200ca5b0bec370122a1b3e75 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 16 Jun 2015 22:16:28 -0400 Subject: [PATCH 204/424] Update pie sample file to support add and remove datasets --- samples/pie.html | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/samples/pie.html b/samples/pie.html index 6f97bd43eec..2ae05735551 100644 --- a/samples/pie.html +++ b/samples/pie.html @@ -8,16 +8,18 @@ -
    +
    + + From 271d37f572e525f0053102f13cd316c6e02399a8 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 16 Jun 2015 22:21:40 -0400 Subject: [PATCH 205/424] Update radar sample + use the same colour functions in all samples --- samples/doughnut.html | 2 +- samples/line.html | 5 ++++- samples/pie.html | 5 ++++- samples/radar.html | 25 ++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/samples/doughnut.html b/samples/doughnut.html index 93f7c8656c7..f2746557a26 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -32,7 +32,7 @@ return Math.round(Math.random() * 255); }; var randomColor = function(opacity) { - return 'rgba(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + (opacity || '.3') + ')'; + return 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',' + (opacity || '.3') + ')'; }; var config = { diff --git a/samples/line.html b/samples/line.html index c7ea97c17e5..b4d9bc4ee72 100644 --- a/samples/line.html +++ b/samples/line.html @@ -25,8 +25,11 @@ var randomScalingFactor = function() { return Math.round(Math.random() * 100 * (Math.random() > 0.5 ? -1 : 1)); }; + var randomColorFactor = function() { + return Math.round(Math.random() * 255); + }; var randomColor = function(opacity) { - return 'rgba(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + (opacity || '.3') + ')'; + return 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',' + (opacity || '.3') + ')'; }; var config = { diff --git a/samples/pie.html b/samples/pie.html index 2ae05735551..571efb03787 100644 --- a/samples/pie.html +++ b/samples/pie.html @@ -18,8 +18,11 @@ var randomScalingFactor = function() { return Math.round(Math.random() * 100); }; + var randomColorFactor = function() { + return Math.round(Math.random() * 255); + }; var randomColor = function(opacity) { - return 'rgba(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + (opacity || '.3') + ')'; + return 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',' + (opacity || '.3') + ')'; }; var config = { diff --git a/samples/radar.html b/samples/radar.html index 0630bc1edce..fd1214cbbdc 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -8,10 +8,12 @@ -
    +
    + + From 79f8ce0e97fa94c01e5333f6c4c05a55b84f4ceb Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 17 Jun 2015 15:10:45 -0600 Subject: [PATCH 206/424] Fixed Custom Tooltips --- src/core/core.tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 13e5548bcc0..5de6b8bdc4e 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -238,8 +238,8 @@ ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips - if (this._custom) { - this._custom(this._view); + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this._view); } else { switch (vm.yAlign) { case "above": From cc2fb73e8787a4a7a45b878845dd5090797b267f Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 17 Jun 2015 15:10:57 -0600 Subject: [PATCH 207/424] Build --- Chart.js | 230 +++++++++++++++++++++++++++++++++++++++------------ Chart.min.js | 12 +-- 2 files changed, 182 insertions(+), 60 deletions(-) diff --git a/Chart.js b/Chart.js index 86718c553a0..71c2a9efc50 100644 --- a/Chart.js +++ b/Chart.js @@ -1233,7 +1233,8 @@ // Make sure controllers are built first so that each dataset is bound to an axis before the scales // are built - this.buildControllers(); + this.ensureScalesHaveIDs(); + this.buildOrUpdateControllers(); this.buildScales(); this.resetElements(); this.initToolTip(); @@ -1256,6 +1257,23 @@ return this; }, + addDataset: function addDataset(dataset, index) { + if (index !== undefined) { + this.data.datasets.splice(index, 0, dataset); + } else { + this.data.datasets.push(dataset); + } + + this.buildOrUpdateControllers(); + dataset.controller.reset(); // so that animation looks ok + this.update(); + }, + removeDataset: function removeDataset(index) { + this.data.datasets.splice(index, 1); + this.buildOrUpdateControllers(); + this.update(); + }, + resize: function resize(silent) { this.stop(); var canvas = this.chart.canvas, @@ -1273,7 +1291,25 @@ return this; }, + ensureScalesHaveIDs: function ensureScalesHaveIDs() { + var defaultXAxisID = 'x-axis-'; + var defaultYAxisID = 'y-axis-'; + if (this.options.scales) { + if (this.options.scales.xAxes && this.options.scales.xAxes.length) { + helpers.each(this.options.scales.xAxes, function(xAxisOptions, index) { + xAxisOptions.id = xAxisOptions.id || (defaultXAxisID + index); + }, this); + } + + if (this.options.scales.yAxes && this.options.scales.yAxes.length) { + // Build the y axes + helpers.each(this.options.scales.yAxes, function(yAxisOptions, index) { + yAxisOptions.id = yAxisOptions.id || (defaultYAxisID + index); + }, this); + } + } + }, buildScales: function buildScales() { // Map of scale ID to scale object so we can lookup later this.scales = {}; @@ -1281,7 +1317,7 @@ // Build the x axes if (this.options.scales) { if (this.options.scales.xAxes && this.options.scales.xAxes.length) { - helpers.each(this.options.scales.xAxes, function(xAxisOptions) { + helpers.each(this.options.scales.xAxes, function(xAxisOptions, index) { var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type); var scale = new ScaleClass({ ctx: this.chart.ctx, @@ -1296,7 +1332,7 @@ if (this.options.scales.yAxes && this.options.scales.yAxes.length) { // Build the y axes - helpers.each(this.options.scales.yAxes, function(yAxisOptions) { + helpers.each(this.options.scales.yAxes, function(yAxisOptions, index) { var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type); var scale = new ScaleClass({ ctx: this.chart.ctx, @@ -1325,7 +1361,7 @@ Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); }, - buildControllers: function() { + buildOrUpdateControllers: function() { helpers.each(this.data.datasets, function(dataset, datasetIndex) { var type = dataset.type || this.config.type; if (dataset.controller) { @@ -2158,8 +2194,8 @@ ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips - if (this._custom) { - this._custom(this._view); + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this._view); } else { switch (vm.yAlign) { case "above": @@ -2294,7 +2330,9 @@ this.linkScales(); this.addElements(); }, - + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { if (!this.getDataset().xAxisID) { this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id; @@ -2446,7 +2484,9 @@ this.linkScales(); this.addElements(); }, - + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { // no scales for doughnut }, @@ -2600,9 +2640,11 @@ scales: { xAxes: [{ type: "category", + id: 'x-axis-0' }], yAxes: [{ type: "linear", + id: 'y-axis-0' }], }, }; @@ -2620,6 +2662,9 @@ this.linkScales(); this.addElements(); }, + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { if (!this.getDataset().xAxisID) { @@ -2848,6 +2893,9 @@ this.linkScales(); this.addElements(); }, + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { // no scales for doughnut @@ -3035,6 +3083,9 @@ this.linkScales(); this.addElements(); }, + updateIndex: function(datasetIndex) { + this.index = datasetIndex; + }, linkScales: function() { // No need. Single scale only @@ -3233,50 +3284,6 @@ }).call(this); -(function() { - "use strict"; - - return; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - var defaultConfig = { - hover: { - mode: 'single', - }, - - scales: { - xAxes: [{ - type: "linear", // scatter should not use a category axis - position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale - }], - yAxes: [{ - type: "linear", - position: "left", - id: "y-axis-1", - }], - }, - - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - - tooltips: { - template: "(<%= value.x %>, <%= value.y %>)", - multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", - }, - - }; - - - Chart.types.Line.extend({ - name: "Scatter", - defaults: defaultConfig, - }); -}).call(this); - (function() { "use strict"; @@ -3288,7 +3295,6 @@ var defaultConfig = { display: true, position: "bottom", - id: "x-axis-1", // need an ID so datasets can reference the scale // grid line settings gridLines: { @@ -3554,7 +3560,6 @@ var defaultConfig = { display: true, position: "left", - id: "y-axis-1", // grid line settings gridLines: { @@ -5016,4 +5021,121 @@ }).call(this); +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Bar = function(context, config) { + config.type = 'bar'; + + return new Chart(context, config); + } + +}).call(this); + +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Doughnut = function(context, config) { + config.type = 'doughnut'; + + return new Chart(context, config); + } + +}).call(this); + +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Line = function(context, config) { + config.type = 'line'; + + return new Chart(context, config); + } + +}).call(this); + +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.PolarArea = function(context, config) { + config.type = 'polarArea'; + + return new Chart(context, config); + } + +}).call(this); + +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + Chart.Radar = function(context, config) { + config.type = 'radar'; + + return new Chart(context, config); + } + +}).call(this); + +(function() { + "use strict"; + + var root = this; + var Chart = root.Chart; + var helpers = Chart.helpers; + + var defaultConfig = { + hover: { + mode: 'single', + }, + + scales: { + xAxes: [{ + type: "linear", // scatter should not use a category axis + position: "bottom", + id: "x-axis-1", // need an ID so datasets can reference the scale + }], + yAxes: [{ + type: "linear", + position: "left", + id: "y-axis-1", + }], + }, + + //String - A legend template + legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", + + tooltips: { + template: "(<%= value.x %>, <%= value.y %>)", + multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", + }, + + }; + + Chart.Scatter = function(context, config) { + config.options = helpers.configMerge(defaultConfig, config.options); + config.type = 'line'; + return new Chart(context, config); + } + +}).call(this); !function e(r,t,n){function a(i,u){if(!t[i]){if(!r[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(s)return s(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var o=t[i]={exports:{}};r[i][0].call(o.exports,function(e){var t=r[i][1][e];return a(t?t:e)},o,o.exports,e,r,t,n)}return t[i].exports}for(var s="function"==typeof require&&require,i=0;i=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*r[0]+.7152*r[1]+.0722*r[2]},contrast:function(e){var r=this.luminosity(),t=e.luminosity();return r>t?(r+.05)/(t+.05):(t+.05)/(r+.05)},level:function(e){var r=this.contrast(e);return r>=7.1?"AAA":r>=4.5?"AA":""},dark:function(){var e=this.values.rgb,r=(299*e[0]+587*e[1]+114*e[2])/1e3;return 128>r},light:function(){return!this.dark()},negate:function(){for(var e=[],r=0;3>r;r++)e[r]=255-this.values.rgb[r];return this.setValues("rgb",e),this},lighten:function(e){return this.values.hsl[2]+=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},darken:function(e){return this.values.hsl[2]-=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},saturate:function(e){return this.values.hsl[1]+=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},desaturate:function(e){return this.values.hsl[1]-=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},whiten:function(e){return this.values.hwb[1]+=this.values.hwb[1]*e,this.setValues("hwb",this.values.hwb),this},blacken:function(e){return this.values.hwb[2]+=this.values.hwb[2]*e,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var e=this.values.rgb,r=.3*e[0]+.59*e[1]+.11*e[2];return this.setValues("rgb",[r,r,r]),this},clearer:function(e){return this.setValues("alpha",this.values.alpha-this.values.alpha*e),this},opaquer:function(e){return this.setValues("alpha",this.values.alpha+this.values.alpha*e),this},rotate:function(e){var r=this.values.hsl[0];return r=(r+e)%360,r=0>r?360+r:r,this.values.hsl[0]=r,this.setValues("hsl",this.values.hsl),this},mix:function(e,r){r=1-(null==r?.5:r);for(var t=2*r-1,n=this.alpha()-e.alpha(),a=((t*n==-1?t:(t+n)/(1+t*n))+1)/2,s=1-a,i=this.rgbArray(),u=e.rgbArray(),l=0;lr&&(r+=360),n=(u+l)/2,t=l==u?0:.5>=n?h/(l+u):h/(2-l-u),[r,100*t,100*n]}function s(e){var r,t,n,a=e[0],s=e[1],i=e[2],u=Math.min(a,s,i),l=Math.max(a,s,i),h=l-u;return t=0==l?0:h/l*1e3/10,l==u?r=0:a==l?r=(s-i)/h:s==l?r=2+(i-a)/h:i==l&&(r=4+(a-s)/h),r=Math.min(60*r,360),0>r&&(r+=360),n=l/255*1e3/10,[r,t,n]}function i(e){var r=e[0],t=e[1],n=e[2],s=a(e)[0],i=1/255*Math.min(r,Math.min(t,n)),n=1-1/255*Math.max(r,Math.max(t,n));return[s,100*i,100*n]}function u(e){var r,t,n,a,s=e[0]/255,i=e[1]/255,u=e[2]/255;return a=Math.min(1-s,1-i,1-u),r=(1-s-a)/(1-a)||0,t=(1-i-a)/(1-a)||0,n=(1-u-a)/(1-a)||0,[100*r,100*t,100*n,100*a]}function l(e){return X[JSON.stringify(e)]}function h(e){var r=e[0]/255,t=e[1]/255,n=e[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*r+.3576*t+.1805*n,s=.2126*r+.7152*t+.0722*n,i=.0193*r+.1192*t+.9505*n;return[100*a,100*s,100*i]}function o(e){var r,t,n,a=h(e),s=a[0],i=a[1],u=a[2];return s/=95.047,i/=100,u/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,r=116*i-16,t=500*(s-i),n=200*(i-u),[r,t,n]}function c(e){return J(o(e))}function v(e){var r,t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100;if(0==u)return s=255*l,[s,s,s];t=.5>l?l*(1+u):l+u-l*u,r=2*l-t,a=[0,0,0];for(var h=0;3>h;h++)n=i+1/3*-(h-1),0>n&&n++,n>1&&n--,s=1>6*n?r+6*(t-r)*n:1>2*n?t:2>3*n?r+(t-r)*(2/3-n)*6:r,a[h]=255*s;return a}function f(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return s*=2,a*=1>=s?s:2-s,t=(s+a)/2,r=2*a/(s+a),[n,100*r,100*t]}function d(e){return i(v(e))}function p(e){return u(v(e))}function m(e){return l(v(e))}function y(e){var r=e[0]/60,t=e[1]/100,n=e[2]/100,a=Math.floor(r)%6,s=r-Math.floor(r),i=255*n*(1-t),u=255*n*(1-t*s),l=255*n*(1-t*(1-s)),n=255*n;switch(a){case 0:return[n,l,i];case 1:return[u,n,i];case 2:return[i,n,l];case 3:return[i,u,n];case 4:return[l,i,n];case 5:return[n,i,u]}}function w(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return t=(2-a)*s,r=a*s,r/=1>=t?t:2-t,r=r||0,t/=2,[n,100*r,100*t]}function k(e){return i(y(e))}function M(e){return u(y(e))}function S(e){return l(y(e))}function x(e){var t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100,h=u+l;switch(h>1&&(u/=h,l/=h),t=Math.floor(6*i),n=1-l,a=6*i-t,0!=(1&t)&&(a=1-a),s=u+a*(n-u),t){default:case 6:case 0:r=n,g=s,b=u;break;case 1:r=s,g=n,b=u;break;case 2:r=u,g=n,b=s;break;case 3:r=u,g=s,b=n;break;case 4:r=s,g=u,b=n;break;case 5:r=n,g=u,b=s}return[255*r,255*g,255*b]}function V(e){return a(x(e))}function q(e){return s(x(e))}function A(e){return u(x(e))}function C(e){return l(x(e))}function F(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100,u=e[3]/100;return r=1-Math.min(1,a*(1-u)+u),t=1-Math.min(1,s*(1-u)+u),n=1-Math.min(1,i*(1-u)+u),[255*r,255*t,255*n]}function N(e){return a(F(e))}function z(e){return s(F(e))}function I(e){return i(F(e))}function O(e){return l(F(e))}function E(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100;return r=3.2406*a+-1.5372*s+i*-.4986,t=a*-.9689+1.8758*s+.0415*i,n=.0557*a+s*-.204+1.057*i,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=12.92*r,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:t=12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,r=Math.min(Math.max(0,r),1),t=Math.min(Math.max(0,t),1),n=Math.min(Math.max(0,n),1),[255*r,255*t,255*n]}function H(e){var r,t,n,a=e[0],s=e[1],i=e[2];return a/=95.047,s/=100,i/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,r=116*s-16,t=500*(a-s),n=200*(s-i),[r,t,n]}function U(e){return J(H(e))}function j(e){var r,t,n,a,s=e[0],i=e[1],u=e[2];return 8>=s?(t=100*s/903.3,a=7.787*(t/100)+16/116):(t=100*Math.pow((s+16)/116,3),a=Math.pow(t/100,1/3)),r=.008856>=r/95.047?r=95.047*(i/500+a-16/116)/7.787:95.047*Math.pow(i/500+a,3),n=.008859>=n/108.883?n=108.883*(a-u/200-16/116)/7.787:108.883*Math.pow(a-u/200,3),[r,t,n]}function J(e){var r,t,n,a=e[0],s=e[1],i=e[2];return r=Math.atan2(i,s),t=360*r/2/Math.PI,0>t&&(t+=360),n=Math.sqrt(s*s+i*i),[a,n,t]}function R(e){return E(j(e))}function $(e){var r,t,n,a=e[0],s=e[1],i=e[2];return n=i/360*2*Math.PI,r=s*Math.cos(n),t=s*Math.sin(n),[a,r,t]}function D(e){return j($(e))}function P(e){return R($(e))}function _(e){return W[e]}function L(e){return a(_(e))}function T(e){return s(_(e))}function B(e){return i(_(e))}function G(e){return u(_(e))}function K(e){return o(_(e))}function Q(e){return h(_(e))}t.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:i,rgb2cmyk:u,rgb2keyword:l,rgb2xyz:h,rgb2lab:o,rgb2lch:c,hsl2rgb:v,hsl2hsv:f,hsl2hwb:d,hsl2cmyk:p,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:k,hsv2cmyk:M,hsv2keyword:S,hwb2rgb:x,hwb2hsl:V,hwb2hsv:q,hwb2cmyk:A,hwb2keyword:C,cmyk2rgb:F,cmyk2hsl:N,cmyk2hsv:z,cmyk2hwb:I,cmyk2keyword:O,keyword2rgb:_,keyword2hsl:L,keyword2hsv:T,keyword2hwb:B,keyword2cmyk:G,keyword2lab:K,keyword2xyz:Q,xyz2rgb:E,xyz2lab:H,xyz2lch:U,lab2xyz:j,lab2rgb:R,lab2lch:J,lch2lab:$,lch2xyz:D,lch2rgb:P};var W={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},X={};for(var Y in W)X[JSON.stringify(W[Y])]=Y},{}],3:[function(e,r,t){var n=e("./conversions"),a=function(){return new h};for(var s in n){a[s+"Raw"]=function(e){return function(r){return"number"==typeof r&&(r=Array.prototype.slice.call(arguments)),n[e](r)}}(s);var i=/(\w+)2(\w+)/.exec(s),u=i[1],l=i[2];a[u]=a[u]||{},a[u][l]=a[s]=function(e){return function(r){"number"==typeof r&&(r=Array.prototype.slice.call(arguments));var t=n[e](r);if("string"==typeof t||void 0===t)return t;for(var a=0;ar||e[3]&&e[3]<1?c(e,r):"rgb("+e[0]+", "+e[1]+", "+e[2]+")"}function c(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+r+")"}function g(e,r){if(1>r||e[3]&&e[3]<1)return v(e,r);var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgb("+t+"%, "+n+"%, "+a+"%)"}function v(e,r){var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgba("+t+"%, "+n+"%, "+a+"%, "+(r||e[3]||1)+")"}function f(e,r){return 1>r||e[3]&&e[3]<1?d(e,r):"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)"}function d(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+r+")"}function b(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+(void 0!==r&&1!==r?", "+r:"")+")"}function p(e){return k[e.slice(0,3)]}function m(e,r,t){return Math.min(Math.max(r,e),t)}function y(e){var r=e.toString(16).toUpperCase();return r.length<2?"0"+r:r}var w=e("color-name");r.exports={getRgba:n,getHsla:a,getRgb:i,getHsl:u,getHwb:s,getAlpha:l,hexString:h,rgbString:o,rgbaString:c,percentString:g,percentaString:v,hslString:f,hslaString:d,hwbString:b,keyword:p};var k={};for(var M in w)k[w[M]]=M},{"color-name":5}],5:[function(e,r,t){r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/Chart.min.js b/Chart.min.js index 2fbf94e0ddb..9ef12f964a7 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},o=this.width=a(t.canvas,"Width")||t.canvas.width,s=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=o,t.canvas.height=s,o=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var o=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var s;if(a)for(s=t.length-1;s>=0;s--)e.apply(i,[t[s],s].concat(o));else for(s=0;s=o[a].length||!o[a][i].type?o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==o[a][i].type?o[a][i]=e.configMerge(o[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):o[a][i]=e.configMerge(o[a][i],t)}):(o[a]=[],e.each(t,function(t){o[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):o.hasOwnProperty(a)&&"object"==typeof o[a]&&null!==o[a]&&"object"==typeof t?o[a]=e.configMerge(o[a],t):o[a]=t)}),o},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var o=t[a];if(e(o))return o}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=s,t&&o(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,o=Math.sqrt(i*i+a*a),s=Math.atan2(a,i);return s<-.5*Math.PI&&(s+=2*Math.PI),{angle:s,distance:o}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*o/(o+s),r=a*s/(o+s);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,o){var s=2,n=Math.floor(e/(1.5*i)),r=s>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(o&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=s,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,o=Math.floor(e.log10(t)),s=t/Math.pow(10,o);return a=i?1.5>s?1:3>s?2:7>s?5:10:1>=s?1:2>=s?2:5>=s?5:10,a*Math.pow(10,o)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,o){var s=new Array(e);return t&&i(s,function(e,i){s[i]=u(t,{value:a+o*(i+1)})}),s},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-s.left,i=a.touches[0].clientY-s.top):(e=a.clientX-s.left,i=a.clientY-s.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var o=0;return i(a,function(e){var i=t.measureText(e).width;o=i>o?i:o}),o},e.drawRoundedRectangle=function(t,e,i,a,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+a-s,i),t.quadraticCurveTo(e+a,i,e+a,i+s),t.lineTo(e+a,i+o-s),t.quadraticCurveTo(e+a,i+o,e+a-s,i+o),t.lineTo(e+s,i+o),t.quadraticCurveTo(e,i+o,e,i+o-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var o=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=o.rgbString()}catch(s){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var o=Date.now(),s=o-t-this.frameDuration,n=s/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.buildControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},resize:function(t){this.stop();var i=this.chart.canvas,a=e.getMaximumWidth(this.chart.canvas),o=this.options.maintainAspectRatio?a/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return i.width=this.chart.width=a,i.height=this.chart.height=o,e.retinaScale(this.chart),t||this.update(this.options.responsiveAnimationDuration),this},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t){var e=Chart.scaleService.getScaleConstructor(t.type),i=new e({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[i.id]=i},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],o=i.currentStep/i.numSteps,s=a(o);t.draw(s,o,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,o){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],o=0;o30?5:2,s=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*o,u-=2*s;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*s,b=e-2*o;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=o,C=o,_=s,k=s;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=o,A=s,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,o,s=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,o=i.indexOf(a,this._active[0]),-1===o);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[o]&&e[o].hasValue()&&c.push(e[o])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),s.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,o);i.extend(this._model,{x:h.x,y:h.y,labels:s,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=s.length*this._model.fontSize+(s.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,s)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,o=t.measureText(e.text).width+2*e.xPadding,s=e.fontSize+2*e.yPadding,n=s+e.caretHeight+a;e.x+o/2>this._chart.width?e.xAlign="left":e.x-o/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-o/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._custom)this._custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-o+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,o,s,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+o/2,h+s/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,o){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(o+1)),t.fillStyle=i.color(e.legendColors[o].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(o+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[o].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(o+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(o,s){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(o,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:s,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,s),y:t?n:a.calculateBarY(this.index,s),label:this.chart.data.labels[s],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,s),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:o.custom&&o.custom.backgroundColor?o.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,s,this.chart.options.elements.rectangle.backgroundColor),borderColor:o.custom&&o.custom.borderColor?o.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,s,this.chart.options.elements.rectangle.borderColor),borderWidth:o.custom&&o.custom.borderWidth?o.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,s,this.chart.options.elements.rectangle.borderWidth) -}}),o.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var o={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?o:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,o=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=s.getPixelForValue(s.min<0&&s.max<0?s.max:s.min>0&&s.max>0?s.min:0),i.extend(a,{_scale:s,_datasetIndex:this.index,_children:o,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),a.pivot(),i.each(o,function(a,o){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:s,_datasetIndex:this.index,_index:o,_model:{x:n.getPointPixelForValue(this.getDataset().data[o],o,this.index),y:t?e:s.getPointPixelForValue(this.getDataset().data[o],o,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,o,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,o,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,o,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,o,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[o],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,o,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),o=this.chart.scale;o.setScaleSize(),o.calculateRange(),o.generateTicks(),o.buildYLabels(),e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var s=o.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?o.xCenter:s.x,y:t?o.yCenter:s.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var o=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),s=o/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=s*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=s/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),o=this.getPixelForValue(null,i,e,!0)-a/2,s=this.calculateBarWidth(t);return this.options.stacked?o+s/2:o+s*e+e*this.options.spacing+s/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var o,s,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),o=h*n,s=h*r,o+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=o+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var o={width:0,height:0},s=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,s,this.data.labels);if(this.isHorizontal()?(o.width=t,this.width=t):this.options.display&&(o.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;o.height=Math.min(r,e)}else this.options.display&&(o.width=Math.min(n+6,t));return this.width=o.width,this.height=o.height,o},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,o="bottom"==this.options.position?this.top+10:this.bottom,s=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,s?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=s?"right":"center",this.ctx.textBaseline=s?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",id:"y-axis-1",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},o=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var o=this.options.override.start+a*this.options.override.stepWidth;ticks.push(o)}else{var s;if(s=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),s=Math.max(2,s),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(s-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.labels.push(o?o:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var o=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>o?e[a]+=o:t[a]+=o},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var o=0,s=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?s+=this.data.datasets[n].data[e]:o+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?s+a:o+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]<0?this.data.datasets[o].data[e]:0);else for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]>0?this.data.datasets[s].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0), -i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,o=0,s=0;t>s;s++)this.data.datasets[s].data[e]<0?o+=this.data.datasets[s].data[e]||0:a+=this.data.datasets[s].data[e]||0;return this.getPixelForValue(0>i?o+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var o="bottom"==this.options.position?this.top:this.bottom-5,s="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,o),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(o,s){var n=this.getPixelForValue(o);0===o||!a&&0===s?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",o,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},o=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var o=i.sign(this.min),s=i.sign(this.max);0>o&&0>s?this.max=0:o>0&&s>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var o;this.options.labels.userCallback?o=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(o=i.template(this.options.labels.template,{value:t})),this.yLabels.push(o?o:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,o,s,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+o,s=e),t.x-om&&(m=t.x+a,s=e):e>this.valuesCount/2&&t.x-a0){var o=this.getDistanceFromCenterForValue(this.ticks[a]),s=this.yCenter-o;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,o,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var o=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var s=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>s-r,l=e===r||e===s-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],o.x,o.y)}}}}});e.scaleService.registerScaleType("radialLinear",o,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),f=c(g),m=Math.ceil(u/(1*Math.pow(10,f)))*Math.pow(10,f),p=a?0:Math.floor(d/(1*Math.pow(10,f)))*Math.pow(10,f),v=m-p,b=Math.pow(10,f),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&f>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},m=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-left"))+parseInt(m(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-bottom"))+parseInt(m(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},resize:function(t){this.stop();var i=this.chart.canvas,a=e.getMaximumWidth(this.chart.canvas),s=this.options.maintainAspectRatio?a/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return i.width=this.chart.width=a,i.height=this.chart.height=s,e.retinaScale(this.chart),t||this.update(this.options.responsiveAnimationDuration),this},ensureScalesHaveIDs:function(){var t="x-axis-",i="y-axis-";this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(e,i){e.id=e.id||t+i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){t.id=t.id||i+e},this))},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],s=i.currentStep/i.numSteps,o=a(s);t.draw(o,s,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],s=0;s30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),f=[],m=function(t){var e=t.fit(d,u);f.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);f.push({horizontal:!0,minSize:e,scale:t})};i.each(n,m),i.each(r,m),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(f,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom)this._options.tooltips.custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(s,o){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(s,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:o,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,o), +y:t?n:a.calculateBarY(this.index,o),label:this.chart.data.labels[o],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,o),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:s.custom&&s.custom.backgroundColor?s.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,o,this.chart.options.elements.rectangle.backgroundColor),borderColor:s.custom&&s.custom.borderColor?s.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,o,this.chart.options.elements.rectangle.borderColor),borderWidth:s.custom&&s.custom.borderWidth?s.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,o,this.chart.options.elements.rectangle.borderWidth)}}),s.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(a,s){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:s,_model:{x:n.getPointPixelForValue(this.getDataset().data[s],s,this.index),y:t?e:o.getPointPixelForValue(this.getDataset().data[s],s,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,s,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,s,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,s,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,s,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[s],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,s,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var o=s.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?s.xCenter:o.x,y:t?s.yCenter:o.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i); +},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),f=this.width,m=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ef&&(f=t.x+s,o=e),t.x-sf&&(f=t.x+a,o=e):e>this.valuesCount/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -18,7 +18,7 @@ i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelFor * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.elements.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?a.startAngle-2*Math.PI:a.startAngle,n=a.endAngle<-.5*Math.PI?a.endAngle+2*Math.PI:a.endAngle>1.5*Math.PI?a.endAngle-2*Math.PI:a.endAngle,r=o.angle>=s&&o.angle<=n,h=o.distance>=a.innerRadius&&o.distance<=a.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.elements.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?a.startAngle-2*Math.PI:a.startAngle,n=a.endAngle<-.5*Math.PI?a.endAngle+2*Math.PI:a.endAngle>1.5*Math.PI?a.endAngle-2*Math.PI:a.endAngle,r=s.angle>=o&&s.angle<=n,h=s.distance>=a.innerRadius&&s.distance<=a.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -27,7 +27,7 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,o=this._children[0],s=this._children[this._children.length-1];i.each(this._children,function(e,o){var s=i.previousItem(this._children,o),n=i.nextItem(this._children,o);return 0===o?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(s._view.x,e._view.y),a.moveTo(n._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,s._view.y),a.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!o._view.skip?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):a.lineTo(o._view.x,o._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,o){var s=i.previousItem(this._children,o),n=i.nextItem(this._children,o);return 0===o?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(s._view.x,e._view.y),void a.moveTo(n._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,s._view.y),void a.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!o._view.skip&&(t.tension>0?a.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,o._view.controlPointPreviousX,o._view.controlPointPreviousY,o._view.x,o._view.y):a.lineTo(o._view.x,o._view.y)),a.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,s=this._children[0],o=this._children[this._children.length-1];i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(o._view.x,e._view.y),a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,o._view.y),a.lineTo(e._view.x,e._view.y)),void(o._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!s._view.skip?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(o._view.x,e._view.y),void a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,o._view.y),void a.moveTo(e._view.x,e._view.y)):o._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!s._view.skip&&(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),a.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,o=e.x+i,s=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,o-=n,s+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,s),t.lineTo(o,s),t.lineTo(o,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),o=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,s=1-o,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function o(t){var e,i,a,o=t[0],s=t[1],n=t[2],r=Math.min(o,s,n),h=Math.max(o,s,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:o==h?e=(s-n)/l:s==h?e=2+(n-o)/l:n==h&&(e=4+(o-s)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],i=t[1],o=t[2],s=a(t)[0],n=1/255*Math.min(e,Math.min(i,o)),o=1-1/255*Math.max(e,Math.max(i,o));return[s,100*n,100*o]}function n(t){var e,i,a,o,s=t[0]/255,n=t[1]/255,r=t[2]/255;return o=Math.min(1-s,1-n,1-r),e=(1-s-o)/(1-o)||0,i=(1-n-o)/(1-o)||0,a=(1-r-o)/(1-o)||0,[100*e,100*i,100*a,100*o]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var o=.4124*e+.3576*i+.1805*a,s=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*o,100*s,100*n]}function c(t){var e,i,a,o=l(t),s=o[0],n=o[1],r=o[2];return s/=95.047,n/=100,r/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(s-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,o,s,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return s=255*h,[s,s,s];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,o=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,s=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,o[l]=255*s;return o}function m(t){var e,i,a=t[0],o=t[1]/100,s=t[2]/100;return s*=2,o*=1>=s?s:2-s,i=(s+o)/2,e=2*o/(s+o),[a,100*e,100*i]}function f(t){return s(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,o=Math.floor(e)%6,s=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*s),h=255*a*(1-i*(1-s)),a=255*a;switch(o){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],o=t[1]/100,s=t[2]/100;return i=(2-o)*s,e=o*s,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return s(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,o,s=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*s),i=1-h,a=6*s-e,0!=(1&e)&&(a=1-a),o=n+a*(i-n),e){default:case 6:case 0:r=i,g=o,b=n;break;case 1:r=o,g=i,b=n;break;case 2:r=n,g=i,b=o;break;case 3:r=n,g=o,b=i;break;case 4:r=o,g=n,b=i;break;case 5:r=i,g=n,b=o}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return o(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function M(t){var e,i,a,o=t[0]/100,s=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,o*(1-r)+r),i=1-Math.min(1,s*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return a(M(t))}function W(t){return o(M(t))}function R(t){return s(M(t))}function V(t){return h(M(t))}function O(t){var e,i,a,o=t[0]/100,s=t[1]/100,n=t[2]/100;return e=3.2406*o+-1.5372*s+n*-.4986,i=o*-.9689+1.8758*s+.0415*n,a=.0557*o+s*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function F(t){var e,i,a,o=t[0],s=t[1],n=t[2];return o/=95.047,s/=100,n/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*s-16,i=500*(o-s),a=200*(s-n),[e,i,a]}function z(t){return B(F(t))}function L(t){var e,i,a,o,s=t[0],n=t[1],r=t[2];return 8>=s?(i=100*s/903.3,o=7.787*(i/100)+16/116):(i=100*Math.pow((s+16)/116,3),o=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+o-16/116)/7.787:95.047*Math.pow(n/500+o,3),a=.008859>=a/108.883?a=108.883*(o-r/200-16/116)/7.787:108.883*Math.pow(o-r/200,3),[e,i,a]}function B(t){var e,i,a,o=t[0],s=t[1],n=t[2];return e=Math.atan2(n,s),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(s*s+n*n),[o,a,i]}function T(t){return O(L(t))}function N(t){var e,i,a,o=t[0],s=t[1],n=t[2];return a=n/360*2*Math.PI,e=s*Math.cos(a),i=s*Math.sin(a),[o,e,i]}function H(t){return L(N(t))}function E(t){return T(N(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return o(q(t))}function X(t){return s(q(t))}function Q(t){return n(q(t))}function Z(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:o,rgb2hwb:s,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:M,cmyk2hsl:I,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:Z,keyword2xyz:U,xyz2rgb:O,xyz2lab:F,xyz2lch:z,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:N,lch2xyz:H,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),o=function(){return new l};for(var s in a){o[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(s);var n=/(\w+)2(\w+)/.exec(s),r=n[1],h=n[2];o[r]=o[r]||{},o[r][h]=o[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var o=0;oe||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),o=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+o+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),o=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+o+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:o,getRgb:n,getHsl:r,getHwb:s,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function f(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return s(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function F(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return B(F(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function N(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function H(t){return L(N(t))}function E(t){return T(N(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function Q(t){return n(q(t))}function U(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:f,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:U,keyword2xyz:Z,xyz2rgb:O,xyz2lab:F,xyz2lch:z,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:N,lch2xyz:H,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function f(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:f,hslaString:m,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From 061566ee2766daf440fd85dd4795581c656ba943 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 17 Jun 2015 15:14:26 -0600 Subject: [PATCH 208/424] Fix Label custom tooltips --- Chart.js | 78 ++++++++++++++++++++-------------------- Chart.min.js | 2 +- src/core/core.tooltip.js | 78 ++++++++++++++++++++-------------------- 3 files changed, 79 insertions(+), 79 deletions(-) diff --git a/Chart.js b/Chart.js index 71c2a9efc50..ae384767a42 100644 --- a/Chart.js +++ b/Chart.js @@ -2163,6 +2163,10 @@ var ctx = this._chart.ctx; var vm = this._view; + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + switch (this._options.hover.mode) { case 'single': @@ -2194,50 +2198,46 @@ ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips - if (this._options.tooltips.custom) { - this._options.tooltips.custom(this._view); - } else { - switch (vm.yAlign) { - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } - switch (vm.xAlign) { - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } + switch (vm.yAlign) { + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } - helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); + switch (vm.xAlign) { + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } - ctx.fill(); + helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); + ctx.fill(); - } + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); break; case 'label': diff --git a/Chart.min.js b/Chart.min.js index 9ef12f964a7..a4fed4b6b87 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,7 +7,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),f=c(g),m=Math.ceil(u/(1*Math.pow(10,f)))*Math.pow(10,f),p=a?0:Math.floor(d/(1*Math.pow(10,f)))*Math.pow(10,f),v=m-p,b=Math.pow(10,f),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&f>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},m=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-left"))+parseInt(m(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-bottom"))+parseInt(m(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},resize:function(t){this.stop();var i=this.chart.canvas,a=e.getMaximumWidth(this.chart.canvas),s=this.options.maintainAspectRatio?a/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return i.width=this.chart.width=a,i.height=this.chart.height=s,e.retinaScale(this.chart),t||this.update(this.options.responsiveAnimationDuration),this},ensureScalesHaveIDs:function(){var t="x-axis-",i="y-axis-";this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(e,i){e.id=e.id||t+i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){t.id=t.id||i+e},this))},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],s=i.currentStep/i.numSteps,o=a(s);t.draw(o,s,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],s=0;s30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),f=[],m=function(t){var e=t.fit(d,u);f.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);f.push({horizontal:!0,minSize:e,scale:t})};i.each(n,m),i.each(r,m),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(f,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom)this._options.tooltips.custom(this._view);else{switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2)}break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(s,o){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(s,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:o,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,o), +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),f=c(g),m=Math.ceil(u/(1*Math.pow(10,f)))*Math.pow(10,f),p=a?0:Math.floor(d/(1*Math.pow(10,f)))*Math.pow(10,f),v=m-p,b=Math.pow(10,f),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&f>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},m=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-left"))+parseInt(m(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-bottom"))+parseInt(m(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},resize:function(t){this.stop();var i=this.chart.canvas,a=e.getMaximumWidth(this.chart.canvas),s=this.options.maintainAspectRatio?a/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return i.width=this.chart.width=a,i.height=this.chart.height=s,e.retinaScale(this.chart),t||this.update(this.options.responsiveAnimationDuration),this},ensureScalesHaveIDs:function(){var t="x-axis-",i="y-axis-";this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(e,i){e.id=e.id||t+i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){t.id=t.id||i+e},this))},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],s=i.currentStep/i.numSteps,o=a(s);t.draw(o,s,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],s=0;s30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),f=[],m=function(t){var e=t.fit(d,u);f.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);f.push({horizontal:!0,minSize:e,scale:t})};i.each(n,m),i.each(r,m),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(f,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(s,o){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(s,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:o,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,o), y:t?n:a.calculateBarY(this.index,o),label:this.chart.data.labels[o],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,o),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:s.custom&&s.custom.backgroundColor?s.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,o,this.chart.options.elements.rectangle.backgroundColor),borderColor:s.custom&&s.custom.borderColor?s.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,o,this.chart.options.elements.rectangle.borderColor),borderWidth:s.custom&&s.custom.borderWidth?s.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,o,this.chart.options.elements.rectangle.borderWidth)}}),s.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(a,s){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:s,_model:{x:n.getPointPixelForValue(this.getDataset().data[s],s,this.index),y:t?e:o.getPointPixelForValue(this.getDataset().data[s],s,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,s,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,s,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,s,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,s,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[s],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,s,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var o=s.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?s.xCenter:o.x,y:t?s.yCenter:o.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i); },this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),f=this.width,m=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ef&&(f=t.x+s,o=e),t.x-sf&&(f=t.x+a,o=e):e>this.valuesCount/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 5de6b8bdc4e..ba154d55a05 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -207,6 +207,10 @@ var ctx = this._chart.ctx; var vm = this._view; + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + switch (this._options.hover.mode) { case 'single': @@ -238,50 +242,46 @@ ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips - if (this._options.tooltips.custom) { - this._options.tooltips.custom(this._view); - } else { - switch (vm.yAlign) { - case "above": - //Draw a caret above the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y - caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); - ctx.closePath(); - ctx.fill(); - break; - case "below": - tooltipY = vm.y + caretPadding + vm.caretHeight; - //Draw a caret below the x/y - ctx.beginPath(); - ctx.moveTo(vm.x, vm.y + caretPadding); - ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); - ctx.closePath(); - ctx.fill(); - break; - } - switch (vm.xAlign) { - case "left": - tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); - break; - case "right": - tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); - break; - } + switch (vm.yAlign) { + case "above": + //Draw a caret above the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y - caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.lineTo(vm.x - vm.caretHeight, vm.y - (caretPadding + vm.caretHeight)); + ctx.closePath(); + ctx.fill(); + break; + case "below": + tooltipY = vm.y + caretPadding + vm.caretHeight; + //Draw a caret below the x/y + ctx.beginPath(); + ctx.moveTo(vm.x, vm.y + caretPadding); + ctx.lineTo(vm.x + vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.lineTo(vm.x - vm.caretHeight, vm.y + caretPadding + vm.caretHeight); + ctx.closePath(); + ctx.fill(); + break; + } - helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); + switch (vm.xAlign) { + case "left": + tooltipX = vm.x - tooltipWidth + (vm.cornerRadius + vm.caretHeight); + break; + case "right": + tooltipX = vm.x - (vm.cornerRadius + vm.caretHeight); + break; + } - ctx.fill(); + helpers.drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, vm.cornerRadius); - ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); + ctx.fill(); - } + ctx.fillStyle = helpers.color(vm.textColor).alpha(vm.opacity).rgbString(); + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(vm.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2); break; case 'label': From 7796c4e87dc671ad5fd983388933028a2fee7f10 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 17 Jun 2015 22:03:24 -0400 Subject: [PATCH 209/424] Add and remove data for bar charts --- samples/bar.html | 32 ++++++++++- src/controllers/controller.bar.js | 95 ++++++++++++++++++------------- src/core/core.controller.js | 24 ++++++++ 3 files changed, 108 insertions(+), 43 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index d79d082c7b4..1d085208e4c 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -14,6 +14,8 @@ + + diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index e4f7fa918cb..c68d478c5e1 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -71,56 +71,71 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var rectangle = new Chart.elements.Rectangle({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + this.updateElement(rectangle, index, true); + this.getDataset().metaData.splice(index, 0, rectangle); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); }, update: function(reset) { + helpers.each(this.getDataset().metaData, function(rectangle, index) { + this.updateElement(rectangle, index, reset); + }, this); + }, + updateElement: function updateElement(rectangle, index, reset) { var xScale = this.getScaleForId(this.getDataset().xAxisID); var yScale = this.getScaleForId(this.getDataset().yAxisID); - helpers.each(this.getDataset().metaData, function(rectangle, index) { - - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } - - helpers.extend(rectangle, { - // Utility - _chart: this.chart.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: this.index, - _index: index, - - - // Desired view properties - _model: { - x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), - y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), - - // Tooltip - label: this.chart.data.labels[index], - datasetLabel: this.getDataset().label, + var yScalePoint; + + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } - // Appearance - base: yScale.calculateBarBase(this.index, index), - width: xScale.calculateBarWidth(this.chart.data.datasets.length), - backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), - borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), - borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), - }, - }); - rectangle.pivot(); - }, this); + helpers.extend(rectangle, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + + // Desired view properties + _model: { + x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), + y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), + + // Tooltip + label: this.chart.data.labels[index], + datasetLabel: this.getDataset().label, + + // Appearance + base: yScale.calculateBarBase(this.index, index), + width: xScale.calculateBarWidth(this.chart.data.datasets.length), + backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), + borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), + borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), + }, + }); + rectangle.pivot(); }, draw: function(ease) { diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 1d098e8907d..312de25b5b0 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -92,6 +92,30 @@ this.update(); }, + // Add data to the given dataset + // @param data: the data to add + // @param {Number} datasetIndex : the index of the dataset to add to + // @param {Number} index : the index of the data + addData: function addData(data, datasetIndex, index) { + if (datasetIndex < this.data.datasets.length) { + if (index === undefined) { + index = this.data.datasets[datasetIndex].data.length; + } + + this.data.datasets[datasetIndex].data.splice(index, 0, data); + this.data.datasets[datasetIndex].controller.addElementAndReset(index); + this.update(); + } + }, + + removeData: function removeData(datasetIndex, index) { + if (datasetIndex < this.data.datasets.length) { + this.data.datasets[datasetIndex].data.splice(index, 1); + this.data.datasets[datasetIndex].controller.removeElement(index); + this.update(); + } + }, + resize: function resize(silent) { this.stop(); var canvas = this.chart.canvas, From 4e305319071e45b83557c348503e33e2ba59915c Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 18 Jun 2015 12:49:09 -0600 Subject: [PATCH 210/424] Allow custom skip property to points --- src/controllers/controller.line.js | 2 +- src/controllers/controller.radar.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index 2e3e341e299..fa5518b43e1 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -144,7 +144,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: this.getDataset().data[index] === null, + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, // Tooltip hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), diff --git a/src/controllers/controller.radar.js b/src/controllers/controller.radar.js index df35de5b192..e7577887f77 100644 --- a/src/controllers/controller.radar.js +++ b/src/controllers/controller.radar.js @@ -141,7 +141,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: this.getDataset().data[index] === null, + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, // Tooltip hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), From 8769b658b17b2712096112d3b114efd69c63cfa7 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 18 Jun 2015 12:49:19 -0600 Subject: [PATCH 211/424] Gulp Build --- Chart.js | 113 ++++++++++++++++++++++++++++++++++----------------- Chart.min.js | 8 ++-- 2 files changed, 80 insertions(+), 41 deletions(-) diff --git a/Chart.js b/Chart.js index ae384767a42..422c91d1610 100644 --- a/Chart.js +++ b/Chart.js @@ -1274,6 +1274,30 @@ this.update(); }, + // Add data to the given dataset + // @param data: the data to add + // @param {Number} datasetIndex : the index of the dataset to add to + // @param {Number} index : the index of the data + addData: function addData(data, datasetIndex, index) { + if (datasetIndex < this.data.datasets.length) { + if (index === undefined) { + index = this.data.datasets[datasetIndex].data.length; + } + + this.data.datasets[datasetIndex].data.splice(index, 0, data); + this.data.datasets[datasetIndex].controller.addElementAndReset(index); + this.update(); + } + }, + + removeData: function removeData(datasetIndex, index) { + if (datasetIndex < this.data.datasets.length) { + this.data.datasets[datasetIndex].data.splice(index, 1); + this.data.datasets[datasetIndex].controller.removeElement(index); + this.update(); + } + }, + resize: function resize(silent) { this.stop(); var canvas = this.chart.canvas, @@ -2361,56 +2385,71 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var rectangle = new Chart.elements.Rectangle({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + this.updateElement(rectangle, index, true); + this.getDataset().metaData.splice(index, 0, rectangle); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); }, update: function(reset) { + helpers.each(this.getDataset().metaData, function(rectangle, index) { + this.updateElement(rectangle, index, reset); + }, this); + }, + updateElement: function updateElement(rectangle, index, reset) { var xScale = this.getScaleForId(this.getDataset().xAxisID); var yScale = this.getScaleForId(this.getDataset().yAxisID); - helpers.each(this.getDataset().metaData, function(rectangle, index) { + var yScalePoint; - var yScalePoint; - - if (yScale.min < 0 && yScale.max < 0) { - // all less than 0. use the top - yScalePoint = yScale.getPixelForValue(yScale.max); - } else if (yScale.min > 0 && yScale.max > 0) { - yScalePoint = yScale.getPixelForValue(yScale.min); - } else { - yScalePoint = yScale.getPixelForValue(0); - } + if (yScale.min < 0 && yScale.max < 0) { + // all less than 0. use the top + yScalePoint = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + yScalePoint = yScale.getPixelForValue(yScale.min); + } else { + yScalePoint = yScale.getPixelForValue(0); + } - helpers.extend(rectangle, { - // Utility - _chart: this.chart.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: this.index, - _index: index, + helpers.extend(rectangle, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, - // Desired view properties - _model: { - x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), - y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), + // Desired view properties + _model: { + x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), + y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), - // Tooltip - label: this.chart.data.labels[index], - datasetLabel: this.getDataset().label, + // Tooltip + label: this.chart.data.labels[index], + datasetLabel: this.getDataset().label, - // Appearance - base: yScale.calculateBarBase(this.index, index), - width: xScale.calculateBarWidth(this.chart.data.datasets.length), - backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), - borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), - borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), - }, - }); - rectangle.pivot(); - }, this); + // Appearance + base: yScale.calculateBarBase(this.index, index), + width: xScale.calculateBarWidth(this.chart.data.datasets.length), + backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), + borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), + borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), + }, + }); + rectangle.pivot(); }, draw: function(ease) { @@ -2770,7 +2809,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: this.getDataset().data[index] === null, + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, // Tooltip hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), @@ -3193,7 +3232,7 @@ backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: this.getDataset().data[index] === null, + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, // Tooltip hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), diff --git a/Chart.min.js b/Chart.min.js index a4fed4b6b87..4c0b49123a2 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),f=c(g),m=Math.ceil(u/(1*Math.pow(10,f)))*Math.pow(10,f),p=a?0:Math.floor(d/(1*Math.pow(10,f)))*Math.pow(10,f),v=m-p,b=Math.pow(10,f),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&f>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),f=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},m=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){f(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-left"))+parseInt(m(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(m(e,"padding-bottom"))+parseInt(m(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},resize:function(t){this.stop();var i=this.chart.canvas,a=e.getMaximumWidth(this.chart.canvas),s=this.options.maintainAspectRatio?a/this.chart.aspectRatio:e.getMaximumHeight(this.chart.canvas);return i.width=this.chart.width=a,i.height=this.chart.height=s,e.retinaScale(this.chart),t||this.update(this.options.responsiveAnimationDuration),this},ensureScalesHaveIDs:function(){var t="x-axis-",i="y-axis-";this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(e,i){e.id=e.id||t+i},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){t.id=t.id||i+e},this))},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&e.each(this.options.scales.xAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&e.each(this.options.scales.yAxes,function(t,e){var i=Chart.scaleService.getScaleConstructor(t.type),a=new i({ctx:this.chart.ctx,options:t,data:this.data,id:t.id});this.scales[a.id]=a},this)),this.options.scale){var t=Chart.scaleService.getScaleConstructor(this.options.scale.type),i=new t({ctx:this.chart.ctx,options:this.options.scale,data:this.data,chart:this.chart});this.scale=i}Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){e.each(this.data.datasets,function(t,e){var i=t.type||this.config.type;return t.controller?void t.controller.updateIndex(e):void(t.controller=new Chart.controllers[i](this,e))},this)},resetElements:function(){e.each(this.data.datasets,function(t,e){t.controller.reset()},this)},update:function(t){Chart.scaleService.fitScalesForChart(this,this.chart.width,this.chart.height),e.each(this.data.datasets,function(t,e){t.controller.update()},this),this.render(t)},render:function(t){if(0!==this.options.animation.duration||t){var i=new Chart.Animation;i.numSteps=(t||this.options.animation.duration)/16.66,i.easing=this.options.animation.easing,i.render=function(t,i){var a=e.easingEffects[i.easing],s=i.currentStep/i.numSteps,o=a(s);t.draw(o,s,i.currentStep)},i.onAnimationProgress=this.options.onAnimationProgress,i.onAnimationComplete=this.options.onAnimationComplete,Chart.animationService.addAnimation(this,i,t)}else this.draw(),this.options.onAnimationComplete.call(this);return this},draw:function(t){var i=t||1;this.clear(),e.each(this.scales,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),e.each(this.data.datasets,function(e,i){e.controller.draw(t)},this,!0),this.tooltip.transition(i).draw()},getElementAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){return t.inRange(i.x,i.y)?(a.push(t),a):void 0},this)},this),a},getElementsAtEvent:function(t){var i=e.getRelativePosition(t),a=[];return e.each(this.data.datasets,function(t,s){e.each(t.metaData,function(t,e){t.inLabelRange(i.x,i.y)&&a.push(t)},this)},this),a},getDatasetAtEvent:function(t){for(var i=e.getRelativePosition(t),a=[],s=0;s30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),f=[],m=function(t){var e=t.fit(d,u);f.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);f.push({horizontal:!0,minSize:e,scale:t})};i.each(n,m),i.each(r,m),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(f,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(f,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e=this.getScaleForId(this.getDataset().xAxisID),a=this.getScaleForId(this.getDataset().yAxisID);i.each(this.getDataset().metaData,function(s,o){var n;n=a.getPixelForValue(a.min<0&&a.max<0?a.max:a.min>0&&a.max>0?a.min:0),i.extend(s,{_chart:this.chart.chart,_xScale:e,_yScale:a,_datasetIndex:this.index,_index:o,_model:{x:e.calculateBarX(this.chart.data.datasets.length,this.index,o), -y:t?n:a.calculateBarY(this.index,o),label:this.chart.data.labels[o],datasetLabel:this.getDataset().label,base:a.calculateBarBase(this.index,o),width:e.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:s.custom&&s.custom.backgroundColor?s.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,o,this.chart.options.elements.rectangle.backgroundColor),borderColor:s.custom&&s.custom.borderColor?s.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,o,this.chart.options.elements.rectangle.borderColor),borderWidth:s.custom&&s.custom.borderWidth?s.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,o,this.chart.options.elements.rectangle.borderWidth)}}),s.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(a,s){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:s,_model:{x:n.getPointPixelForValue(this.getDataset().data[s],s,this.index),y:t?e:o.getPointPixelForValue(this.getDataset().data[s],s,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,s,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,s,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,s,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,s,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[s],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,s,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var o=s.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?s.xCenter:o.x,y:t?s.yCenter:o.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i); -},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),f=this.width,m=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;ef&&(f=t.x+s,o=e),t.x-sf&&(f=t.x+a,o=e):e>this.valuesCount/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){ +this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(a,s){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:s,_model:{x:n.getPointPixelForValue(this.getDataset().data[s],s,this.index),y:t?e:o.getPointPixelForValue(this.getDataset().data[s],s,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,s,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,s,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,s,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,s,this.chart.options.elements.point.borderWidth),skip:a.custom&&a.custom.skip?a.custom.skip:null===this.getDataset().data[s],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,s,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var o=s.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?s.xCenter:o.x,y:t?s.yCenter:o.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:e.custom&&e.custom.skip?e.custom.skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t; +},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.valuesCount/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function f(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return s(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function F(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return B(F(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function N(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function H(t){return L(N(t))}function E(t){return T(N(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function Q(t){return n(q(t))}function U(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:f,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:U,keyword2xyz:Z,xyz2rgb:O,xyz2lab:F,xyz2lch:z,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:N,lch2xyz:H,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function f(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:f,hslaString:m,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return s(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function F(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return B(F(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function N(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function H(t){return L(N(t))}function E(t){return T(N(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function Q(t){return n(q(t))}function U(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:U,keyword2xyz:Z,xyz2rgb:O,xyz2lab:F,xyz2lch:z,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:N,lch2xyz:H,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From a3a2f8ea09ac0f19e9cb02b83a7ffeaefb04da6c Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 18 Jun 2015 18:04:28 -0400 Subject: [PATCH 212/424] Line chart addData and removeData implementations + sample file updates --- samples/line.html | 34 ++++++++++- src/controllers/controller.line.js | 92 +++++++++++++++++++++--------- 2 files changed, 95 insertions(+), 31 deletions(-) diff --git a/samples/line.html b/samples/line.html index b4d9bc4ee72..f4962480f4c 100644 --- a/samples/line.html +++ b/samples/line.html @@ -21,6 +21,8 @@ + + diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index fa5518b43e1..34680dc068a 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -76,13 +76,32 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var point = new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(point, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, point); + + // Make sure bezier control points are updated + this.updateBezierControlPoints(); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); }, update: function(reset) { - var line = this.getDataset().metaDataset; var points = this.getDataset().metaData; @@ -98,7 +117,6 @@ scaleBase = yScale.getPixelForValue(0); } - // Update Line helpers.extend(line, { // Utility @@ -126,33 +144,52 @@ // Update Points helpers.each(points, function(point, index) { - helpers.extend(point, { - // Utility - _chart: this.chart.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: this.index, - _index: index, + this.updateElement(point, index, reset); + }, this); - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), - }, + this.updateBezierControlPoints(); + }, - }); - }, this); + updateElement: function(point, index, reset) { + var yScale = this.getScaleForId(this.getDataset().yAxisID); + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + }); + }, + updateBezierControlPoints: function() { // Update bezier control points helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( @@ -167,7 +204,7 @@ // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds + // Cap outer bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chart.chartArea.bottom) { point._model.controlPointNextY = this.chart.chartArea.bottom; } else if (controlPoints.next.y < this.chart.chartArea.top) { @@ -188,7 +225,6 @@ // Now pivot the point for animation point.pivot(); }, this); - }, draw: function(ease) { From 73af6a31b6ec1ab3cda00a8a905c4a046d7eb086 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 18 Jun 2015 18:28:45 -0400 Subject: [PATCH 213/424] add support for addData and removeData to the radar chart. Needed to update the radialLinear scale so that the number of values is not cached. --- samples/radar.html | 35 +++++++++++-- src/controllers/controller.radar.js | 77 +++++++++++++++++++---------- src/scales/scale.radialLinear.js | 20 ++++---- 3 files changed, 92 insertions(+), 40 deletions(-) diff --git a/samples/radar.html b/samples/radar.html index fd1214cbbdc..0605c76e760 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -14,6 +14,8 @@ + + diff --git a/src/controllers/controller.radar.js b/src/controllers/controller.radar.js index e7577887f77..ce597d720f9 100644 --- a/src/controllers/controller.radar.js +++ b/src/controllers/controller.radar.js @@ -70,6 +70,26 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var point = new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(point, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, point); + + // Make sure bezier control points are updated + this.updateBezierControlPoints(); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); @@ -123,34 +143,40 @@ // Update Points helpers.each(points, function(point, index) { - var pointPosition = scale.getPointPositionForValue(index, this.getDataset().data[index]); - - helpers.extend(point, { - // Utility - _datasetIndex: this.index, - _index: index, - - // Desired view properties - _model: { - x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: reset ? scale.yCenter : pointPosition.y, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), - }, - }); + this.updateElement(point, index, reset); }, this); // Update bezier control points + this.updateBezierControlPoints(); + }, + updateElement: function(point, index, reset) { + var pointPosition = this.chart.scale.getPointPositionForValue(index, this.getDataset().data[index]); + + helpers.extend(point, { + // Utility + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: reset ? this.chart.scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: reset ? this.chart.scale.yCenter : pointPosition.y, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + }); + }, + updateBezierControlPoints: function() { helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( helpers.previousItem(this.getDataset().metaData, index, true)._model, @@ -164,7 +190,7 @@ // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds + // Cap outer bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chart.chartArea.bottom) { point._model.controlPointNextY = this.chart.chartArea.bottom; } else if (controlPoints.next.y < this.chart.chartArea.top) { @@ -185,7 +211,6 @@ // Now pivot the point for animation point.pivot(); }, this); - }, draw: function(ease) { diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 15169aa8673..0a1a26b45af 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -73,10 +73,12 @@ this.xCenter = this.chart.width / 2; this.yCenter = this.chart.height / 2; this.size = helpers.min([this.height, this.width]); - this.valuesCount = this.data.labels.length; this.labels = this.data.labels; this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, + getValueCount: function() { + return this.data.labels.length; + }, update: function() { if (!this.options.lineArc) { this.setScaleSize(); @@ -201,7 +203,7 @@ }, this); }, getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); + return ((Math.PI * 2) / this.getValueCount()); }, setScaleSize: function() { /* @@ -252,13 +254,13 @@ radiusReductionLeft, maxWidthRadius; this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - for (i = 0; i < this.valuesCount; i++) { + for (i = 0; i < this.getValueCount(); i++) { // 5px to space the text slightly out - similar to what we do in the draw function. pointPosition = this.getPointPosition(i, largestPossibleRadius); textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { value: this.labels[i] })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { + if (i === 0 || i === this.getValueCount() / 2) { // If we're at index zero, or exactly the middle, we're at exactly the top/bottom // of the radar chart, so text will be aligned centrally, so we'll half it and compare // w/left and right text sizes @@ -271,13 +273,13 @@ furthestLeft = pointPosition.x - halfTextWidth; furthestLeftIndex = i; } - } else if (i < this.valuesCount / 2) { + } else if (i < this.getValueCount() / 2) { // Less than half the values means we'll left align the text if (pointPosition.x + textWidth > furthestRight) { furthestRight = pointPosition.x + textWidth; furthestRightIndex = i; } - } else if (i > this.valuesCount / 2) { + } else if (i > this.getValueCount() / 2) { // More than half the values means we'll right align the text if (pointPosition.x - textWidth < furthestLeft) { furthestLeft = pointPosition.x - textWidth; @@ -319,7 +321,7 @@ }, getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; + var angleMultiplier = (Math.PI * 2) / this.getValueCount(); // Start from the top instead of right, so remove a quarter of the circle return index * angleMultiplier - (Math.PI / 2); @@ -362,7 +364,7 @@ } else { // Draw straight lines connecting each index ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { + for (var i = 0; i < this.getValueCount(); i++) { var pointPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.ticks[index])); if (i === 0) { ctx.moveTo(pointPosition.x, pointPosition.y); @@ -401,7 +403,7 @@ ctx.lineWidth = this.options.angleLines.lineWidth; ctx.strokeStyle = this.options.angleLines.color; - for (var i = this.valuesCount - 1; i >= 0; i--) { + for (var i = this.getValueCount() - 1; i >= 0; i--) { if (this.options.angleLines.show) { var outerPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max)); ctx.beginPath(); From 891655b3cea3ac48becc637a578222136297e248 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 18 Jun 2015 18:51:00 -0400 Subject: [PATCH 214/424] Polar area charts now support addData and removeData. Fixed an issue with the animateRotate and animateScale options for polar area charts. --- samples/polar-area.html | 29 +++++++- src/controllers/controller.polarArea.js | 96 ++++++++++++++----------- 2 files changed, 83 insertions(+), 42 deletions(-) diff --git a/samples/polar-area.html b/samples/polar-area.html index 73d5c604972..a8c74d16b61 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -8,10 +8,12 @@ -
    +
    + + diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 733ab9dc6d0..4fe948bf843 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -16,6 +16,7 @@ //Boolean - Whether to animate the rotation of the chart animateRotate: true, + animateScale: true, }; Chart.controllers.polarArea = function(chart, datasetIndex) { @@ -56,6 +57,23 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var arc = new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(arc, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, arc); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); @@ -82,14 +100,44 @@ this.innerRadius = this.outerRadius - this.chart.radiusLength; helpers.each(this.getDataset().metaData, function(arc, index) { - - var resetModel = { + this.updateElement(arc, index, reset); + }, this); + }, + updateElement: function(arc, index, reset) { + var circumference = 1 / this.getDataset().data.length * 2; + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + innerRadius: 0, + outerRadius: this.chart.options.animateScale ? 0 : this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), + startAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : startAngle, + endAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : endAngle, + + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) + }; + + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: reset ? resetModel : { x: this.chart.chart.width / 2, y: this.chart.chart.height / 2, innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, + outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), + startAngle: startAngle, + endAngle: endAngle, backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), @@ -97,40 +145,10 @@ borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) - }; - - var circumference = 1 / this.getDataset().data.length * 2; - var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); - - console.log() - - helpers.extend(arc, { - // Utility - _chart: this.chart.chart, - _datasetIndex: this.index, - _index: index, - - // Desired view properties - _model: reset ? resetModel : { - x: this.chart.chart.width / 2, - y: this.chart.chart.height / 2, - innerRadius: 0, - outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), - startAngle: startAngle, - endAngle: endAngle, - - backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), - hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), - borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), - borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) - }, - }); + }, + }); - arc.pivot(); - }, this); + arc.pivot(); }, draw: function(ease) { @@ -141,8 +159,6 @@ }, this); }, - - setHoverStyle: function(arc) { var dataset = this.chart.data.datasets[arc._datasetIndex]; var index = arc._index; From 8cecd5935ec044515e28cddf3d15b89ffb0f7433 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 19 Jun 2015 12:36:22 -0600 Subject: [PATCH 215/424] Tooltip Title width now accurately measured --- Chart.js | 285 +++++++++++++++--------- Chart.min.js | 8 +- samples/line.html | 34 ++- samples/polar-area.html | 29 ++- samples/radar.html | 35 ++- src/controllers/controller.line.js | 92 +++++--- src/controllers/controller.polarArea.js | 96 ++++---- src/controllers/controller.radar.js | 77 ++++--- src/core/core.tooltip.js | 2 +- src/scales/scale.radialLinear.js | 20 +- 10 files changed, 457 insertions(+), 221 deletions(-) diff --git a/Chart.js b/Chart.js index 422c91d1610..808dd8ad0ac 100644 --- a/Chart.js +++ b/Chart.js @@ -2154,7 +2154,7 @@ this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; - var titleWidth = ctx.measureText(this.title).width, + var titleWidth = ctx.measureText(this._model.title).width, //Label has a legend square as well so account for this. labelWidth = helpers.longestText(ctx, this.font, labels) + this._model.fontSize + 3, longestTextWidth = helpers.max([labelWidth, titleWidth]); @@ -2741,13 +2741,32 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var point = new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(point, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, point); + + // Make sure bezier control points are updated + this.updateBezierControlPoints(); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); }, update: function(reset) { - var line = this.getDataset().metaDataset; var points = this.getDataset().metaData; @@ -2763,7 +2782,6 @@ scaleBase = yScale.getPixelForValue(0); } - // Update Line helpers.extend(line, { // Utility @@ -2791,33 +2809,52 @@ // Update Points helpers.each(points, function(point, index) { - helpers.extend(point, { - // Utility - _chart: this.chart.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: this.index, - _index: index, + this.updateElement(point, index, reset); + }, this); - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), - }, + this.updateBezierControlPoints(); + }, - }); - }, this); + updateElement: function(point, index, reset) { + var yScale = this.getScaleForId(this.getDataset().yAxisID); + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + }); + }, + + updateBezierControlPoints: function() { // Update bezier control points helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( @@ -2832,7 +2869,7 @@ // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds + // Cap outer bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chart.chartArea.bottom) { point._model.controlPointNextY = this.chart.chartArea.bottom; } else if (controlPoints.next.y < this.chart.chartArea.top) { @@ -2853,7 +2890,6 @@ // Now pivot the point for animation point.pivot(); }, this); - }, draw: function(ease) { @@ -2918,6 +2954,7 @@ //Boolean - Whether to animate the rotation of the chart animateRotate: true, + animateScale: true, }; Chart.controllers.polarArea = function(chart, datasetIndex) { @@ -2958,6 +2995,23 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var arc = new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(arc, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, arc); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); @@ -2984,14 +3038,44 @@ this.innerRadius = this.outerRadius - this.chart.radiusLength; helpers.each(this.getDataset().metaData, function(arc, index) { + this.updateElement(arc, index, reset); + }, this); + }, + updateElement: function(arc, index, reset) { + var circumference = 1 / this.getDataset().data.length * 2; + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + innerRadius: 0, + outerRadius: this.chart.options.animateScale ? 0 : this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), + startAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : startAngle, + endAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : endAngle, + + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) + }; - var resetModel = { + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: reset ? resetModel : { x: this.chart.chart.width / 2, y: this.chart.chart.height / 2, innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, + outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), + startAngle: startAngle, + endAngle: endAngle, backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), @@ -2999,40 +3083,10 @@ borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) - }; - - var circumference = 1 / this.getDataset().data.length * 2; - var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); - - console.log() - - helpers.extend(arc, { - // Utility - _chart: this.chart.chart, - _datasetIndex: this.index, - _index: index, - - // Desired view properties - _model: reset ? resetModel : { - x: this.chart.chart.width / 2, - y: this.chart.chart.height / 2, - innerRadius: 0, - outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), - startAngle: startAngle, - endAngle: endAngle, - - backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), - hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), - borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), - borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) - }, - }); + }, + }); - arc.pivot(); - }, this); + arc.pivot(); }, draw: function(ease) { @@ -3043,8 +3097,6 @@ }, this); }, - - setHoverStyle: function(arc) { var dataset = this.chart.data.datasets[arc._datasetIndex]; var index = arc._index; @@ -3161,6 +3213,26 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var point = new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(point, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, point); + + // Make sure bezier control points are updated + this.updateBezierControlPoints(); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); @@ -3214,34 +3286,40 @@ // Update Points helpers.each(points, function(point, index) { - var pointPosition = scale.getPointPositionForValue(index, this.getDataset().data[index]); - - helpers.extend(point, { - // Utility - _datasetIndex: this.index, - _index: index, - - // Desired view properties - _model: { - x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: reset ? scale.yCenter : pointPosition.y, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), - }, - }); + this.updateElement(point, index, reset); }, this); // Update bezier control points + this.updateBezierControlPoints(); + }, + updateElement: function(point, index, reset) { + var pointPosition = this.chart.scale.getPointPositionForValue(index, this.getDataset().data[index]); + + helpers.extend(point, { + // Utility + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: reset ? this.chart.scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: reset ? this.chart.scale.yCenter : pointPosition.y, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + }); + }, + updateBezierControlPoints: function() { helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( helpers.previousItem(this.getDataset().metaData, index, true)._model, @@ -3255,7 +3333,7 @@ // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds + // Cap outer bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chart.chartArea.bottom) { point._model.controlPointNextY = this.chart.chartArea.bottom; } else if (controlPoints.next.y < this.chart.chartArea.top) { @@ -3276,7 +3354,6 @@ // Now pivot the point for animation point.pivot(); }, this); - }, draw: function(ease) { @@ -4238,10 +4315,12 @@ this.xCenter = this.chart.width / 2; this.yCenter = this.chart.height / 2; this.size = helpers.min([this.height, this.width]); - this.valuesCount = this.data.labels.length; this.labels = this.data.labels; this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, + getValueCount: function() { + return this.data.labels.length; + }, update: function() { if (!this.options.lineArc) { this.setScaleSize(); @@ -4366,7 +4445,7 @@ }, this); }, getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); + return ((Math.PI * 2) / this.getValueCount()); }, setScaleSize: function() { /* @@ -4417,13 +4496,13 @@ radiusReductionLeft, maxWidthRadius; this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - for (i = 0; i < this.valuesCount; i++) { + for (i = 0; i < this.getValueCount(); i++) { // 5px to space the text slightly out - similar to what we do in the draw function. pointPosition = this.getPointPosition(i, largestPossibleRadius); textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { value: this.labels[i] })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { + if (i === 0 || i === this.getValueCount() / 2) { // If we're at index zero, or exactly the middle, we're at exactly the top/bottom // of the radar chart, so text will be aligned centrally, so we'll half it and compare // w/left and right text sizes @@ -4436,13 +4515,13 @@ furthestLeft = pointPosition.x - halfTextWidth; furthestLeftIndex = i; } - } else if (i < this.valuesCount / 2) { + } else if (i < this.getValueCount() / 2) { // Less than half the values means we'll left align the text if (pointPosition.x + textWidth > furthestRight) { furthestRight = pointPosition.x + textWidth; furthestRightIndex = i; } - } else if (i > this.valuesCount / 2) { + } else if (i > this.getValueCount() / 2) { // More than half the values means we'll right align the text if (pointPosition.x - textWidth < furthestLeft) { furthestLeft = pointPosition.x - textWidth; @@ -4484,7 +4563,7 @@ }, getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; + var angleMultiplier = (Math.PI * 2) / this.getValueCount(); // Start from the top instead of right, so remove a quarter of the circle return index * angleMultiplier - (Math.PI / 2); @@ -4527,7 +4606,7 @@ } else { // Draw straight lines connecting each index ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { + for (var i = 0; i < this.getValueCount(); i++) { var pointPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.ticks[index])); if (i === 0) { ctx.moveTo(pointPosition.x, pointPosition.y); @@ -4566,7 +4645,7 @@ ctx.lineWidth = this.options.angleLines.lineWidth; ctx.strokeStyle = this.options.angleLines.color; - for (var i = this.valuesCount - 1; i >= 0; i--) { + for (var i = this.getValueCount() - 1; i >= 0; i--) { if (this.options.angleLines.show) { var outerPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max)); ctx.beginPath(); diff --git a/Chart.min.js b/Chart.min.js index 4c0b49123a2..ba642a9839e 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){ -this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(a,s){i.extend(a,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:s,_model:{x:n.getPointPixelForValue(this.getDataset().data[s],s,this.index),y:t?e:o.getPointPixelForValue(this.getDataset().data[s],s,this.index),tension:a.custom&&a.custom.tension?a.custom.tension:this.chart.options.elements.line.tension,radius:a.custom&&a.custom.radius?a.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,s,this.chart.options.elements.point.radius),backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,s,this.chart.options.elements.point.backgroundColor),borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,s,this.chart.options.elements.point.borderColor),borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,s,this.chart.options.elements.point.borderWidth),skip:a.custom&&a.custom.skip?a.custom.skip:null===this.getDataset().data[s],hitRadius:a.custom&&a.custom.hitRadius?a.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,s,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,a){var o=s.getPointPositionForValue(a,this.getDataset().data[a]);i.extend(e,{_datasetIndex:this.index,_index:a,_model:{x:t?s.xCenter:o.x,y:t?s.yCenter:o.y,tension:e.custom&&e.custom.tension?e.custom.tension:this.chart.options.elements.line.tension,radius:e.custom&&e.custom.radius?e.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,a,this.chart.options.elements.point.radius),backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,a,this.chart.options.elements.point.backgroundColor),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,a,this.chart.options.elements.point.borderColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,a,this.chart.options.elements.point.borderWidth),skip:e.custom&&e.custom.skip?e.custom.skip:null===this.getDataset().data[a],hitRadius:e.custom&&e.custom.hitRadius?e.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,a,this.chart.options.elements.point.hitRadius)}})},this),i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t; -},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.valuesCount=this.data.labels.length,this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.valuesCount/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){ +this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a); +}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return s(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function F(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return B(F(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function N(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function H(t){return L(N(t))}function E(t){return T(N(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function Q(t){return n(q(t))}function U(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:U,keyword2xyz:Z,xyz2rgb:O,xyz2lab:F,xyz2lch:z,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:N,lch2xyz:H,lch2rgb:E};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return s(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function z(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function F(t){return B(z(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function E(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function N(t){return L(E(t))}function H(t){return T(E(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function Q(t){return n(q(t))}function U(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:U,keyword2xyz:Z,xyz2rgb:O,xyz2lab:z,xyz2lch:F,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:E,lch2xyz:N,lch2rgb:H};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/samples/line.html b/samples/line.html index b4d9bc4ee72..f4962480f4c 100644 --- a/samples/line.html +++ b/samples/line.html @@ -21,6 +21,8 @@ + + diff --git a/samples/polar-area.html b/samples/polar-area.html index 73d5c604972..a8c74d16b61 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -8,10 +8,12 @@ -
    +
    + + diff --git a/samples/radar.html b/samples/radar.html index fd1214cbbdc..0605c76e760 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -14,6 +14,8 @@ + + diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index fa5518b43e1..34680dc068a 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -76,13 +76,32 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var point = new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(point, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, point); + + // Make sure bezier control points are updated + this.updateBezierControlPoints(); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); }, update: function(reset) { - var line = this.getDataset().metaDataset; var points = this.getDataset().metaData; @@ -98,7 +117,6 @@ scaleBase = yScale.getPixelForValue(0); } - // Update Line helpers.extend(line, { // Utility @@ -126,33 +144,52 @@ // Update Points helpers.each(points, function(point, index) { - helpers.extend(point, { - // Utility - _chart: this.chart.chart, - _xScale: xScale, - _yScale: yScale, - _datasetIndex: this.index, - _index: index, + this.updateElement(point, index, reset); + }, this); - // Desired view properties - _model: { - x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), - }, + this.updateBezierControlPoints(); + }, - }); - }, this); + updateElement: function(point, index, reset) { + var yScale = this.getScaleForId(this.getDataset().yAxisID); + var xScale = this.getScaleForId(this.getDataset().xAxisID); + var scaleBase; + + if (yScale.min < 0 && yScale.max < 0) { + scaleBase = yScale.getPixelForValue(yScale.max); + } else if (yScale.min > 0 && yScale.max > 0) { + scaleBase = yScale.getPixelForValue(yScale.min); + } else { + scaleBase = yScale.getPixelForValue(0); + } + + helpers.extend(point, { + // Utility + _chart: this.chart.chart, + _xScale: xScale, + _yScale: yScale, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + }); + }, + updateBezierControlPoints: function() { // Update bezier control points helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( @@ -167,7 +204,7 @@ // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds + // Cap outer bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chart.chartArea.bottom) { point._model.controlPointNextY = this.chart.chartArea.bottom; } else if (controlPoints.next.y < this.chart.chartArea.top) { @@ -188,7 +225,6 @@ // Now pivot the point for animation point.pivot(); }, this); - }, draw: function(ease) { diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 733ab9dc6d0..4fe948bf843 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -16,6 +16,7 @@ //Boolean - Whether to animate the rotation of the chart animateRotate: true, + animateScale: true, }; Chart.controllers.polarArea = function(chart, datasetIndex) { @@ -56,6 +57,23 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var arc = new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(arc, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, arc); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); @@ -82,14 +100,44 @@ this.innerRadius = this.outerRadius - this.chart.radiusLength; helpers.each(this.getDataset().metaData, function(arc, index) { - - var resetModel = { + this.updateElement(arc, index, reset); + }, this); + }, + updateElement: function(arc, index, reset) { + var circumference = 1 / this.getDataset().data.length * 2; + var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; + var endAngle = startAngle + (circumference * Math.PI); + + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + innerRadius: 0, + outerRadius: this.chart.options.animateScale ? 0 : this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), + startAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : startAngle, + endAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : endAngle, + + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), + + label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) + }; + + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: reset ? resetModel : { x: this.chart.chart.width / 2, y: this.chart.chart.height / 2, innerRadius: 0, - outerRadius: 0, - startAngle: Math.PI * -0.5, - endAngle: Math.PI * -0.5, + outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), + startAngle: startAngle, + endAngle: endAngle, backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), @@ -97,40 +145,10 @@ borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) - }; - - var circumference = 1 / this.getDataset().data.length * 2; - var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index; - var endAngle = startAngle + (circumference * Math.PI); - - console.log() - - helpers.extend(arc, { - // Utility - _chart: this.chart.chart, - _datasetIndex: this.index, - _index: index, - - // Desired view properties - _model: reset ? resetModel : { - x: this.chart.chart.width / 2, - y: this.chart.chart.height / 2, - innerRadius: 0, - outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]), - startAngle: startAngle, - endAngle: endAngle, - - backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), - hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), - borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), - borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index]) - }, - }); + }, + }); - arc.pivot(); - }, this); + arc.pivot(); }, draw: function(ease) { @@ -141,8 +159,6 @@ }, this); }, - - setHoverStyle: function(arc) { var dataset = this.chart.data.datasets[arc._datasetIndex]; var index = arc._index; diff --git a/src/controllers/controller.radar.js b/src/controllers/controller.radar.js index e7577887f77..ce597d720f9 100644 --- a/src/controllers/controller.radar.js +++ b/src/controllers/controller.radar.js @@ -70,6 +70,26 @@ }); }, this); }, + addElementAndReset: function(index) { + this.getDataset().metaData = this.getDataset().metaData || []; + var point = new Chart.elements.Point({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + // Reset the point + this.updateElement(point, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, point); + + // Make sure bezier control points are updated + this.updateBezierControlPoints(); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); @@ -123,34 +143,40 @@ // Update Points helpers.each(points, function(point, index) { - var pointPosition = scale.getPointPositionForValue(index, this.getDataset().data[index]); - - helpers.extend(point, { - // Utility - _datasetIndex: this.index, - _index: index, - - // Desired view properties - _model: { - x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: reset ? scale.yCenter : pointPosition.y, - - // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, - radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), - backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), - borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), - borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), - skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, - - // Tooltip - hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), - }, - }); + this.updateElement(point, index, reset); }, this); // Update bezier control points + this.updateBezierControlPoints(); + }, + updateElement: function(point, index, reset) { + var pointPosition = this.chart.scale.getPointPositionForValue(index, this.getDataset().data[index]); + + helpers.extend(point, { + // Utility + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: { + x: reset ? this.chart.scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales + y: reset ? this.chart.scale.yCenter : pointPosition.y, + + // Appearance + tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + radius: point.custom && point.custom.radius ? point.custom.pointRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius), + backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), + borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), + borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth), + skip: point.custom && point.custom.skip ? point.custom.skip : this.getDataset().data[index] === null, + + // Tooltip + hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), + }, + }); + }, + updateBezierControlPoints: function() { helpers.each(this.getDataset().metaData, function(point, index) { var controlPoints = helpers.splineCurve( helpers.previousItem(this.getDataset().metaData, index, true)._model, @@ -164,7 +190,7 @@ // Prevent the bezier going outside of the bounds of the graph - // Cap puter bezier handles to the upper/lower scale bounds + // Cap outer bezier handles to the upper/lower scale bounds if (controlPoints.next.y > this.chart.chartArea.bottom) { point._model.controlPointNextY = this.chart.chartArea.bottom; } else if (controlPoints.next.y < this.chart.chartArea.top) { @@ -185,7 +211,6 @@ // Now pivot the point for animation point.pivot(); }, this); - }, draw: function(ease) { diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index ba154d55a05..1423f7ae5f1 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -174,7 +174,7 @@ this._model.height = (labels.length * this._model.fontSize) + ((labels.length - 1) * (this._model.fontSize / 2)) + (this._model.yPadding * 2) + this._model.titleFontSize * 1.5; - var titleWidth = ctx.measureText(this.title).width, + var titleWidth = ctx.measureText(this._model.title).width, //Label has a legend square as well so account for this. labelWidth = helpers.longestText(ctx, this.font, labels) + this._model.fontSize + 3, longestTextWidth = helpers.max([labelWidth, titleWidth]); diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 15169aa8673..0a1a26b45af 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -73,10 +73,12 @@ this.xCenter = this.chart.width / 2; this.yCenter = this.chart.height / 2; this.size = helpers.min([this.height, this.width]); - this.valuesCount = this.data.labels.length; this.labels = this.data.labels; this.drawingArea = (this.options.display) ? (this.size / 2) - (this.options.labels.fontSize / 2 + this.options.labels.backdropPaddingY) : (this.size / 2); }, + getValueCount: function() { + return this.data.labels.length; + }, update: function() { if (!this.options.lineArc) { this.setScaleSize(); @@ -201,7 +203,7 @@ }, this); }, getCircumference: function() { - return ((Math.PI * 2) / this.valuesCount); + return ((Math.PI * 2) / this.getValueCount()); }, setScaleSize: function() { /* @@ -252,13 +254,13 @@ radiusReductionLeft, maxWidthRadius; this.ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); - for (i = 0; i < this.valuesCount; i++) { + for (i = 0; i < this.getValueCount(); i++) { // 5px to space the text slightly out - similar to what we do in the draw function. pointPosition = this.getPointPosition(i, largestPossibleRadius); textWidth = this.ctx.measureText(helpers.template(this.options.labels.template, { value: this.labels[i] })).width + 5; - if (i === 0 || i === this.valuesCount / 2) { + if (i === 0 || i === this.getValueCount() / 2) { // If we're at index zero, or exactly the middle, we're at exactly the top/bottom // of the radar chart, so text will be aligned centrally, so we'll half it and compare // w/left and right text sizes @@ -271,13 +273,13 @@ furthestLeft = pointPosition.x - halfTextWidth; furthestLeftIndex = i; } - } else if (i < this.valuesCount / 2) { + } else if (i < this.getValueCount() / 2) { // Less than half the values means we'll left align the text if (pointPosition.x + textWidth > furthestRight) { furthestRight = pointPosition.x + textWidth; furthestRightIndex = i; } - } else if (i > this.valuesCount / 2) { + } else if (i > this.getValueCount() / 2) { // More than half the values means we'll right align the text if (pointPosition.x - textWidth < furthestLeft) { furthestLeft = pointPosition.x - textWidth; @@ -319,7 +321,7 @@ }, getIndexAngle: function(index) { - var angleMultiplier = (Math.PI * 2) / this.valuesCount; + var angleMultiplier = (Math.PI * 2) / this.getValueCount(); // Start from the top instead of right, so remove a quarter of the circle return index * angleMultiplier - (Math.PI / 2); @@ -362,7 +364,7 @@ } else { // Draw straight lines connecting each index ctx.beginPath(); - for (var i = 0; i < this.valuesCount; i++) { + for (var i = 0; i < this.getValueCount(); i++) { var pointPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.ticks[index])); if (i === 0) { ctx.moveTo(pointPosition.x, pointPosition.y); @@ -401,7 +403,7 @@ ctx.lineWidth = this.options.angleLines.lineWidth; ctx.strokeStyle = this.options.angleLines.color; - for (var i = this.valuesCount - 1; i >= 0; i--) { + for (var i = this.getValueCount() - 1; i >= 0; i--) { if (this.options.angleLines.show) { var outerPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max)); ctx.beginPath(); From 5f6e2a0af3cf6d9509ebeccc7c1b459d83f34a55 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 19 Jun 2015 12:36:35 -0600 Subject: [PATCH 216/424] Gulp build --- Chart.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chart.min.js b/Chart.min.js index ba642a9839e..177c42adc38 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,7 +7,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){ +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){ this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a); }.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js From 85e928b42619fc3278b74c4f5829465fe8aa9d8a Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 19 Jun 2015 13:29:36 -0600 Subject: [PATCH 217/424] Lazy Update and Render option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Usage: `.update(animationDuration, [bool])` Tooltip animations are now "lazy” by default, meaning they can be interrupted and pivoted by other animations. All others internal updates are by nature non-interruptible, so hovering over a chart during a regular `update()` cycle will pivot the tooltip correctly. --- Chart.js | 18 +++++++++--------- Chart.min.js | 6 +++--- src/core/core.animation.js | 4 ++-- src/core/core.controller.js | 14 +++++++------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Chart.js b/Chart.js index 808dd8ad0ac..cec1cfe50da 100644 --- a/Chart.js +++ b/Chart.js @@ -1092,9 +1092,9 @@ frameDuration: 17, animations: [], dropFrames: 0, - addAnimation: function(chartInstance, animationObject, duration) { + addAnimation: function(chartInstance, animationObject, duration, lazy) { - if (typeof duration !== 'number' || duration === 0) { + if (!lazy) { chartInstance.animating = true; } @@ -1263,7 +1263,7 @@ } else { this.data.datasets.push(dataset); } - + this.buildOrUpdateControllers(); dataset.controller.reset(); // so that animation looks ok this.update(); @@ -1283,7 +1283,7 @@ if (index === undefined) { index = this.data.datasets[datasetIndex].data.length; } - + this.data.datasets[datasetIndex].data.splice(index, 0, data); this.data.datasets[datasetIndex].controller.addElementAndReset(index); this.update(); @@ -1403,16 +1403,16 @@ }, - update: function update(animationDuration) { + update: function update(animationDuration, lazy) { // This will loop through any data and do the appropriate element update for the type Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.update(); }, this); - this.render(animationDuration); + this.render(animationDuration, lazy); }, - render: function render(duration) { + render: function render(duration, lazy) { if (this.options.animation.duration !== 0 || duration) { var animation = new Chart.Animation(); @@ -1432,7 +1432,7 @@ animation.onAnimationProgress = this.options.onAnimationProgress; animation.onAnimationComplete = this.options.onAnimationComplete; - Chart.animationService.addAnimation(this, animation, duration); + Chart.animationService.addAnimation(this, animation, duration, lazy); } else { this.draw(); this.options.onAnimationComplete.call(this); @@ -1666,7 +1666,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hover.animationDuration); + this.update(this.options.hover.animationDuration, true); } } diff --git a/Chart.min.js b/Chart.min.js index 177c42adc38..0f06a833a03 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a){("number"!=typeof a||0===a)&&(t.animating=!0);for(var s=0;s1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){ -this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a); -}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[]; +var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={ +display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha diff --git a/src/core/core.animation.js b/src/core/core.animation.js index 06cf54190e1..a61f5e0a14a 100644 --- a/src/core/core.animation.js +++ b/src/core/core.animation.js @@ -27,9 +27,9 @@ frameDuration: 17, animations: [], dropFrames: 0, - addAnimation: function(chartInstance, animationObject, duration) { + addAnimation: function(chartInstance, animationObject, duration, lazy) { - if (typeof duration !== 'number' || duration === 0) { + if (!lazy) { chartInstance.animating = true; } diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 312de25b5b0..a4f202bc51b 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -81,7 +81,7 @@ } else { this.data.datasets.push(dataset); } - + this.buildOrUpdateControllers(); dataset.controller.reset(); // so that animation looks ok this.update(); @@ -101,7 +101,7 @@ if (index === undefined) { index = this.data.datasets[datasetIndex].data.length; } - + this.data.datasets[datasetIndex].data.splice(index, 0, data); this.data.datasets[datasetIndex].controller.addElementAndReset(index); this.update(); @@ -221,16 +221,16 @@ }, - update: function update(animationDuration) { + update: function update(animationDuration, lazy) { // This will loop through any data and do the appropriate element update for the type Chart.scaleService.fitScalesForChart(this, this.chart.width, this.chart.height); helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.update(); }, this); - this.render(animationDuration); + this.render(animationDuration, lazy); }, - render: function render(duration) { + render: function render(duration, lazy) { if (this.options.animation.duration !== 0 || duration) { var animation = new Chart.Animation(); @@ -250,7 +250,7 @@ animation.onAnimationProgress = this.options.onAnimationProgress; animation.onAnimationComplete = this.options.onAnimationComplete; - Chart.animationService.addAnimation(this, animation, duration); + Chart.animationService.addAnimation(this, animation, duration, lazy); } else { this.draw(); this.options.onAnimationComplete.call(this); @@ -484,7 +484,7 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.render(this.options.hover.animationDuration); + this.update(this.options.hover.animationDuration, true); } } From 539af61e1ff779a4c0717f6ed24ed203ba4daac7 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 19 Jun 2015 14:23:05 -0600 Subject: [PATCH 218/424] Proper stacking order for stacked area charts --- Chart.js | 4 ++-- Chart.min.js | 4 ++-- src/core/core.controller.js | 2 +- src/scales/scale.linear.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Chart.js b/Chart.js index cec1cfe50da..6c0c93fd777 100644 --- a/Chart.js +++ b/Chart.js @@ -1455,7 +1455,7 @@ // Draw each dataset via its respective controller (reversed to support proper line stacking) helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.draw(ease); - }, this, true); + }, this); // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); @@ -3911,7 +3911,7 @@ var offsetPos = 0; var offsetNeg = 0; - for (var i = 0; i < datasetIndex; ++i) { + for (var i = this.data.datasets.length - 1; i > datasetIndex; --i) { if (this.data.datasets[i].data[index] < 0) { offsetNeg += this.data.datasets[i].data[index]; } else { diff --git a/Chart.min.js b/Chart.min.js index 0f06a833a03..6e3484dd01f 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[]; +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[]; var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={ -display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=0;i>n;++n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha diff --git a/src/core/core.controller.js b/src/core/core.controller.js index a4f202bc51b..94df818a6f5 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -273,7 +273,7 @@ // Draw each dataset via its respective controller (reversed to support proper line stacking) helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.draw(ease); - }, this, true); + }, this); // Finally draw the tooltip this.tooltip.transition(easingDecimal).draw(); diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index ce2fa8eb19d..21a6e43223d 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -243,7 +243,7 @@ var offsetPos = 0; var offsetNeg = 0; - for (var i = 0; i < datasetIndex; ++i) { + for (var i = this.data.datasets.length - 1; i > datasetIndex; --i) { if (this.data.datasets[i].data[index] < 0) { offsetNeg += this.data.datasets[i].data[index]; } else { From 2dd49f0c9217759e7e670d69c82e77c7a043dbdb Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 19 Jun 2015 19:13:31 -0400 Subject: [PATCH 219/424] Fix a missing `this` in the scale `generateTicks` method when manually overriding. Added a sample to test this. --- samples/line-scale-override.html | 131 +++++++++++++++++++++++++++++++ src/scales/scale.linear.js | 2 +- src/scales/scale.radialLinear.js | 2 +- 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 samples/line-scale-override.html diff --git a/samples/line-scale-override.html b/samples/line-scale-override.html new file mode 100644 index 00000000000..6603b5c043d --- /dev/null +++ b/samples/line-scale-override.html @@ -0,0 +1,131 @@ + + + + + Line Chart with Scale Override + + + + + +
    + +
    +
    +
    + + + + + + + + + diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 21a6e43223d..ceeae97c148 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -61,7 +61,7 @@ // we get the final line for (var i = 0; i <= this.options.override.steps; ++i) { var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); + this.ticks.push(value); } } else { // Figure out what the max number of ticks we can support it is based on the size of diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 0a1a26b45af..0e9c763b30d 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -129,7 +129,7 @@ // we get the final line for (var i = 0; i <= this.options.override.steps; ++i) { var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); + this.ticks.push(value); } } else { // Figure out what the max number of ticks we can support it is based on the size of From 46af76a8ed01dc705ea80d5aa5fb0362dcd6b5d1 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 19 Jun 2015 19:51:28 -0400 Subject: [PATCH 220/424] addData is now supported by the doughnut chart + updated the sample to match. --- samples/doughnut.html | 40 ++++++++-- src/controllers/controller.doughnut.js | 104 +++++++++++++++---------- src/core/core.controller.js | 7 +- 3 files changed, 103 insertions(+), 48 deletions(-) diff --git a/samples/doughnut.html b/samples/doughnut.html index f2746557a26..f2c4282f848 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -24,6 +24,8 @@ + + diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index dc8cbdc352b..454ec549899 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -63,7 +63,25 @@ }); }, this); }, + addElementAndReset: function(index, colorForNewElement) { + this.getDataset().metaData = this.getDataset().metaData || []; + var arc = new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + this.getDataset().backgroundColor.splice(index, 0, colorForNewElement); + // Reset the point + this.updateElement(arc, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, arc); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); }, @@ -84,58 +102,60 @@ this.innerRadius = this.outerRadius - this.chart.radiusLength; helpers.each(this.getDataset().metaData, function(arc, index) { - - var resetModel = { + this.updateElement(arc, index, reset); + }, this); + }, + updateElement: function(arc, index, reset) { + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(this.getDataset().data[index]), + outerRadius: (this.chart.options.animation.animateScale) ? 0 : this.outerRadius, + innerRadius: (this.chart.options.animation.animateScale) ? 0 : this.innerRadius, + }; + + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + + // Desired view properties + _model: reset ? resetModel : { x: this.chart.chart.width / 2, y: this.chart.chart.height / 2, - startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(this.getDataset().data[index]), - outerRadius: (this.chart.options.animation.animateScale) ? 0 : this.outerRadius, - innerRadius: (this.chart.options.animation.animateScale) ? 0 : this.innerRadius, - }; - - helpers.extend(arc, { - // Utility - _chart: this.chart.chart, - _datasetIndex: this.index, - _index: index, + circumference: this.calculateCircumference(this.getDataset().data[index]), + outerRadius: this.outerRadius, + innerRadius: this.innerRadius, - // Desired view properties - _model: reset ? resetModel : { - x: this.chart.chart.width / 2, - y: this.chart.chart.height / 2, - circumference: this.calculateCircumference(this.getDataset().data[index]), - outerRadius: this.outerRadius, - innerRadius: this.innerRadius, - - backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), - hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), - borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), - borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - - label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index]) - }, - }); + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - if (!reset) { + label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index]) + }, + }); - if (index === 0) { - arc._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - } else { - arc._model.startAngle = this.getDataset().metaData[index - 1]._model.endAngle; - } + if (!reset) { - arc._model.endAngle = arc._model.startAngle + arc._model.circumference; + if (index === 0) { + arc._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + } else { + arc._model.startAngle = this.getDataset().metaData[index - 1]._model.endAngle; + } + + arc._model.endAngle = arc._model.startAngle + arc._model.circumference; - //Check to see if it's the last arc, if not get the next and update its start angle - if (index < this.getDataset().data.length - 1) { - this.getDataset().metaData[index + 1]._model.startAngle = arc._model.endAngle; - } + //Check to see if it's the last arc, if not get the next and update its start angle + if (index < this.getDataset().data.length - 1) { + this.getDataset().metaData[index + 1]._model.startAngle = arc._model.endAngle; } + } - arc.pivot(); - }, this); + arc.pivot(); }, draw: function(ease) { diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 94df818a6f5..439fe523042 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -102,8 +102,13 @@ index = this.data.datasets[datasetIndex].data.length; } + var addElementArgs = [index]; + for (var i = 3; i < arguments.length; ++i) { + addElementArgs.push(arguments[i]); + } + this.data.datasets[datasetIndex].data.splice(index, 0, data); - this.data.datasets[datasetIndex].controller.addElementAndReset(index); + this.data.datasets[datasetIndex].controller.addElementAndReset.apply(this.data.datasets[datasetIndex].controller, addElementArgs); this.update(); } }, From 48be4edbdd0ed0f485abbf510c38d2225f4beed8 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 19 Jun 2015 20:24:14 -0400 Subject: [PATCH 221/424] Category scale label rotation improvements --- src/scales/scale.category.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index ffac6fe2100..7e861dfd7c2 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -113,7 +113,7 @@ var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; //Max label rotate should be 90 - also act as a loop counter - while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { + while (this.labelWidth > gridWidth && this.labelRotation <= 90) { cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); @@ -157,6 +157,13 @@ // @param {number} maxHeight: the max height the axis can be // @return {object} minSize : the minimum size needed to draw the axis fit: function(maxWidth, maxHeight, margins) { + // Set the unconstrained dimension before label rotation + if (this.isHorizontal()) { + this.width = maxWidth; + } else { + this.height = maxHeight; + } + this.calculateLabelRotation(maxHeight, margins); var minSize = { @@ -170,17 +177,16 @@ // Width if (this.isHorizontal()) { minSize.width = maxWidth; - this.width = maxWidth; } else if (this.options.display) { minSize.width = Math.min(longestLabelWidth + 6, maxWidth); } // Height if (this.isHorizontal() && this.options.display) { - var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; minSize.height = Math.min(labelHeight, maxHeight); } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + minSize.height = maxHeight; } this.width = minSize.width; From 82de2f135135f63ba07ad2ae6598c538a97653f0 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 20 Jun 2015 09:47:35 -0400 Subject: [PATCH 222/424] Can now change more properties for line drawing. Updated the sample file to demo --- samples/line.html | 1 + src/controllers/controller.line.js | 4 ++++ src/elements/element.line.js | 12 +++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/samples/line.html b/samples/line.html index f4962480f4c..edcca91ecfa 100644 --- a/samples/line.html +++ b/samples/line.html @@ -42,6 +42,7 @@ label: "My First dataset", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], fill: false, + borderDash: [5, 5], }, { label: "My Second dataset", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index 34680dc068a..d007498a896 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -131,6 +131,10 @@ backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor), borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth), borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor), + borderCapStyle: line.custom && line.custom.borderCapStyle ? line.custom.borderCapStyle : (this.getDataset().borderCapStyle || this.chart.options.elements.line.borderCapStyle), + borderDash: line.custom && line.custom.borderDash ? line.custom.borderDash : (this.getDataset().borderDash || this.chart.options.elements.line.borderDash), + borderDashOffset: line.custom && line.custom.borderDashOffset ? line.custom.borderDashOffset : (this.getDataset().borderDashOffset || this.chart.options.elements.line.borderDashOffset), + borderJoinStyle: line.custom && line.custom.borderJoinStyle ? line.custom.borderJoinStyle : (this.getDataset().borderJoinStyle || this.chart.options.elements.line.borderJoinStyle), fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill), skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, diff --git a/src/elements/element.line.js b/src/elements/element.line.js index bd5ba83269c..c03f066848a 100644 --- a/src/elements/element.line.js +++ b/src/elements/element.line.js @@ -22,6 +22,10 @@ backgroundColor: Chart.defaults.global.defaultColor, borderWidth: 3, borderColor: Chart.defaults.global.defaultColor, + borderCapStyle: 'butt', + borderDash: [], + borderDashOffset: 0.0, + borderJoinStyle: 'miter', fill: true, // do we fill in the area between the line and its base axis skipNull: true, drawNull: false, @@ -36,6 +40,8 @@ var first = this._children[0]; var last = this._children[this._children.length - 1]; + ctx.save(); + // Draw the background first (so the border is always on top) helpers.each(this._children, function(point, index) { var previous = helpers.previousItem(this._children, index); @@ -107,6 +113,10 @@ // Now draw the line between all the points with any borders + ctx.lineCap = vm.borderCapStyle || Chart.defaults.global.elements.line.borderCapStyle; + ctx.setLineDash(vm.borderDash || Chart.defaults.global.elements.line.borderDash); + ctx.lineDashOffset = vm.borderDashOffset || Chart.defaults.global.elements.line.borderDashOffset; + ctx.lineJoin = vm.borderJoinStyle || Chart.defaults.global.elements.line.borderJoinStyle; ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; ctx.beginPath(); @@ -171,7 +181,7 @@ ctx.stroke(); - + ctx.restore(); }, }); From 25fd84490b722aa4046b412251bcb16ec6496611 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 22 Jun 2015 13:10:49 -0600 Subject: [PATCH 223/424] Support for custom tooltips again --- samples/line-customTooltips.html | 130 ++++++++++++++++++------------- src/core/core.controller.js | 2 +- src/core/core.tooltip.js | 18 ++++- 3 files changed, 89 insertions(+), 61 deletions(-) diff --git a/samples/line-customTooltips.html b/samples/line-customTooltips.html index a9ee1b85cd6..a480f809240 100644 --- a/samples/line-customTooltips.html +++ b/samples/line-customTooltips.html @@ -5,22 +5,22 @@ Line Chart with Custom Tooltips - @@ -40,48 +41,80 @@
    -
    - -
    - -
    - - diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 94df818a6f5..0ec57829041 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -446,7 +446,7 @@ // Built in Tooltips - if (this.options.tooltips.enabled) { + if (this.options.tooltips.enabled || this.options.tooltips.custom) { // The usual updates this.tooltip.initialize(); diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 1423f7ae5f1..90539681a64 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -207,10 +207,6 @@ var ctx = this._chart.ctx; var vm = this._view; - if (this._options.tooltips.custom) { - this._options.tooltips.custom(this); - } - switch (this._options.hover.mode) { case 'single': @@ -242,6 +238,12 @@ ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + if (!this._options.tooltips.enabled) { + return; + } switch (vm.yAlign) { case "above": @@ -285,6 +287,14 @@ break; case 'label': + // Custom Tooltips + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + if (!this._options.tooltips.enabled) { + return; + } + helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); ctx.fill(); From 9368c6079d989527dcd2072b6f18780b53e3113c Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 22 Jun 2015 13:11:19 -0600 Subject: [PATCH 224/424] Gulp build --- Chart.js | 161 ++++++++++++++++++++++++++++++++++----------------- Chart.min.js | 10 ++-- 2 files changed, 113 insertions(+), 58 deletions(-) diff --git a/Chart.js b/Chart.js index 6c0c93fd777..72834ddbc7a 100644 --- a/Chart.js +++ b/Chart.js @@ -1284,8 +1284,13 @@ index = this.data.datasets[datasetIndex].data.length; } + var addElementArgs = [index]; + for (var i = 3; i < arguments.length; ++i) { + addElementArgs.push(arguments[i]); + } + this.data.datasets[datasetIndex].data.splice(index, 0, data); - this.data.datasets[datasetIndex].controller.addElementAndReset(index); + this.data.datasets[datasetIndex].controller.addElementAndReset.apply(this.data.datasets[datasetIndex].controller, addElementArgs); this.update(); } }, @@ -1628,7 +1633,7 @@ // Built in Tooltips - if (this.options.tooltips.enabled) { + if (this.options.tooltips.enabled || this.options.tooltips.custom) { // The usual updates this.tooltip.initialize(); @@ -2187,10 +2192,6 @@ var ctx = this._chart.ctx; var vm = this._view; - if (this._options.tooltips.custom) { - this._options.tooltips.custom(this); - } - switch (this._options.hover.mode) { case 'single': @@ -2222,6 +2223,12 @@ ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + if (!this._options.tooltips.enabled) { + return; + } switch (vm.yAlign) { case "above": @@ -2265,6 +2272,14 @@ break; case 'label': + // Custom Tooltips + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + if (!this._options.tooltips.enabled) { + return; + } + helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); ctx.fill(); @@ -2548,7 +2563,25 @@ }); }, this); }, + addElementAndReset: function(index, colorForNewElement) { + this.getDataset().metaData = this.getDataset().metaData || []; + var arc = new Chart.elements.Arc({ + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, + }); + + this.getDataset().backgroundColor.splice(index, 0, colorForNewElement); + // Reset the point + this.updateElement(arc, index, true); + + // Add to the points array + this.getDataset().metaData.splice(index, 0, arc); + }, + removeElement: function(index) { + this.getDataset().metaData.splice(index, 1); + }, reset: function() { this.update(true); }, @@ -2569,58 +2602,60 @@ this.innerRadius = this.outerRadius - this.chart.radiusLength; helpers.each(this.getDataset().metaData, function(arc, index) { + this.updateElement(arc, index, reset); + }, this); + }, + updateElement: function(arc, index, reset) { + var resetModel = { + x: this.chart.chart.width / 2, + y: this.chart.chart.height / 2, + startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(this.getDataset().data[index]), + outerRadius: (this.chart.options.animation.animateScale) ? 0 : this.outerRadius, + innerRadius: (this.chart.options.animation.animateScale) ? 0 : this.innerRadius, + }; + + helpers.extend(arc, { + // Utility + _chart: this.chart.chart, + _datasetIndex: this.index, + _index: index, - var resetModel = { + // Desired view properties + _model: reset ? resetModel : { x: this.chart.chart.width / 2, y: this.chart.chart.height / 2, - startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(this.getDataset().data[index]), - outerRadius: (this.chart.options.animation.animateScale) ? 0 : this.outerRadius, - innerRadius: (this.chart.options.animation.animateScale) ? 0 : this.innerRadius, - }; - - helpers.extend(arc, { - // Utility - _chart: this.chart.chart, - _datasetIndex: this.index, - _index: index, + circumference: this.calculateCircumference(this.getDataset().data[index]), + outerRadius: this.outerRadius, + innerRadius: this.innerRadius, - // Desired view properties - _model: reset ? resetModel : { - x: this.chart.chart.width / 2, - y: this.chart.chart.height / 2, - circumference: this.calculateCircumference(this.getDataset().data[index]), - outerRadius: this.outerRadius, - innerRadius: this.innerRadius, - - backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), - hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), - borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), - borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), + backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor), + hoverBackgroundColor: arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor, index, this.chart.options.elements.arc.hoverBackgroundColor), + borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth), + borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor), - label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index]) - }, - }); + label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index]) + }, + }); - if (!reset) { + if (!reset) { - if (index === 0) { - arc._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function - } else { - arc._model.startAngle = this.getDataset().metaData[index - 1]._model.endAngle; - } + if (index === 0) { + arc._model.startAngle = Math.PI * -0.5; // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function + } else { + arc._model.startAngle = this.getDataset().metaData[index - 1]._model.endAngle; + } - arc._model.endAngle = arc._model.startAngle + arc._model.circumference; + arc._model.endAngle = arc._model.startAngle + arc._model.circumference; - //Check to see if it's the last arc, if not get the next and update its start angle - if (index < this.getDataset().data.length - 1) { - this.getDataset().metaData[index + 1]._model.startAngle = arc._model.endAngle; - } + //Check to see if it's the last arc, if not get the next and update its start angle + if (index < this.getDataset().data.length - 1) { + this.getDataset().metaData[index + 1]._model.startAngle = arc._model.endAngle; } + } - arc.pivot(); - }, this); + arc.pivot(); }, draw: function(ease) { @@ -2796,6 +2831,10 @@ backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor), borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth), borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor), + borderCapStyle: line.custom && line.custom.borderCapStyle ? line.custom.borderCapStyle : (this.getDataset().borderCapStyle || this.chart.options.elements.line.borderCapStyle), + borderDash: line.custom && line.custom.borderDash ? line.custom.borderDash : (this.getDataset().borderDash || this.chart.options.elements.line.borderDash), + borderDashOffset: line.custom && line.custom.borderDashOffset ? line.custom.borderDashOffset : (this.getDataset().borderDashOffset || this.chart.options.elements.line.borderDashOffset), + borderJoinStyle: line.custom && line.custom.borderJoinStyle ? line.custom.borderJoinStyle : (this.getDataset().borderJoinStyle || this.chart.options.elements.line.borderJoinStyle), fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill), skipNull: this.getDataset().skipNull !== undefined ? this.getDataset().skipNull : this.chart.options.elements.line.skipNull, drawNull: this.getDataset().drawNull !== undefined ? this.getDataset().drawNull : this.chart.options.elements.line.drawNull, @@ -3515,7 +3554,7 @@ var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; //Max label rotate should be 90 - also act as a loop counter - while ((this.labelWidth > gridWidth && this.labelRotation === 0) || (this.labelWidth > gridWidth && this.labelRotation <= 90 && this.labelRotation > 0)) { + while (this.labelWidth > gridWidth && this.labelRotation <= 90) { cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); @@ -3559,6 +3598,13 @@ // @param {number} maxHeight: the max height the axis can be // @return {object} minSize : the minimum size needed to draw the axis fit: function(maxWidth, maxHeight, margins) { + // Set the unconstrained dimension before label rotation + if (this.isHorizontal()) { + this.width = maxWidth; + } else { + this.height = maxHeight; + } + this.calculateLabelRotation(maxHeight, margins); var minSize = { @@ -3572,17 +3618,16 @@ // Width if (this.isHorizontal()) { minSize.width = maxWidth; - this.width = maxWidth; } else if (this.options.display) { minSize.width = Math.min(longestLabelWidth + 6, maxWidth); } // Height if (this.isHorizontal() && this.options.display) { - var labelHeight = (Math.cos(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; minSize.height = Math.min(labelHeight, maxHeight); } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + minSize.height = maxHeight; } this.width = minSize.width; @@ -3729,7 +3774,7 @@ // we get the final line for (var i = 0; i <= this.options.override.steps; ++i) { var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); + this.ticks.push(value); } } else { // Figure out what the max number of ticks we can support it is based on the size of @@ -4371,7 +4416,7 @@ // we get the final line for (var i = 0; i <= this.options.override.steps; ++i) { var value = this.options.override.start + (i * this.options.override.stepWidth); - ticks.push(value); + this.ticks.push(value); } } else { // Figure out what the max number of ticks we can support it is based on the size of @@ -4812,6 +4857,10 @@ backgroundColor: Chart.defaults.global.defaultColor, borderWidth: 3, borderColor: Chart.defaults.global.defaultColor, + borderCapStyle: 'butt', + borderDash: [], + borderDashOffset: 0.0, + borderJoinStyle: 'miter', fill: true, // do we fill in the area between the line and its base axis skipNull: true, drawNull: false, @@ -4826,6 +4875,8 @@ var first = this._children[0]; var last = this._children[this._children.length - 1]; + ctx.save(); + // Draw the background first (so the border is always on top) helpers.each(this._children, function(point, index) { var previous = helpers.previousItem(this._children, index); @@ -4897,6 +4948,10 @@ // Now draw the line between all the points with any borders + ctx.lineCap = vm.borderCapStyle || Chart.defaults.global.elements.line.borderCapStyle; + ctx.setLineDash(vm.borderDash || Chart.defaults.global.elements.line.borderDash); + ctx.lineDashOffset = vm.borderDashOffset || Chart.defaults.global.elements.line.borderDashOffset; + ctx.lineJoin = vm.borderJoinStyle || Chart.defaults.global.elements.line.borderJoinStyle; ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; ctx.beginPath(); @@ -4961,7 +5016,7 @@ ctx.stroke(); - + ctx.restore(); }, }); diff --git a/Chart.min.js b/Chart.min.js index 6e3484dd01f..b40c67ff490 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,k=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){k+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:k};e&&t.fit(e.minSize.width,v,a)});var D=s,A=o,S=function(t){t.left=D,t.right=D+t.width,t.top=_,t.bottom=_+v,D=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),D+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.tooltips.custom&&this._options.tooltips.custom(this),this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;switch(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[]; -var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(e,{_chart:this.chart.chart,_datasetIndex:this.index,_index:a,_model:t?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[a]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:e.custom&&e.custom.backgroundColor?e.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,a,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:e.custom&&e.custom.hoverBackgroundColor?e.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,a,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:e.custom&&e.custom.borderWidth?e.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,a,this.chart.options.elements.arc.borderWidth),borderColor:e.custom&&e.custom.borderColor?e.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,a,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,a,this.chart.data.labels[a])}}),t||(0===a?e._model.startAngle=Math.PI*-.5:e._model.startAngle=this.getDataset().metaData[a-1]._model.endAngle,e._model.endAngle=e._model.startAngle+e._model.circumference,a0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&0===this.labelRotation||this.labelWidth>u&&this.labelRotation<=90&&this.labelRotation>0;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?(s.width=t,this.width=t):this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.cos(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.width=Math.min(n+6,t));return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={ -display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,D=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){D+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)});var k=s,A=o,S=function(t){t.left=k,t.right=k+t.width,t.top=_,t.bottom=_+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),k+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[], +i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(0===e?t._model.startAngle=Math.PI*-.5:t._model.startAngle=this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&this.labelRotation<=90;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor, +this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -27,7 +27,7 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,s=this._children[0],o=this._children[this._children.length-1];i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(o._view.x,e._view.y),a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,o._view.y),a.lineTo(e._view.x,e._view.y)),void(o._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!s._view.skip?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(o._view.x,e._view.y),void a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,o._view.y),void a.moveTo(e._view.x,e._view.y)):o._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!s._view.skip&&(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),a.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,s=this._children[0],o=this._children[this._children.length-1];a.save(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(o._view.x,e._view.y),a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,o._view.y),a.lineTo(e._view.x,e._view.y)),void(o._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!s._view.skip?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineCap=t.borderCapStyle||e.defaults.global.elements.line.borderCapStyle,a.setLineDash(t.borderDash||e.defaults.global.elements.line.borderDash),a.lineDashOffset=t.borderDashOffset||e.defaults.global.elements.line.borderDashOffset,a.lineJoin=t.borderJoinStyle||e.defaults.global.elements.line.borderJoinStyle,a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(o._view.x,e._view.y),void a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,o._view.y),void a.moveTo(e._view.x,e._view.y)):o._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!s._view.skip&&(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),a.stroke(),a.restore()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return J[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function k(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function D(t){return a(k(t))}function A(t){return s(k(t))}function S(t){return n(k(t))}function P(t){return h(k(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function z(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function F(t){return B(z(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function E(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function N(t){return L(E(t))}function H(t){return T(E(t))}function q(t){return $[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function Q(t){return n(q(t))}function U(t){return c(q(t))}function Z(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:k,hwb2hsl:D,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:Q,keyword2lab:U,keyword2xyz:Z,xyz2rgb:O,xyz2lab:z,xyz2lch:F,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:E,lch2xyz:N,lch2rgb:H};var $={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},J={};for(var G in $)J[JSON.stringify($[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return a(D(t))}function A(t){return s(D(t))}function S(t){return n(D(t))}function P(t){return h(D(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function z(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function F(t){return B(z(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function E(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function N(t){return L(E(t))}function H(t){return T(E(t))}function q(t){return Z[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function J(t){return n(q(t))}function Q(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:D,hwb2hsl:k,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:J,keyword2lab:Q,keyword2xyz:U,xyz2rgb:O,xyz2lab:z,xyz2lch:F,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:E,lch2xyz:N,lch2rgb:H};var Z={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var G in Z)$[JSON.stringify(Z[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From 880ae3a4747373bf74ac643cadaeb7b2c2f852d2 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 22 Jun 2015 18:46:12 -0400 Subject: [PATCH 225/424] Update getting started docs --- docs/00-Getting-Started.md | 55 +++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index 3c2b6435fb6..9e56b65cd01 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -46,7 +46,10 @@ To create a chart, we need to instantiate the `Chart` class. To do this, we need ```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); +var myNewChart = Chart.PolarArea(chart, { + data: data, + options: config +}); ``` 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. @@ -63,7 +66,27 @@ After we've instantiated the Chart class on the canvas we want to draw on, Chart 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); +var myChart = Chart.PolarArea(ctx, { + data: data, + options: options +}); +``` + +To create a scatter chart, which is a special configuration of a line chart, we use the following. +```javascript +var myScatterChart = Chart.Scatter(ctx, { + data: data, + options: options +}); +``` + +Alternatively, we can use the more advanced API to create simple chart types. . In the example below, we are creating a line chart +```javascript +var myChart = new Chart(ctx, { + type: 'line', // built in types are 'line', 'bar', 'radar', 'polarArea', 'doughnut', + data: data, + options: 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. @@ -211,8 +234,20 @@ Chart.defaults.global = { // Number - width of the line borderWidth: 3, - // String = color of the line + // String - color of the line borderColor: defaultColor, + + // String - cap style of the line. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap + borderCapStyle: 'butt', + + // Array - Length and spacing of dashes. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash + borderDash: [], + + // Number - Offset for line dashes. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset + borderDashOffset: 0.0, + + // String - line join style. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin + borderJoinStyle: 'miter', // Boolean - if true fill in the area between the line and the x axis with the background color fill: true, @@ -238,7 +273,7 @@ Chart.defaults.global = { borderColor: defaultColor, // Number - extra radius added to radius for hit detection - hitRadius: 6, + hitRadius: 1, // Number - radius of point circle when hovered hoverRadius: 4, @@ -247,7 +282,7 @@ Chart.defaults.global = { hoverBorderWidth: 2, }, // Settings for all bar elements - bar: { + rectangle: { // String - fill color of bar backgroundColor: defaultColor, @@ -256,15 +291,9 @@ Chart.defaults.global = { // String - Border color borderColor: defaultColor, - - // Number - - valueSpacing: 5, - - // Number - - datasetSpacing: 1, }, - // Settings for all slice elements - slice: { + // Settings for all arc elements + arc: { // String - fill color backgroundColor: defaultColor, From 6110352df8c732dcda28777bdd87abd25ddf74f8 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 22 Jun 2015 19:03:01 -0400 Subject: [PATCH 226/424] Add userCallback to category scale + demo file --- samples/line-x-axis-filter.html | 138 ++++++++++++++++++++++++++++++++ src/scales/scale.category.js | 26 ++++-- 2 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 samples/line-x-axis-filter.html diff --git a/samples/line-x-axis-filter.html b/samples/line-x-axis-filter.html new file mode 100644 index 00000000000..3b5b82f280a --- /dev/null +++ b/samples/line-x-axis-filter.html @@ -0,0 +1,138 @@ + + + + + Chart with xAxis Filtering + + + + + + +
    + +
    +
    +
    + + + + + + + + + diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 7e861dfd7c2..2b233048f85 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -37,13 +37,24 @@ isHorizontal: function() { return this.options.position == "top" || this.options.position == "bottom"; }, + buildLabels: function(index) { + this.labels = []; + + if (this.options.labels.userCallback) { + this.data.labels.forEach(function(labelString, index) { + this.labels.push(this.options.labels.userCallback(labelString, index)); + }, this); + } else { + this.labels = this.data.labels; + } + }, getPixelForValue: function(value, index, datasetIndex, includeOffset) { // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined if (this.isHorizontal()) { var isRotated = (this.labelRotation > 0); var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.data.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); var valueOffset = (valueWidth * index) + this.paddingLeft; if (this.options.gridLines.offsetGridLines && includeOffset) { @@ -52,7 +63,7 @@ return this.left + Math.round(valueOffset); } else { - return this.top + (index * (this.height / this.data.labels.length)); + return this.top + (index * (this.height / this.labels.length)); } }, getPointPixelForValue: function(value, index, datasetIndex) { @@ -90,8 +101,8 @@ var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); this.ctx.font = labelFont; - var firstWidth = this.ctx.measureText(this.data.labels[0]).width; - var lastWidth = this.ctx.measureText(this.data.labels[this.data.labels.length - 1]).width; + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; var firstRotated; var lastRotated; @@ -101,7 +112,7 @@ this.labelRotation = 0; if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); var cosRotation; var sinRotation; var firstRotatedWidth; @@ -164,6 +175,7 @@ this.height = maxHeight; } + this.buildLabels(); this.calculateLabelRotation(maxHeight, margins); var minSize = { @@ -172,7 +184,7 @@ }; var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); // Width if (this.isHorizontal()) { @@ -209,7 +221,7 @@ var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; var isRotated = this.labelRotation !== 0; - helpers.each(this.data.labels, function(label, index) { + helpers.each(this.labels, function(label, index) { var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) From 255bdc700ec8ca22a4c79db11d7d6703039d752c Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 22 Jun 2015 19:05:50 -0400 Subject: [PATCH 227/424] Line chart doc updates --- docs/01-Line-Chart.md | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/01-Line-Chart.md b/docs/01-Line-Chart.md index 986ec3f426f..7db1bbeb929 100644 --- a/docs/01-Line-Chart.md +++ b/docs/01-Line-Chart.md @@ -13,7 +13,16 @@ Often, it is used to show trend data, and the comparison of two data sets. ###Example usage ```javascript -var myLineChart = new Chart(ctx).Line({ +var myLineChart = new Chart(ctx, { + type: 'line', + data: data, + options: options +}); +``` + +Alternatively a line chart can be created using syntax similar to the v1.0 syntax +```javascript +var myLineChart = Chart.Line(ctx, { data: data, options: options }); @@ -38,6 +47,18 @@ var data = { // String or array - 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 + borderCapStyle: 'butt', + + // Array - Length and spacing of dashes. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash + borderDash: [], + + // Number - Offset for line dashes. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset + borderDashOffset: 0.0, + + // String - line join style. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin + borderJoinStyle: 'miter', + // String or array - Point stroke color pointBorderColor: "rgba(220,220,220,1)", @@ -245,7 +266,8 @@ You can override these for your `Chart` instance by passing a member `options` i For example, we could have a line chart display without an x axis by doing the following. The config merge is smart enough to handle arrays so that you do not need to specify all axis settings to change one thing. ```javascript -new Chart(ctx).Line({ +new Chart(ctx, { + type: 'line', data: data, options: { xAxes: [{ @@ -262,13 +284,13 @@ We can also change these defaults values for each Line type that is created, thi ### Prototype methods -#### .getPointsAtEvent( event ) +#### .getElementsAtEvent( 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. +Calling `getElementsAtEvent(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); + var activePoints = myLineChart.getElementsAtEvent(evt); // => activePoints is an array of points on the canvas that are at the same position as the click event. }; ``` From 06a2c52b2605d3c995f6cce032c6485bd57cda70 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 22 Jun 2015 19:47:51 -0400 Subject: [PATCH 228/424] Update scale docs. --- docs/00-Getting-Started.md | 171 +++++++++++++++++++++++++++++++++++++ docs/01-Line-Chart.md | 136 +++-------------------------- 2 files changed, 181 insertions(+), 126 deletions(-) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index 9e56b65cd01..49b39a7ccb7 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -314,3 +314,174 @@ Chart.defaults.global.responsive = true; ``` Now, every time we create a chart, `options.responsive` will be `true`. + +## Scales + +Scales in v2.0 of Chart.js are significantly different than those of v1.0. Multiple x & y axes are now supported. Datasets include +additional properties to bind themselves to a specific axis. + + +### Category Scale +The category scale will be familiar to those who have used v1.0. Labels are drawn in from the labels array included in the chart data. The category scale has +the following options. + +```javascript +{ + // Boolean - if true, show the scale + display: true, + + // String - position of the scale. possible options are "top" and "bottom" for category scales + position: "bottom", + + // grid line settings + gridLines: { + // Boolean - if true, show the grid lines + show: true, + + // String - color of the grid lines + color: "rgba(0, 0, 0, 0.05)", + + // Number - width of the grid lines + lineWidth: 1, + + // Boolean - if true draw lines on the chart area + drawOnChartArea: true, + + // Boolean - if true draw ticks in the axis area + drawTicks: true, + + // Number - width of the grid line for the first index (index 0) + zeroLineWidth: 1, + + // String - color of the grid line for the first index + zeroLineColor: "rgba(0,0,0,0.25)", + + // Boolean - if true, offset labels from grid lines + offsetGridLines: false, + }, + + // label settings + labels: { + // Boolean - if true show labels + show: true, + + // String - template string for labels + template: "<%=value%>", + + // Number - label font size + fontSize: 12, + + // String - label font style + fontStyle: "normal", + + // String - label font color + fontColor: "#666", + + // String - label font family + fontFamily: "Helvetica Neue", + + // Function - Can be used to filter the labels. Passed the data label & index + userCallback: null, + }, +} + +``` + +The `userCallback` method may be useful when there are a lot of labels. The following callback would filter out every second label on a category scale +```javascript +{ + scales: { + xAxes: [{ + labels: { + userCallback: function(labelString, index) { + return (index % 2 === 0) ? labelString : ''; + } + } + }] + } +} +``` + +### Linear Scale +The linear scale can be used to display numerical data. It can be placed on either the x or y axis. The scatter chart type automatically configures a line chart to +use one of these scales for the x axis. + +The linear scale supports the following options +```javascript +{ + // Boolean - if true, show the scale + display: true, + + // String - position of axis. Vertical axes can have either "left" or "right" + position: "left", + + // grid line settings + gridLines: { + // Boolean - if true, show the grid lines + show: true, + + // String - color of the grid lines + color: "rgba(0, 0, 0, 0.05)", + + // Number - width of the grid lines + lineWidth: 1, + + // Boolean - if true draw lines on the chart area + drawOnChartArea: true, + + // Boolean - if true draw ticks in the axis area + drawTicks: true, + + // Number - width of the grid line representing a numerical value of 0 + zeroLineWidth: 1, + + // String - color of the grid line representing a numerical value of 0 + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // Boolean - if true ensures that the scale always has a 0 point + beginAtZero: false, + + // Object - if specified, allows the user to override the step generation algorithm. + // Contains the following values + // start: // number to start at + // stepWidth: // size of step + // steps: // number of steps + override: null, + + // label settings + labels: { + // Boolean - if true show labels + show: true, + + // String - template string for labels + template: "<%=value%>", + + // Function - if specified this is passed the tick value, index, and the array of all tick values. Returns a string that is used as the label for that value + userCallback: null, + + // Number - label font size + fontSize: 12, + + // String - label font style + fontStyle: "normal", + + // String - label font color + fontColor: "#666", + + // String - label font family + fontFamily: "Helvetica Neue", + }, +} +``` + +The `userCallback` function allows the user fine grained control over how labels are generated. For instance, to generate every second labels in scientific notation, one could do the following +```javascript +{ + labels: { + userCallback: function(value, index, values) { + return (index % 2 === 0) ? values.toExponential() : ''; + } + } +} +``` \ No newline at end of file diff --git a/docs/01-Line-Chart.md b/docs/01-Line-Chart.md index 7db1bbeb929..840f6cb3473 100644 --- a/docs/01-Line-Chart.md +++ b/docs/01-Line-Chart.md @@ -124,138 +124,22 @@ These are the customisation options specific to Line charts. These options are m }, scales: { - // The line chart officially supports only 1 x-axis but uses an array to keep the API consistent. Use a scatter chart if you need multiple x axes. + // Defines all of the x axes used in the chart. See the [scale documentation](#getting-started-scales) for details on the available options xAxes: [{ - // String - type of axis to use. Should not be changed from 'dataset'. To use a 'linear' axis on the x, use the scatter chart type - scaleType: "dataset", // scatter should not use a dataset axis - - // Boolean - if true, show the scale - display: true, - - // String - position of the scale. possible options are "top" and "bottom" for dataset scales - position: "bottom", + // String - type of scale. Built in types are 'category' and 'linear' + type: 'category', // String - id of the axis so that data can bind to it - id: "x-axis-1", // need an ID so datasets can reference the scale - - // grid line settings - gridLines: { - // Boolean - if true, show the grid lines - show: true, - - // String - color of the grid lines - color: "rgba(0, 0, 0, 0.05)", - - // Number - width of the grid lines - lineWidth: 1, - - // Boolean - if true draw lines on the chart area - drawOnChartArea: true, - - // Boolean - if true draw ticks in the axis area - drawTicks: true, - - // Number - width of the grid line for the first index (index 0) - zeroLineWidth: 1, - - // String - color of the grid line for the first index - zeroLineColor: "rgba(0,0,0,0.25)", - - // Boolean - if true, offset labels from grid lines - offsetGridLines: false, - }, - - // label settings - labels: { - // Boolean - if true show labels - show: true, - - // String - template string for labels - template: "<%=value%>", - - // Number - label font size - fontSize: 12, - - // String - label font style - fontStyle: "normal", - - // String - label font color - fontColor: "#666", - - // String - label font family - fontFamily: "Helvetica Neue", - }, + id: "x-axis-1", // need an ID so datasets can reference the scale }], - yAxes: [{ - // String - type of axis. 'linear' is the default but extensions may provide other types such as logarithmic - scaleType: "linear", - - // Boolean - if true, show the scale - display: true, - // String - position of axis. Vertical axes can have either "left" or "right" - position: "left", - - // ID of the axis for data binding - id: "y-axis-1", - - // grid line settings - gridLines: { - // Boolean - if true, show the grid lines - show: true, - - // String - color of the grid lines - color: "rgba(0, 0, 0, 0.05)", - - // Number - width of the grid lines - lineWidth: 1, - - // Boolean - if true draw lines on the chart area - drawOnChartArea: true, - - // Boolean - if true draw ticks in the axis area - drawTicks: true, - - // Number - width of the grid line representing a numerical value of 0 - zeroLineWidth: 1, - - // String - color of the grid line representing a numerical value of 0 - zeroLineColor: "rgba(0,0,0,0.25)", - }, - - // Boolean - if true ensures that the scale always has a 0 point - beginAtZero: false, - - // Object - if specified, allows the user to override the step generation algorithm. - // Contains the following values - // start: // number to start at - // stepWidth: // size of step - // steps: // number of steps - override: null, - - // label settings - labels: { - // Boolean - if true show labels - show: true, - - // String - template string for labels - template: "<%=value%>", - - // Function - if specified this is passed the tick value, index, and the array of all tick values. Returns a string that is used as the label for that value - userCallback: null, - - // Number - label font size - fontSize: 12, - - // String - label font style - fontStyle: "normal", - - // String - label font color - fontColor: "#666", + // Defines all of the y axes used in the chart. + // By default, the line chart uses a linear scale along the y axis + yAxes: [{ + type: 'linear', - // String - label font family - fontFamily: "Helvetica Neue", - }, + // String - ID of the axis for data binding + id: "y-axis-1", }], } }; From 2baad552f10bb8af78585f180e2f25381bd850d2 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 4 Jul 2015 19:17:01 -0400 Subject: [PATCH 229/424] Built files to include dataset scale changes --- Chart.js | 26 +++++++++++++++++++------- Chart.min.js | 8 ++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Chart.js b/Chart.js index 72834ddbc7a..69eaf454332 100644 --- a/Chart.js +++ b/Chart.js @@ -3478,13 +3478,24 @@ isHorizontal: function() { return this.options.position == "top" || this.options.position == "bottom"; }, + buildLabels: function(index) { + this.labels = []; + + if (this.options.labels.userCallback) { + this.data.labels.forEach(function(labelString, index) { + this.labels.push(this.options.labels.userCallback(labelString, index)); + }, this); + } else { + this.labels = this.data.labels; + } + }, getPixelForValue: function(value, index, datasetIndex, includeOffset) { // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined if (this.isHorizontal()) { var isRotated = (this.labelRotation > 0); var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.data.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); var valueOffset = (valueWidth * index) + this.paddingLeft; if (this.options.gridLines.offsetGridLines && includeOffset) { @@ -3493,7 +3504,7 @@ return this.left + Math.round(valueOffset); } else { - return this.top + (index * (this.height / this.data.labels.length)); + return this.top + (index * (this.height / this.labels.length)); } }, getPointPixelForValue: function(value, index, datasetIndex) { @@ -3531,8 +3542,8 @@ var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); this.ctx.font = labelFont; - var firstWidth = this.ctx.measureText(this.data.labels[0]).width; - var lastWidth = this.ctx.measureText(this.data.labels[this.data.labels.length - 1]).width; + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; var firstRotated; var lastRotated; @@ -3542,7 +3553,7 @@ this.labelRotation = 0; if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); var cosRotation; var sinRotation; var firstRotatedWidth; @@ -3605,6 +3616,7 @@ this.height = maxHeight; } + this.buildLabels(); this.calculateLabelRotation(maxHeight, margins); var minSize = { @@ -3613,7 +3625,7 @@ }; var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.data.labels); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); // Width if (this.isHorizontal()) { @@ -3650,7 +3662,7 @@ var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; var isRotated = this.labelRotation !== 0; - helpers.each(this.data.labels, function(label, index) { + helpers.each(this.labels, function(label, index) { var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) diff --git a/Chart.min.js b/Chart.min.js index b40c67ff490..108a158c5be 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,D=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){D+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)});var k=s,A=o,S=function(t){t.left=k,t.right=k+t.width,t.top=_,t.bottom=_+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=A,t.bottom=A+t.height,A=t.bottom};i.each(n,S),i.each(h,P),k+=b,A+=v,i.each(r,S),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[], -i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(0===e?t._model.startAngle=Math.PI*-.5:t._model.startAngle=this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.data.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.data.labels[0]).width,r=this.ctx.measureText(this.data.labels[this.data.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.data.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&this.labelRotation<=90;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.data.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor, -this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.data.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";{var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):s[a][i]=t.type!==s[a][i].type?e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s[a]=s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?e.configMerge(s[a],t):t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else this._view[a]="number"==typeof i?i*t:i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,D=o,_=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){D+=t.height}),i.each(l,function(t){_+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=D,t.bottom=D+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:D,right:w+b,bottom:D+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(){var t,e,a,r,h,l=[],c=[],u=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),u.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(u),a=i.max(u),r=i.min(c),e=i.max(c),{x:r>this._chart.width/2?r:e,y:(h+a)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i}) +},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(t._model.startAngle=0===e?Math.PI*-.5:this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){{var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID)}e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&this.labelRotation<=90;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0); +this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t){var e=this.getRightValue(t);null===this.min?this.min=e:ethis.max&&(this.max=e)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;t.textAlign=0===e?"center":e===n?"center":n>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return a(D(t))}function A(t){return s(D(t))}function S(t){return n(D(t))}function P(t){return h(D(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function z(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function F(t){return B(z(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function E(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function N(t){return L(E(t))}function H(t){return T(E(t))}function q(t){return Z[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function J(t){return n(q(t))}function Q(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:D,hwb2hsl:k,hwb2hsv:A,hwb2cmyk:S,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:J,keyword2lab:Q,keyword2xyz:U,xyz2rgb:O,xyz2lab:z,xyz2lch:F,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:E,lch2xyz:N,lch2rgb:H};var Z={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var G in Z)$[JSON.stringify(Z[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function a(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],a=t[1],s=t[2],o=i(t)[0],n=1/255*Math.min(e,Math.min(a,s)),s=1-1/255*Math.max(e,Math.max(a,s));return[o,100*n,100*s]}function o(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function n(t){return Z[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function l(t){var e,i,a,s=h(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function c(t){return L(l(t))}function u(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function d(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return s(u(t))}function f(t){return o(u(t))}function p(t){return n(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function x(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function y(t){return s(v(t))}function w(t){return o(v(t))}function C(t){return n(v(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(D(t))}function k(t){return a(D(t))}function S(t){return o(D(t))}function A(t){return n(D(t))}function P(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return i(P(t))}function M(t){return a(P(t))}function W(t){return s(P(t))}function R(t){return n(P(t))}function V(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function O(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return L(O(t))}function F(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function L(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function B(t){return V(F(t))}function T(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function E(t){return F(T(t))}function N(t){return B(T(t))}function H(t){return U[t]}function q(t){return i(H(t))}function j(t){return a(H(t))}function Y(t){return s(H(t))}function X(t){return o(H(t))}function J(t){return l(H(t))}function Q(t){return h(H(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:u,hsl2hsv:d,hsl2hwb:m,hsl2cmyk:f,hsl2keyword:p,hsv2rgb:v,hsv2hsl:x,hsv2hwb:y,hsv2cmyk:w,hsv2keyword:C,hwb2rgb:D,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:A,cmyk2rgb:P,cmyk2hsl:I,cmyk2hsv:M,cmyk2hwb:W,cmyk2keyword:R,keyword2rgb:H,keyword2hsl:q,keyword2hsv:j,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:J,keyword2xyz:Q,xyz2rgb:V,xyz2lab:O,xyz2lch:z,lab2xyz:F,lab2rgb:B,lab2lch:L,lch2lab:T,lch2xyz:E,lch2rgb:N};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in U)Z[JSON.stringify(U[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),a=function(){return new h};for(var s in i){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),n=o[1],r=o[2];a[n]=a[n]||{},a[n][r]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return d(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function d(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function p(t){return y[t.slice(0,3)]}function v(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:a,getRgb:o,getHsl:n,getHwb:s,getAlpha:r,hexString:h,rgbString:l,rgbaString:c,percentString:u,percentaString:d,hslString:g,hslaString:m,hwbString:f,keyword:p};var y={};for(var w in x)y[x[w]]=w},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From dc58699ee7a741feba0cfce59d3a984f786f2d06 Mon Sep 17 00:00:00 2001 From: Guy Date: Sun, 5 Jul 2015 12:32:03 +0300 Subject: [PATCH 230/424] Hover missing in parameter name In the 1st dataset, the second time "pointBorderWidth" appeared it was under a comment referring to hover so I corrected it to be "pointHoverBorderWidth". Also in the 2nd dataset. Needs to be tested. --- docs/01-Line-Chart.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/01-Line-Chart.md b/docs/01-Line-Chart.md index 840f6cb3473..53c31a3aec5 100644 --- a/docs/01-Line-Chart.md +++ b/docs/01-Line-Chart.md @@ -78,7 +78,7 @@ var data = { pointHoverBorderColor: "rgba(220,220,220,1)", // Number or array - border width of point when hovered - pointBorderWidth: 2, + pointHoverBorderWidth: 2, // The actual data data: [65, 59, 80, 81, 56, 55, 40], @@ -97,7 +97,7 @@ var data = { pointHoverRadius: 5, pointHoverBackgroundColor: "rgba(220,220,220,1)", pointHoverBorderColor: "rgba(220,220,220,1)", - pointBorderWidth: 2, + pointHoverBorderWidth: 2, data: [28, 48, 40, 19, 86, 27, 90] } ] From dfd48debe501172b30d11238d75f117c68d5d5f7 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 5 Jul 2015 14:36:27 -0400 Subject: [PATCH 231/424] Remove log call from polar area draw. --- src/controllers/controller.polarArea.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 4fe948bf843..4de24af6d25 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -155,7 +155,6 @@ var easingDecimal = ease || 1; helpers.each(this.getDataset().metaData, function(arc, index) { arc.transition(easingDecimal).draw(); - console.log(arc); }, this); }, From 0caa2a79aeea89283070ce86bfcf048b2f1076e5 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 5 Jul 2015 14:47:56 -0400 Subject: [PATCH 232/424] Legends for Line, Bar & Radar charts. --- samples/bar.html | 21 +++++++++++++++++++++ samples/line.html | 21 +++++++++++++++++++++ samples/radar.html | 20 ++++++++++++++++++++ src/charts/Chart.Scatter.js | 3 --- src/core/core.controller.js | 2 +- src/core/core.js | 4 +++- 6 files changed, 66 insertions(+), 5 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index 1d085208e4c..eb8796ac5cb 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -16,6 +16,12 @@ +
    +

    Legend

    +
    + +
    +
    diff --git a/samples/line.html b/samples/line.html index edcca91ecfa..28171cdea74 100644 --- a/samples/line.html +++ b/samples/line.html @@ -23,6 +23,12 @@ +
    +

    Legend

    +
    + +
    +
    diff --git a/samples/radar.html b/samples/radar.html index 0605c76e760..b84b8458369 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -16,6 +16,12 @@ + ]
    +

    Legend

    +
    + +
    +
    diff --git a/src/charts/Chart.Scatter.js b/src/charts/Chart.Scatter.js index 3c784ff3212..8863ed5e6dd 100644 --- a/src/charts/Chart.Scatter.js +++ b/src/charts/Chart.Scatter.js @@ -23,9 +23,6 @@ }], }, - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - tooltips: { template: "(<%= value.x %>, <%= value.y %>)", multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", diff --git a/src/core/core.controller.js b/src/core/core.controller.js index c7e29dcd387..bd843631b03 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -338,7 +338,7 @@ }, generateLegend: function generateLegend() { - return template(this.options.legendTemplate, this); + return helpers.template(this.options.legendTemplate, this); }, destroy: function destroy() { diff --git a/src/core/core.js b/src/core/core.js index 85a99167148..42c214e1444 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -83,8 +83,10 @@ defaultColor: 'rgba(0,0,0,0.1)', // Element defaults defined in element extensions - elements: {} + elements: {}, + // Legend template string + legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets.length; i++){%>
    • \"><%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    ", }, }; From 84aba3f6d30134eac4a26f402ee632c388ebb786 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 5 Jul 2015 14:48:04 -0400 Subject: [PATCH 233/424] Polar area legends --- samples/polar-area.html | 22 ++++++++++++++++++++-- src/charts/Chart.PolarArea.js | 5 +++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/samples/polar-area.html b/samples/polar-area.html index a8c74d16b61..e7c992d8ea5 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -8,12 +8,18 @@ -
    - +
    +
    +
    +

    Legend

    +
    + +
    +
    diff --git a/src/charts/Chart.PolarArea.js b/src/charts/Chart.PolarArea.js index e798f74647d..7070a0d8f24 100644 --- a/src/charts/Chart.PolarArea.js +++ b/src/charts/Chart.PolarArea.js @@ -5,7 +5,12 @@ var Chart = root.Chart; var helpers = Chart.helpers; + var defaultConfig = { + legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • \"><%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    ", + }; + Chart.PolarArea = function(context, config) { + config.options = helpers.configMerge(defaultConfig, config.options); config.type = 'polarArea'; return new Chart(context, config); From 925e3051846572d553c3eed89e95a5db8f3c9fae Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 5 Jul 2015 14:56:22 -0400 Subject: [PATCH 234/424] Doughnut legends (only makes sense for first dataset). --- samples/doughnut.html | 24 ++++++++++++++++++++++-- src/charts/Chart.Doughnut.js | 5 +++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/samples/doughnut.html b/samples/doughnut.html index f2c4282f848..ae6bbc9e585 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -26,6 +26,12 @@ +
    +

    Legend

    +
    + +
    +
    diff --git a/src/charts/Chart.Doughnut.js b/src/charts/Chart.Doughnut.js index d01959d448f..ccea714f31d 100644 --- a/src/charts/Chart.Doughnut.js +++ b/src/charts/Chart.Doughnut.js @@ -5,7 +5,12 @@ var Chart = root.Chart; var helpers = Chart.helpers; + var defaultConfig = { + legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • \"><%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    ", + }; + Chart.Doughnut = function(context, config) { + config.options = helpers.configMerge(defaultConfig, config.options); config.type = 'doughnut'; return new Chart(context, config); From f3eb6f4a433b4f34a582842dcf7b42f710861a7d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 5 Jul 2015 14:56:35 -0400 Subject: [PATCH 235/424] Built legend version --- Chart.js | 20 ++++++++++++++------ Chart.min.js | 8 ++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Chart.js b/Chart.js index 69eaf454332..5778de9c169 100644 --- a/Chart.js +++ b/Chart.js @@ -83,8 +83,10 @@ defaultColor: 'rgba(0,0,0,0.1)', // Element defaults defined in element extensions - elements: {} + elements: {}, + // Legend template string + legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets.length; i++){%>
    • \"><%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    ", }, }; @@ -1520,7 +1522,7 @@ }, generateLegend: function generateLegend() { - return template(this.options.legendTemplate, this); + return helpers.template(this.options.legendTemplate, this); }, destroy: function destroy() { @@ -3132,7 +3134,6 @@ var easingDecimal = ease || 1; helpers.each(this.getDataset().metaData, function(arc, index) { arc.transition(easingDecimal).draw(); - console.log(arc); }, this); }, @@ -5228,7 +5229,12 @@ var Chart = root.Chart; var helpers = Chart.helpers; + var defaultConfig = { + legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • \"><%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    ", + }; + Chart.Doughnut = function(context, config) { + config.options = helpers.configMerge(defaultConfig, config.options); config.type = 'doughnut'; return new Chart(context, config); @@ -5258,7 +5264,12 @@ var Chart = root.Chart; var helpers = Chart.helpers; + var defaultConfig = { + legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • \"><%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    ", + }; + Chart.PolarArea = function(context, config) { + config.options = helpers.configMerge(defaultConfig, config.options); config.type = 'polarArea'; return new Chart(context, config); @@ -5306,9 +5317,6 @@ }], }, - //String - A legend template - legendTemplate: "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ", - tooltips: { template: "(<%= value.x %>, <%= value.y %>)", multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)", diff --git a/Chart.min.js b/Chart.min.js index 108a158c5be..ca70195c879 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";{var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):s[a][i]=t.type!==s[a][i].type?e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s[a]=s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?e.configMerge(s[a],t):t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else this._view[a]="number"==typeof i?i*t:i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,D=o,_=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){D+=t.height}),i.each(l,function(t){_+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=D,t.bottom=D+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:D,right:w+b,bottom:D+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(){var t,e,a,r,h,l=[],c=[],u=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),u.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(u),a=i.max(u),r=i.min(c),e=i.max(c),{x:r>this._chart.width/2?r:e,y:(h+a)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i}) -},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(t._model.startAngle=0===e?Math.PI*-.5:this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){{var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID)}e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&this.labelRotation<=90;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0); -this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t){var e=this.getRightValue(t);null===this.min?this.min=e:ethis.max&&(this.max=e)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;t.textAlign=0===e?"center":e===n?"center":n>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendTemplate:'
      <% for (var i = 0; i < data.datasets.length; i++){%>
    • <%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    '}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";{var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):s[a][i]=t.type!==s[a][i].type?e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s[a]=s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?e.configMerge(s[a],t):t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else this._view[a]="number"==typeof i?i*t:i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,D=o,_=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){D+=t.height}),i.each(l,function(t){_+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=D,t.bottom=D+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:D,right:w+b,bottom:D+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(){var t,e,a,r,h,l=[],c=[],u=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),u.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(u),a=i.max(u),r=i.min(c),e=i.max(c),{x:r>this._chart.width/2?r:e,y:(h+a)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id) +},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(t._model.startAngle=0===e?Math.PI*-.5:this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){{var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID)}e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&this.labelRotation<=90;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s +},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t){var e=this.getRightValue(t);null===this.min?this.min=e:ethis.max&&(this.max=e)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;t.textAlign=0===e?"center":e===n?"center":n>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>',tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function a(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],a=t[1],s=t[2],o=i(t)[0],n=1/255*Math.min(e,Math.min(a,s)),s=1-1/255*Math.max(e,Math.max(a,s));return[o,100*n,100*s]}function o(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function n(t){return Z[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function l(t){var e,i,a,s=h(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function c(t){return L(l(t))}function u(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function d(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return s(u(t))}function f(t){return o(u(t))}function p(t){return n(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function x(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function y(t){return s(v(t))}function w(t){return o(v(t))}function C(t){return n(v(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(D(t))}function k(t){return a(D(t))}function S(t){return o(D(t))}function A(t){return n(D(t))}function P(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return i(P(t))}function M(t){return a(P(t))}function W(t){return s(P(t))}function R(t){return n(P(t))}function V(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function O(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return L(O(t))}function F(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function L(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function B(t){return V(F(t))}function T(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function E(t){return F(T(t))}function N(t){return B(T(t))}function H(t){return U[t]}function q(t){return i(H(t))}function j(t){return a(H(t))}function Y(t){return s(H(t))}function X(t){return o(H(t))}function J(t){return l(H(t))}function Q(t){return h(H(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:u,hsl2hsv:d,hsl2hwb:m,hsl2cmyk:f,hsl2keyword:p,hsv2rgb:v,hsv2hsl:x,hsv2hwb:y,hsv2cmyk:w,hsv2keyword:C,hwb2rgb:D,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:A,cmyk2rgb:P,cmyk2hsl:I,cmyk2hsv:M,cmyk2hwb:W,cmyk2keyword:R,keyword2rgb:H,keyword2hsl:q,keyword2hsv:j,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:J,keyword2xyz:Q,xyz2rgb:V,xyz2lab:O,xyz2lch:z,lab2xyz:F,lab2rgb:B,lab2lch:L,lch2lab:T,lch2xyz:E,lch2rgb:N};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in U)Z[JSON.stringify(U[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),a=function(){return new h};for(var s in i){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),n=o[1],r=o[2];a[n]=a[n]||{},a[n][r]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return d(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function d(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function p(t){return y[t.slice(0,3)]}function v(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:a,getRgb:o,getHsl:n,getHwb:s,getAlpha:r,hexString:h,rgbString:l,rgbaString:c,percentString:u,percentaString:d,hslString:g,hslaString:m,hwbString:f,keyword:p};var y={};for(var w in x)y[x[w]]=w},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i = 0; i < data.datasets[0].data.length; i++){%>
  • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
  • <%}%>'};e.Doughnut=function(t,s){return s.options=i.configMerge(a,s.options),s.type="doughnut",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={legendTemplate:'
      <% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    '};e.PolarArea=function(t,s){return s.options=i.configMerge(a,s.options),s.type="polarArea",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Radar=function(t,i){return i.type="radar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function a(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],a=t[1],s=t[2],o=i(t)[0],n=1/255*Math.min(e,Math.min(a,s)),s=1-1/255*Math.max(e,Math.max(a,s));return[o,100*n,100*s]}function o(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function n(t){return Z[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function l(t){var e,i,a,s=h(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function c(t){return L(l(t))}function u(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function d(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return s(u(t))}function f(t){return o(u(t))}function p(t){return n(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function x(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function y(t){return s(v(t))}function w(t){return o(v(t))}function C(t){return n(v(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(D(t))}function k(t){return a(D(t))}function S(t){return o(D(t))}function A(t){return n(D(t))}function P(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return i(P(t))}function M(t){return a(P(t))}function W(t){return s(P(t))}function R(t){return n(P(t))}function V(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function O(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return L(O(t))}function F(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function L(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function B(t){return V(F(t))}function T(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function E(t){return F(T(t))}function N(t){return B(T(t))}function H(t){return U[t]}function q(t){return i(H(t))}function j(t){return a(H(t))}function Y(t){return s(H(t))}function X(t){return o(H(t))}function J(t){return l(H(t))}function Q(t){return h(H(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:u,hsl2hsv:d,hsl2hwb:m,hsl2cmyk:f,hsl2keyword:p,hsv2rgb:v,hsv2hsl:x,hsv2hwb:y,hsv2cmyk:w,hsv2keyword:C,hwb2rgb:D,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:A,cmyk2rgb:P,cmyk2hsl:I,cmyk2hsv:M,cmyk2hwb:W,cmyk2keyword:R,keyword2rgb:H,keyword2hsl:q,keyword2hsv:j,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:J,keyword2xyz:Q,xyz2rgb:V,xyz2lab:O,xyz2lch:z,lab2xyz:F,lab2rgb:B,lab2lch:L,lch2lab:T,lch2xyz:E,lch2rgb:N};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in U)Z[JSON.stringify(U[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),a=function(){return new h};for(var s in i){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),n=o[1],r=o[2];a[n]=a[n]||{},a[n][r]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return d(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function d(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function p(t){return y[t.slice(0,3)]}function v(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:a,getRgb:o,getHsl:n,getHwb:s,getAlpha:r,hexString:h,rgbString:l,rgbaString:c,percentString:u,percentaString:d,hslString:g,hslaString:m,hwbString:f,keyword:p};var y={};for(var w in x)y[x[w]]=w},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From d3ffc7aec13b1f7002ddf49eaacb856186bf0bbf Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 6 Jul 2015 22:28:05 -0400 Subject: [PATCH 236/424] Auto Skip Labels Attempt 1 --- src/scales/scale.category.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 2b233048f85..b375c25ddec 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -121,10 +121,11 @@ //Allow 3 pixels x2 padding either side for label readability // only the index matters for a dataset scale, but we want a consistent interface between scales - var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + + var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; //Max label rotate should be 90 - also act as a loop counter - while (this.labelWidth > gridWidth && this.labelRotation <= 90) { + while (this.labelWidth > datasetWidth && this.labelRotation <= 40) { cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); @@ -220,8 +221,16 @@ var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; var isRotated = this.labelRotation !== 0; + var skipRatio = false; + + if ((this.options.labels.fontSize + 4) * this.labels.length > (this.width - (this.paddingLeft + this.paddingRight))) { + skipRatio = 1 + Math.floor(((this.options.labels.fontSize + 4) * this.labels.length) / (this.width - (this.paddingLeft + this.paddingRight))); + } helpers.each(this.labels, function(label, index) { + if (skipRatio > 1 && index % skipRatio > 0) { + return; + } var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) From 68b22562d9b34d08974844933a0c324fd34dc8bb Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 3 Aug 2015 13:06:40 -0600 Subject: [PATCH 237/424] DatasetWidth now incorporates chartPaddingLeft --- src/scales/scale.category.js | 583 ++++++++++++++++++----------------- 1 file changed, 293 insertions(+), 290 deletions(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index b375c25ddec..13b414ee7bb 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -1,292 +1,295 @@ (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - // Default config for a category scale - var defaultConfig = { - display: true, - position: "bottom", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.1)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: false, - }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }; - - var DatasetScale = Chart.Element.extend({ - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - buildLabels: function(index) { - this.labels = []; - - if (this.options.labels.userCallback) { - this.data.labels.forEach(function(labelString, index) { - this.labels.push(this.options.labels.userCallback(labelString, index)); - }, this); - } else { - this.labels = this.data.labels; - } - }, - getPixelForValue: function(value, index, datasetIndex, includeOffset) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - if (this.isHorizontal()) { - var isRotated = (this.labelRotation > 0); - var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; - - if (this.options.gridLines.offsetGridLines && includeOffset) { - valueOffset += (valueWidth / 2); - } - - return this.left + Math.round(valueOffset); - } else { - return this.top + (index * (this.height / this.labels.length)); - } - }, - getPointPixelForValue: function(value, index, datasetIndex) { - return this.getPixelForValue(value, index, datasetIndex, true); - }, - - // Functions needed for bar charts - calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); - }, - calculateBarWidth: function(datasetCount) { - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); - - if (this.options.stacked) { - return baseWidth; - } - return (baseWidth / datasetCount); - }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); - - if (this.options.stacked) { - return xAbsolute + barWidth / 2; - } - - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; - }, - - calculateLabelRotation: function(maxHeight, margins) { - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - this.ctx.font = labelFont; - - var firstWidth = this.ctx.measureText(this.labels[0]).width; - var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; - var firstRotated; - var lastRotated; - - this.paddingRight = lastWidth / 2 + 3; - this.paddingLeft = firstWidth / 2 + 3; - - this.labelRotation = 0; - - if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - var cosRotation; - var sinRotation; - var firstRotatedWidth; - - this.labelWidth = originalLabelWidth; - - //Allow 3 pixels x2 padding either side for label readability - // only the index matters for a dataset scale, but we want a consistent interface between scales - - var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; - - //Max label rotate should be 90 - also act as a loop counter - while (this.labelWidth > datasetWidth && this.labelRotation <= 40) { - cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); - sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); - - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; - - // We're right aligning the text now. - if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { - this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; - } - - this.paddingRight = this.options.labels.fontSize / 2; - - if (sinRotation * originalLabelWidth > maxHeight) { - // go back one step - this.labelRotation--; - break; - } - - this.labelRotation++; - this.labelWidth = cosRotation * originalLabelWidth; - - } - } else { - this.labelWidth = 0; - this.paddingRight = 0; - this.paddingLeft = 0; - } - - if (margins) { - this.paddingLeft -= margins.left; - this.paddingRight -= margins.right; - - this.paddingLeft = Math.max(this.paddingLeft, 0); - this.paddingRight = Math.max(this.paddingRight, 0); - } - - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight, margins) { - // Set the unconstrained dimension before label rotation - if (this.isHorizontal()) { - this.width = maxWidth; - } else { - this.height = maxHeight; - } - - this.buildLabels(); - this.calculateLabelRotation(maxHeight, margins); - - var minSize = { - width: 0, - height: 0, - }; - - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - // Width - if (this.isHorizontal()) { - minSize.width = maxWidth; - } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } - - // Height - if (this.isHorizontal() && this.options.display) { - var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); - } else if (this.options.display) { - minSize.height = maxHeight; - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - setContextLineSettings = true; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; - var isRotated = this.labelRotation !== 0; - var skipRatio = false; - - if ((this.options.labels.fontSize + 4) * this.labels.length > (this.width - (this.paddingLeft + this.paddingRight))) { - skipRatio = 1 + Math.floor(((this.options.labels.fontSize + 4) * this.labels.length) / (this.width - (this.paddingLeft + this.paddingRight))); - } - - helpers.each(this.labels, function(label, index) { - if (skipRatio > 1 && index % skipRatio > 0) { - return; - } - var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines - var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) - - if (this.options.gridLines.show) { - if (index === 0) { - // Draw the first index specially - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xLineValue, yTickStart); - this.ctx.lineTo(xLineValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xLineValue, chartArea.top); - this.ctx.lineTo(xLineValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - } - - if (this.options.labels.show) { - this.ctx.save(); - this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); - this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); - this.ctx.font = this.font; - this.ctx.textAlign = (isRotated) ? "right" : "center"; - this.ctx.textBaseline = (isRotated) ? "middle" : "top"; - this.ctx.fillText(label, 0, 0); - this.ctx.restore(); - } - }, this); - } else { - // Vertical - if (this.options.gridLines.show) {} - - if (this.options.labels.show) { - // Draw the labels - } - } - } - } - }); - Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + // Default config for a category scale + var defaultConfig = { + display: true, + position: "bottom", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, + + // label settings + labels: { + show: true, + maxRotation: 90, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }; + + var DatasetScale = Chart.Element.extend({ + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + buildLabels: function(index) { + this.labels = []; + + if (this.options.labels.userCallback) { + this.data.labels.forEach(function(labelString, index) { + this.labels.push(this.options.labels.userCallback(labelString, index)); + }, this); + } else { + this.labels = this.data.labels; + } + }, + getPixelForValue: function(value, index, datasetIndex, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.labels.length)); + } + }, + getPointPixelForValue: function(value, index, datasetIndex) { + return this.getPixelForValue(value, index, datasetIndex, true); + }, + + // Functions needed for bar charts + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); + + if (this.options.stacked) { + return baseWidth; + } + return (baseWidth / datasetCount); + }, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); + + if (this.options.stacked) { + return xAbsolute + barWidth / 2; + } + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; + }, + + calculateLabelRotation: function(maxHeight, margins) { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + var firstRotated; + var lastRotated; + + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; + + this.labelRotation = 0; + + if (this.options.display) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; + + this.labelWidth = originalLabelWidth; + + //Allow 3 pixels x2 padding either side for label readability + // only the index matters for a dataset scale, but we want a consistent interface between scales + + var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + + //Max label rotation can be set or default to 90 - also act as a loop counter + while (this.labelWidth > (datasetWidth + this.paddingLeft) && this.labelRotation <= this.options.labels.maxRotation) { + console.log(this.labelWidth, datasetWidth, this.labelRotation, this.options.labels.maxRotation) + console.log(this.paddingLeft); + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; + } + + this.paddingRight = this.options.labels.fontSize / 2; + + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } + + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; + + } + } else { + this.labelWidth = 0; + this.paddingRight = 0; + this.paddingLeft = 0; + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + } + + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight, margins) { + // Set the unconstrained dimension before label rotation + if (this.isHorizontal()) { + this.width = maxWidth; + } else { + this.height = maxHeight; + } + + this.buildLabels(); + this.calculateLabelRotation(maxHeight, margins); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; + } else if (this.options.display) { + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + // Height + if (this.isHorizontal() && this.options.display) { + var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else if (this.options.display) { + minSize.height = maxHeight; + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + var skipRatio = false; + + if ((this.options.labels.fontSize + 4) * this.labels.length > (this.width - (this.paddingLeft + this.paddingRight))) { + skipRatio = 1 + Math.floor(((this.options.labels.fontSize + 4) * this.labels.length) / (this.width - (this.paddingLeft + this.paddingRight))); + } + + helpers.each(this.labels, function(label, index) { + if (skipRatio > 1 && index % skipRatio > 0) { + return; + } + var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } + + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) {} + + if (this.options.labels.show) { + // Draw the labels + } + } + } + } + }); + Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig); }).call(this); From 452ef8b6e7c9c3913d148d59a7eacd19e0844c12 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 3 Aug 2015 13:06:53 -0600 Subject: [PATCH 238/424] No Logs --- src/scales/scale.category.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 13b414ee7bb..98b28d072fa 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -127,8 +127,6 @@ //Max label rotation can be set or default to 90 - also act as a loop counter while (this.labelWidth > (datasetWidth + this.paddingLeft) && this.labelRotation <= this.options.labels.maxRotation) { - console.log(this.labelWidth, datasetWidth, this.labelRotation, this.options.labels.maxRotation) - console.log(this.paddingLeft); cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); From 26c210db33ccce675c428f5f67f296de3b4c8a97 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 3 Aug 2015 17:17:49 -0600 Subject: [PATCH 239/424] More Accurate animation frame dropper --- src/core/core.animation.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core/core.animation.js b/src/core/core.animation.js index a61f5e0a14a..cb6c6fc0ad1 100644 --- a/src/core/core.animation.js +++ b/src/core/core.animation.js @@ -73,7 +73,7 @@ if (this.dropFrames > 1) { framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; + this.dropFrames = this.dropFrames % 1; } for (var i = 0; i < this.animations.length; i++) { @@ -81,7 +81,6 @@ if (this.animations[i].animationObject.currentStep === null) { this.animations[i].animationObject.currentStep = 0; } - this.animations[i].animationObject.currentStep += 1 + framesToDrop; if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; @@ -99,12 +98,9 @@ } var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; + var dropFrames = (endTime - startTime) / this.frameDuration; - if (frameDelay > 1) { - this.dropFrames += frameDelay; - } + this.dropFrames += dropFrames; // Do we have more stuff to animate? if (this.animations.length > 0) { From f3706b0755c74b7a713c93b68dd0bf302ee1909e Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 4 Aug 2015 11:24:27 -0600 Subject: [PATCH 240/424] chart.update(0) now draws instantly instead of not at all --- src/core/core.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index bd843631b03..a255167bf02 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -237,7 +237,7 @@ render: function render(duration, lazy) { - if (this.options.animation.duration !== 0 || duration) { + if ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration == 'undefined' && this.options.animation.duration !== 0)) { var animation = new Chart.Animation(); animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps animation.easing = this.options.animation.easing; From 31c5e45bd465e620eb4658c3e7f30eea76842a71 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 4 Aug 2015 11:25:04 -0600 Subject: [PATCH 241/424] Build --- Chart.js | 584 ++++++++++++++++++++++++++------------------------- Chart.min.js | 8 +- 2 files changed, 299 insertions(+), 293 deletions(-) diff --git a/Chart.js b/Chart.js index 5778de9c169..79f88897ad2 100644 --- a/Chart.js +++ b/Chart.js @@ -1140,7 +1140,7 @@ if (this.dropFrames > 1) { framesToDrop = Math.floor(this.dropFrames); - this.dropFrames -= framesToDrop; + this.dropFrames = this.dropFrames % 1; } for (var i = 0; i < this.animations.length; i++) { @@ -1148,7 +1148,6 @@ if (this.animations[i].animationObject.currentStep === null) { this.animations[i].animationObject.currentStep = 0; } - this.animations[i].animationObject.currentStep += 1 + framesToDrop; if (this.animations[i].animationObject.currentStep > this.animations[i].animationObject.numSteps) { this.animations[i].animationObject.currentStep = this.animations[i].animationObject.numSteps; @@ -1166,12 +1165,9 @@ } var endTime = Date.now(); - var delay = endTime - startTime - this.frameDuration; - var frameDelay = delay / this.frameDuration; + var dropFrames = (endTime - startTime) / this.frameDuration; - if (frameDelay > 1) { - this.dropFrames += frameDelay; - } + this.dropFrames += dropFrames; // Do we have more stuff to animate? if (this.animations.length > 0) { @@ -1421,7 +1417,7 @@ render: function render(duration, lazy) { - if (this.options.animation.duration !== 0 || duration) { + if ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration == 'undefined' && this.options.animation.duration !== 0)) { var animation = new Chart.Animation(); animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps animation.easing = this.options.animation.easing; @@ -3441,287 +3437,297 @@ }).call(this); (function() { - "use strict"; - - var root = this, - Chart = root.Chart, - helpers = Chart.helpers; - - // Default config for a category scale - var defaultConfig = { - display: true, - position: "bottom", - - // grid line settings - gridLines: { - show: true, - color: "rgba(0, 0, 0, 0.1)", - lineWidth: 1, - drawOnChartArea: true, - drawTicks: true, - zeroLineWidth: 1, - zeroLineColor: "rgba(0,0,0,0.25)", - offsetGridLines: false, - }, - - // label settings - labels: { - show: true, - template: "<%=value%>", - fontSize: 12, - fontStyle: "normal", - fontColor: "#666", - fontFamily: "Helvetica Neue", - }, - }; - - var DatasetScale = Chart.Element.extend({ - isHorizontal: function() { - return this.options.position == "top" || this.options.position == "bottom"; - }, - buildLabels: function(index) { - this.labels = []; - - if (this.options.labels.userCallback) { - this.data.labels.forEach(function(labelString, index) { - this.labels.push(this.options.labels.userCallback(labelString, index)); - }, this); - } else { - this.labels = this.data.labels; - } - }, - getPixelForValue: function(value, index, datasetIndex, includeOffset) { - // This must be called after fit has been run so that - // this.left, this.top, this.right, and this.bottom have been defined - if (this.isHorizontal()) { - var isRotated = (this.labelRotation > 0); - var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; - - if (this.options.gridLines.offsetGridLines && includeOffset) { - valueOffset += (valueWidth / 2); - } - - return this.left + Math.round(valueOffset); - } else { - return this.top + (index * (this.height / this.labels.length)); - } - }, - getPointPixelForValue: function(value, index, datasetIndex) { - return this.getPixelForValue(value, index, datasetIndex, true); - }, - - // Functions needed for bar charts - calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); - }, - calculateBarWidth: function(datasetCount) { - //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); - - if (this.options.stacked) { - return baseWidth; - } - return (baseWidth / datasetCount); - }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { - var xWidth = this.calculateBaseWidth(), - xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); - - if (this.options.stacked) { - return xAbsolute + barWidth / 2; - } - - return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; - }, - - calculateLabelRotation: function(maxHeight, margins) { - //Get the width of each grid by calculating the difference - //between x offsets between 0 and 1. - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - this.ctx.font = labelFont; - - var firstWidth = this.ctx.measureText(this.labels[0]).width; - var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; - var firstRotated; - var lastRotated; - - this.paddingRight = lastWidth / 2 + 3; - this.paddingLeft = firstWidth / 2 + 3; - - this.labelRotation = 0; - - if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - var cosRotation; - var sinRotation; - var firstRotatedWidth; - - this.labelWidth = originalLabelWidth; - - //Allow 3 pixels x2 padding either side for label readability - // only the index matters for a dataset scale, but we want a consistent interface between scales - var gridWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; - - //Max label rotate should be 90 - also act as a loop counter - while (this.labelWidth > gridWidth && this.labelRotation <= 90) { - cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); - sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); - - firstRotated = cosRotation * firstWidth; - lastRotated = cosRotation * lastWidth; - - // We're right aligning the text now. - if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { - this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; - } - - this.paddingRight = this.options.labels.fontSize / 2; - - if (sinRotation * originalLabelWidth > maxHeight) { - // go back one step - this.labelRotation--; - break; - } - - this.labelRotation++; - this.labelWidth = cosRotation * originalLabelWidth; - - } - } else { - this.labelWidth = 0; - this.paddingRight = 0; - this.paddingLeft = 0; - } - - if (margins) { - this.paddingLeft -= margins.left; - this.paddingRight -= margins.right; - - this.paddingLeft = Math.max(this.paddingLeft, 0); - this.paddingRight = Math.max(this.paddingRight, 0); - } - - }, - // Fit this axis to the given size - // @param {number} maxWidth : the max width the axis can be - // @param {number} maxHeight: the max height the axis can be - // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight, margins) { - // Set the unconstrained dimension before label rotation - if (this.isHorizontal()) { - this.width = maxWidth; - } else { - this.height = maxHeight; - } - - this.buildLabels(); - this.calculateLabelRotation(maxHeight, margins); - - var minSize = { - width: 0, - height: 0, - }; - - var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); - - // Width - if (this.isHorizontal()) { - minSize.width = maxWidth; - } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); - } - - // Height - if (this.isHorizontal() && this.options.display) { - var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); - } else if (this.options.display) { - minSize.height = maxHeight; - } - - this.width = minSize.width; - this.height = minSize.height; - return minSize; - }, - // Actualy draw the scale on the canvas - // @param {rectangle} chartArea : the area of the chart to draw full grid lines on - draw: function(chartArea) { - if (this.options.display) { - - var setContextLineSettings; - - // Make sure we draw text in the correct color - this.ctx.fillStyle = this.options.labels.fontColor; - - if (this.isHorizontal()) { - setContextLineSettings = true; - var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; - var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; - var isRotated = this.labelRotation !== 0; - - helpers.each(this.labels, function(label, index) { - var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines - var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) - - if (this.options.gridLines.show) { - if (index === 0) { - // Draw the first index specially - this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; - this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; - setContextLineSettings = true; // reset next time - } else if (setContextLineSettings) { - this.ctx.lineWidth = this.options.gridLines.lineWidth; - this.ctx.strokeStyle = this.options.gridLines.color; - setContextLineSettings = false; - } - - xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - - // Draw the label area - this.ctx.beginPath(); - - if (this.options.gridLines.drawTicks) { - this.ctx.moveTo(xLineValue, yTickStart); - this.ctx.lineTo(xLineValue, yTickEnd); - } - - // Draw the chart area - if (this.options.gridLines.drawOnChartArea) { - this.ctx.moveTo(xLineValue, chartArea.top); - this.ctx.lineTo(xLineValue, chartArea.bottom); - } - - // Need to stroke in the loop because we are potentially changing line widths & colours - this.ctx.stroke(); - } - - if (this.options.labels.show) { - this.ctx.save(); - this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); - this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); - this.ctx.font = this.font; - this.ctx.textAlign = (isRotated) ? "right" : "center"; - this.ctx.textBaseline = (isRotated) ? "middle" : "top"; - this.ctx.fillText(label, 0, 0); - this.ctx.restore(); - } - }, this); - } else { - // Vertical - if (this.options.gridLines.show) {} - - if (this.options.labels.show) { - // Draw the labels - } - } - } - } - }); - Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig); + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + // Default config for a category scale + var defaultConfig = { + display: true, + position: "bottom", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + offsetGridLines: false, + }, + + // label settings + labels: { + show: true, + maxRotation: 90, + template: "<%=value%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue", + }, + }; + + var DatasetScale = Chart.Element.extend({ + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + buildLabels: function(index) { + this.labels = []; + + if (this.options.labels.userCallback) { + this.data.labels.forEach(function(labelString, index) { + this.labels.push(this.options.labels.userCallback(labelString, index)); + }, this); + } else { + this.labels = this.data.labels; + } + }, + getPixelForValue: function(value, index, datasetIndex, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var isRotated = (this.labelRotation > 0); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.labels.length)); + } + }, + getPointPixelForValue: function(value, index, datasetIndex) { + return this.getPixelForValue(value, index, datasetIndex, true); + }, + + // Functions needed for bar charts + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); + }, + calculateBarWidth: function(datasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); + + if (this.options.stacked) { + return baseWidth; + } + return (baseWidth / datasetCount); + }, + calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(datasetCount); + + if (this.options.stacked) { + return xAbsolute + barWidth / 2; + } + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; + }, + + calculateLabelRotation: function(maxHeight, margins) { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + var firstRotated; + var lastRotated; + + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; + + this.labelRotation = 0; + + if (this.options.display) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; + + this.labelWidth = originalLabelWidth; + + //Allow 3 pixels x2 padding either side for label readability + // only the index matters for a dataset scale, but we want a consistent interface between scales + + var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + + //Max label rotation can be set or default to 90 - also act as a loop counter + while (this.labelWidth > (datasetWidth + this.paddingLeft) && this.labelRotation <= this.options.labels.maxRotation) { + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; + } + + this.paddingRight = this.options.labels.fontSize / 2; + + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } + + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; + + } + } else { + this.labelWidth = 0; + this.paddingRight = 0; + this.paddingLeft = 0; + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + } + + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight, margins) { + // Set the unconstrained dimension before label rotation + if (this.isHorizontal()) { + this.width = maxWidth; + } else { + this.height = maxHeight; + } + + this.buildLabels(); + this.calculateLabelRotation(maxHeight, margins); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; + } else if (this.options.display) { + minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + } + + // Height + if (this.isHorizontal() && this.options.display) { + var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(labelHeight, maxHeight); + } else if (this.options.display) { + minSize.height = maxHeight; + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + var skipRatio = false; + + if ((this.options.labels.fontSize + 4) * this.labels.length > (this.width - (this.paddingLeft + this.paddingRight))) { + skipRatio = 1 + Math.floor(((this.options.labels.fontSize + 4) * this.labels.length) / (this.width - (this.paddingLeft + this.paddingRight))); + } + + helpers.each(this.labels, function(label, index) { + if (skipRatio > 1 && index % skipRatio > 0) { + return; + } + var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } + + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) {} + + if (this.options.labels.show) { + // Draw the labels + } + } + } + } + }); + Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig); }).call(this); (function() { diff --git a/Chart.min.js b/Chart.min.js index ca70195c879..4fe68fcdac5 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendTemplate:'
      <% for (var i = 0; i < data.datasets.length; i++){%>
    • <%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    '}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";{var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):s[a][i]=t.type!==s[a][i].type?e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s[a]=s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?e.configMerge(s[a],t):t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else this._view[a]="number"==typeof i?i*t:i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames-=e);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=s-t-this.frameDuration,n=o/this.frameDuration;n>1&&(this.dropFrames+=n),this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,D=o,_=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){D+=t.height}),i.each(l,function(t){_+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=D,t.bottom=D+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:D,right:w+b,bottom:D+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(){var t,e,a,r,h,l=[],c=[],u=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),u.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(u),a=i.max(u),r=i.min(c),e=i.max(c),{x:r>this._chart.width/2?r:e,y:(h+a)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id) -},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(t._model.startAngle=0===e?Math.PI*-.5:this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){{var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID)}e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&this.labelRotation<=90;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s -},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation;i.each(this.labels,function(n,r){var h=this.getPixelForValue(n,r,null,!1),l=this.getPixelForValue(n,r,null,!0);this.options.gridLines.show&&(0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,a),this.ctx.lineTo(h,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(l,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(n,0,0),this.ctx.restore())},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t){var e=this.getRightValue(t);null===this.min?this.min=e:ethis.max&&(this.max=e)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;t.textAlign=0===e?"center":e===n?"center":n>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendTemplate:'
      <% for (var i = 0; i < data.datasets.length; i++){%>
    • <%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    '}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames=this.dropFrames%1);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=(s-t)/this.frameDuration;this.dropFrames+=o,this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,D=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){D+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=_,t.bottom=_+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id), +this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(0===e?t._model.startAngle=Math.PI*-.5:t._model.startAngle=this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(t){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u+this.paddingLeft&&this.labelRotation<=this.options.labels.maxRotation;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels); +if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation,n=!1;(this.options.labels.fontSize+4)*this.labels.length>this.width-(this.paddingLeft+this.paddingRight)&&(n=1+Math.floor((this.options.labels.fontSize+4)*this.labels.length/(this.width-(this.paddingLeft+this.paddingRight)))),i.each(this.labels,function(r,h){if(!(n>1&&h%n>0)){var l=this.getPixelForValue(r,h,null,!1),c=this.getPixelForValue(r,h,null,!0);this.options.gridLines.show&&(0===h?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,a),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(c,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())}},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i = 0; i < data.datasets[0].data.length; i++){%>
  • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
  • <%}%>'};e.Doughnut=function(t,s){return s.options=i.configMerge(a,s.options),s.type="doughnut",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={legendTemplate:'
      <% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    '};e.PolarArea=function(t,s){return s.options=i.configMerge(a,s.options),s.type="polarArea",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Radar=function(t,i){return i.type="radar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function a(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],a=t[1],s=t[2],o=i(t)[0],n=1/255*Math.min(e,Math.min(a,s)),s=1-1/255*Math.max(e,Math.max(a,s));return[o,100*n,100*s]}function o(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function n(t){return Z[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function l(t){var e,i,a,s=h(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function c(t){return L(l(t))}function u(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function d(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return s(u(t))}function f(t){return o(u(t))}function p(t){return n(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function x(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function y(t){return s(v(t))}function w(t){return o(v(t))}function C(t){return n(v(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(D(t))}function k(t){return a(D(t))}function S(t){return o(D(t))}function A(t){return n(D(t))}function P(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return i(P(t))}function M(t){return a(P(t))}function W(t){return s(P(t))}function R(t){return n(P(t))}function V(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function O(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return L(O(t))}function F(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function L(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function B(t){return V(F(t))}function T(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function E(t){return F(T(t))}function N(t){return B(T(t))}function H(t){return U[t]}function q(t){return i(H(t))}function j(t){return a(H(t))}function Y(t){return s(H(t))}function X(t){return o(H(t))}function J(t){return l(H(t))}function Q(t){return h(H(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:u,hsl2hsv:d,hsl2hwb:m,hsl2cmyk:f,hsl2keyword:p,hsv2rgb:v,hsv2hsl:x,hsv2hwb:y,hsv2cmyk:w,hsv2keyword:C,hwb2rgb:D,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:A,cmyk2rgb:P,cmyk2hsl:I,cmyk2hsv:M,cmyk2hwb:W,cmyk2keyword:R,keyword2rgb:H,keyword2hsl:q,keyword2hsv:j,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:J,keyword2xyz:Q,xyz2rgb:V,xyz2lab:O,xyz2lch:z,lab2xyz:F,lab2rgb:B,lab2lch:L,lch2lab:T,lch2xyz:E,lch2rgb:N};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in U)Z[JSON.stringify(U[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),a=function(){return new h};for(var s in i){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),n=o[1],r=o[2];a[n]=a[n]||{},a[n][r]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return d(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function d(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function p(t){return y[t.slice(0,3)]}function v(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:a,getRgb:o,getHsl:n,getHwb:s,getAlpha:r,hexString:h,rgbString:l,rgbaString:c,percentString:u,percentaString:d,hslString:g,hslaString:m,hwbString:f,keyword:p};var y={};for(var w in x)y[x[w]]=w},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i = 0; i < data.datasets[0].data.length; i++){%>
  • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
  • <%}%>'};e.Doughnut=function(t,s){return s.options=i.configMerge(a,s.options),s.type="doughnut",new e(t,s)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={legendTemplate:'
      <% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    '};e.PolarArea=function(t,s){return s.options=i.configMerge(a,s.options),s.type="polarArea",new e(t,s)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Radar=function(t,i){return i.type="radar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return a(D(t))}function S(t){return s(D(t))}function A(t){return n(D(t))}function P(t){return h(D(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function z(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function F(t){return B(z(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function E(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function N(t){return L(E(t))}function H(t){return T(E(t))}function q(t){return Z[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function J(t){return n(q(t))}function Q(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:D,hwb2hsl:k,hwb2hsv:S,hwb2cmyk:A,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:J,keyword2lab:Q,keyword2xyz:U,xyz2rgb:O,xyz2lab:z,xyz2lch:F,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:E,lch2xyz:N,lch2rgb:H};var Z={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var G in Z)$[JSON.stringify(Z[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From 0c6f37fff744e8f00c57c51407136cc39d506409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Gallego?= Date: Wed, 5 Aug 2015 17:40:44 +0200 Subject: [PATCH 242/424] Add support for mirror option --- docs/00-Getting-Started.md | 6 ++++++ src/scales/scale.linear.js | 22 +++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index 49b39a7ccb7..a678a46d660 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -364,6 +364,12 @@ the following options. labels: { // Boolean - if true show labels show: true, + + // Boolean - if true the chart will mirror the axis labels. If the labels are on the left, mirroring the axis will render them to the right + mirror: false, + + // Number - controls the padding between the label and the axis + padding: 10, // String - template string for labels template: "<%=value%>", diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index ceeae97c148..8ab840eb99c 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -28,11 +28,13 @@ // label settings labels: { show: true, + mirror: false, + padding: 10, template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", - fontFamily: "Helvetica Neue", + fontFamily: "Helvetica Neue" } }; @@ -548,12 +550,22 @@ var labelStartX; if (this.options.position == "left") { - labelStartX = this.right - 10; - this.ctx.textAlign = "right"; + if (this.options.labels.mirror) { + labelStartX = this.right + this.options.labels.padding; + this.ctx.textAlign = "left"; + } else { + labelStartX = this.right - this.options.labels.padding; + this.ctx.textAlign = "right"; + } } else { // right side - labelStartX = this.left + 5; - this.ctx.textAlign = "left"; + if (this.options.labels.mirror) { + labelStartX = this.left - this.options.labels.padding; + this.ctx.textAlign = "right"; + } else { + labelStartX = this.left + this.options.labels.padding; + this.ctx.textAlign = "left"; + } } this.ctx.textBaseline = "middle"; From f5b44acc38908d5245f668d51a8653664d72ff21 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 7 Aug 2015 13:39:09 -0600 Subject: [PATCH 243/424] onAnimationComplete for zero-frame transitions --- src/core/core.controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index a255167bf02..1b4cbe3953c 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -258,7 +258,9 @@ Chart.animationService.addAnimation(this, animation, duration, lazy); } else { this.draw(); - this.options.onAnimationComplete.call(this); + if (this.options.onAnimationComplete && this.options.onAnimationComplete.call) { + this.options.onAnimationComplete.call(this); + } } return this; }, From ca0ece37e6a7f706ff918a12fc5849c9cf6cb980 Mon Sep 17 00:00:00 2001 From: Pratyush Mittal Date: Sat, 8 Aug 2015 14:07:24 +0530 Subject: [PATCH 244/424] Added documentation for maxRotation of labels --- docs/00-Getting-Started.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index a678a46d660..9b372c825ad 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -371,6 +371,9 @@ the following options. // Number - controls the padding between the label and the axis padding: 10, + // Number: maximum auto-rotation allowed for labels. + maxRotation: 90, + // String - template string for labels template: "<%=value%>", @@ -393,14 +396,15 @@ the following options. ``` -The `userCallback` method may be useful when there are a lot of labels. The following callback would filter out every second label on a category scale +The `userCallback` method may be useful when there are a lot of labels. The following callback would show every fifth label on a category scale ```javascript { scales: { xAxes: [{ labels: { + maxRotation: 0, // set maxRotation to 0 to turn off auto-rotation userCallback: function(labelString, index) { - return (index % 2 === 0) ? labelString : ''; + return (index % 5 === 0) ? labelString : ''; } } }] @@ -490,4 +494,4 @@ The `userCallback` function allows the user fine grained control over how labels } } } -``` \ No newline at end of file +``` From 1cdc046566e616155f6edcb268c933c532c2d341 Mon Sep 17 00:00:00 2001 From: achichenin Date: Sat, 8 Aug 2015 15:15:57 +0300 Subject: [PATCH 245/424] Update 00-Getting-Started.md tiny typo fix --- docs/00-Getting-Started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index a678a46d660..0ff54a53848 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -46,7 +46,7 @@ To create a chart, we need to instantiate the `Chart` class. To do this, we need ```javascript // Get the context of the canvas element we want to select var ctx = document.getElementById("myChart").getContext("2d"); -var myNewChart = Chart.PolarArea(chart, { +var myNewChart = Chart.PolarArea(ctx, { data: data, options: config }); @@ -490,4 +490,4 @@ The `userCallback` function allows the user fine grained control over how labels } } } -``` \ No newline at end of file +``` From 9dfa9e8e663157bab6af317961eda98e84e2c391 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 8 Aug 2015 10:14:37 -0400 Subject: [PATCH 246/424] Fix the outerRadius calculation with respect to the border width. Previously the border width was divided by 2 twice rather than once. --- src/controllers/controller.doughnut.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 454ec549899..8b161c29a35 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -88,7 +88,7 @@ update: function(reset) { - this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; + this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) / 2) - this.chart.options.elements.arc.borderWidth / 2; this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; From 87ac933c106450b77dd00b8d08e083baef41b88e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 8 Aug 2015 11:52:20 -0400 Subject: [PATCH 247/424] Linear scale has proper padding in both vertical and horizontal orientations. Should prevent labels from getting cut off even when axes are not displayed. --- src/scales/scale.linear.js | 40 +++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 8ab840eb99c..c9827e02ef0 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -166,10 +166,14 @@ var range = this.end - this.start; if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.start)); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + pixel = this.left + (innerWidth / range * (value - this.start)); + pixel += this.paddingLeft; } else { // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.start)); + var innerHeight = this.height - (this.paddingTop + this.paddingBottom); + pixel = this.bottom - (innerHeight / range * (value - this.start)); + pixel += this.paddingTop; } return pixel; @@ -343,7 +347,7 @@ // @param {number} maxWidth : the max width the axis can be // @param {number} maxHeight: the max height the axis can be // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { + fit: function(maxWidth, maxHeight, margins) { this.calculateRange(); this.generateTicks(maxWidth, maxHeight); this.buildLabels(); @@ -386,6 +390,10 @@ minSize.height = maxHeight; // fill all the height } + this.paddingLeft = 0; + this.paddingRight = 0; + this.paddingTop = 0; + this.paddingBottom = 0; if (this.options.labels.show && this.options.display) { @@ -398,6 +406,16 @@ var maxLabelHeight = maxHeight - minSize.height; var labelHeight = 1.5 * this.options.labels.fontSize; minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstLabelWidth = this.ctx.measureText(this.labels[0]).width; + var lastLabelWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + + // Ensure that our labels are always inside the canvas + this.paddingLeft = firstLabelWidth / 2; + this.paddingRight = lastLabelWidth / 2; } else { // A vertical axis is more constrained by the width. Labels are the dominant factor // here, so get that length first @@ -407,13 +425,29 @@ if (largestTextWidth < maxLabelWidth) { // We don't need all the room minSize.width += largestTextWidth; + minSize.width += 3; // extra padding } else { // Expand to max size minSize.width = maxWidth; } + + this.paddingTop = this.options.labels.fontSize / 2; + this.paddingBottom = this.options.labels.fontSize / 2; } } + if (margins) { + this.paddingLeft -= margins.left; + this.paddingTop -= margins.top; + this.paddingRight -= margins.right; + this.paddingBottom -= margins.bottom; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingTop = Math.max(this.paddingTop, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + this.paddingBottom = Math.max(this.paddingBottom, 0); + } + this.width = minSize.width; this.height = minSize.height; return minSize; From 88896abe48f70bceea309ac5bb74d3900711bbea Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 8 Aug 2015 18:12:01 -0400 Subject: [PATCH 248/424] During a mousemove event only re-render the chart instead of updating it. Updating uses more memory & causes flicker in the axes. --- Chart.js | 73 +++++++++++++++++++++++++++++++------ Chart.min.js | 8 ++-- src/core/core.controller.js | 5 ++- 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/Chart.js b/Chart.js index 79f88897ad2..2a33c6d1d78 100644 --- a/Chart.js +++ b/Chart.js @@ -1438,7 +1438,9 @@ Chart.animationService.addAnimation(this, animation, duration, lazy); } else { this.draw(); - this.options.onAnimationComplete.call(this); + if (this.options.onAnimationComplete && this.options.onAnimationComplete.call) { + this.options.onAnimationComplete.call(this); + } } return this; }, @@ -1669,7 +1671,10 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.update(this.options.hover.animationDuration, true); + + // We only need to render at this point. Updating will cause scales to be recomputed generating flicker & using more + // memory than necessary. + this.render(this.options.hover.animationDuration, true); } } @@ -2586,7 +2591,7 @@ update: function(reset) { - this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; + this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) / 2) - this.chart.options.elements.arc.borderWidth / 2; this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; @@ -3760,11 +3765,13 @@ // label settings labels: { show: true, + mirror: false, + padding: 10, template: "<%=value.toLocaleString()%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", - fontFamily: "Helvetica Neue", + fontFamily: "Helvetica Neue" } }; @@ -3896,10 +3903,14 @@ var range = this.end - this.start; if (this.isHorizontal()) { - pixel = this.left + (this.width / range * (value - this.start)); + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + pixel = this.left + (innerWidth / range * (value - this.start)); + pixel += this.paddingLeft; } else { // Bottom - top since pixels increase downard on a screen - pixel = this.bottom - (this.height / range * (value - this.start)); + var innerHeight = this.height - (this.paddingTop + this.paddingBottom); + pixel = this.bottom - (innerHeight / range * (value - this.start)); + pixel += this.paddingTop; } return pixel; @@ -4073,7 +4084,7 @@ // @param {number} maxWidth : the max width the axis can be // @param {number} maxHeight: the max height the axis can be // @return {object} minSize : the minimum size needed to draw the axis - fit: function(maxWidth, maxHeight) { + fit: function(maxWidth, maxHeight, margins) { this.calculateRange(); this.generateTicks(maxWidth, maxHeight); this.buildLabels(); @@ -4116,6 +4127,10 @@ minSize.height = maxHeight; // fill all the height } + this.paddingLeft = 0; + this.paddingRight = 0; + this.paddingTop = 0; + this.paddingBottom = 0; if (this.options.labels.show && this.options.display) { @@ -4128,6 +4143,16 @@ var maxLabelHeight = maxHeight - minSize.height; var labelHeight = 1.5 * this.options.labels.fontSize; minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstLabelWidth = this.ctx.measureText(this.labels[0]).width; + var lastLabelWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + + // Ensure that our labels are always inside the canvas + this.paddingLeft = firstLabelWidth / 2; + this.paddingRight = lastLabelWidth / 2; } else { // A vertical axis is more constrained by the width. Labels are the dominant factor // here, so get that length first @@ -4137,13 +4162,29 @@ if (largestTextWidth < maxLabelWidth) { // We don't need all the room minSize.width += largestTextWidth; + minSize.width += 3; // extra padding } else { // Expand to max size minSize.width = maxWidth; } + + this.paddingTop = this.options.labels.fontSize / 2; + this.paddingBottom = this.options.labels.fontSize / 2; } } + if (margins) { + this.paddingLeft -= margins.left; + this.paddingTop -= margins.top; + this.paddingRight -= margins.right; + this.paddingBottom -= margins.bottom; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingTop = Math.max(this.paddingTop, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + this.paddingBottom = Math.max(this.paddingBottom, 0); + } + this.width = minSize.width; this.height = minSize.height; return minSize; @@ -4280,12 +4321,22 @@ var labelStartX; if (this.options.position == "left") { - labelStartX = this.right - 10; - this.ctx.textAlign = "right"; + if (this.options.labels.mirror) { + labelStartX = this.right + this.options.labels.padding; + this.ctx.textAlign = "left"; + } else { + labelStartX = this.right - this.options.labels.padding; + this.ctx.textAlign = "right"; + } } else { // right side - labelStartX = this.left + 5; - this.ctx.textAlign = "left"; + if (this.options.labels.mirror) { + labelStartX = this.left - this.options.labels.padding; + this.ctx.textAlign = "right"; + } else { + labelStartX = this.left + this.options.labels.padding; + this.ctx.textAlign = "left"; + } } this.ctx.textBaseline = "middle"; diff --git a/Chart.min.js b/Chart.min.js index 4fe68fcdac5..6a07e3417dd 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendTemplate:'
      <% for (var i = 0; i < data.datasets.length; i++){%>
    • <%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    '}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==s[a][i].type?s[a][i]=e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):s[a][i]=e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?s[a]=e.configMerge(s[a],t):s[a]=t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),f=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),p=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=f-p,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:p,max:p+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},f=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-left"))+parseInt(f(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(f(e,"padding-bottom"))+parseInt(f(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else"number"==typeof i?this._view[a]=i*t:this._view[a]=i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames=this.dropFrames%1);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=(s-t)/this.frameDuration;this.dropFrames+=o,this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],f=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},p=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,f),i.each(r,f),i.each(h,p),i.each(l,p);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,_=o,D=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){_+=t.height}),i.each(l,function(t){D+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:_,bottom:D};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=_,t.bottom=_+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:_,right:w+b,bottom:_+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(t){var e,a,r,h,l,c=[],u=[],d=[];return i.each(this._data.datasets,function(t){e=t.metaData,e[s]&&e[s].hasValue()&&c.push(e[s])},this),i.each(this._options.stacked?c.reverse():c,function(t){u.push(t._view.x),d.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),l=i.min(d),r=i.max(d),h=i.min(u),a=i.max(u),{x:h>this._chart.width/2?h:a,y:(l+r)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id), -this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=(i.min([this.chart.chart.width,this.chart.chart.height])-this.chart.options.elements.arc.borderWidth/2)/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(0===e?t._model.startAngle=Math.PI*-.5:t._model.startAngle=this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,a.next.y>this.chart.chartArea.bottom?t._model.controlPointNextY=this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?t._model.controlPointPreviousY=this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(t){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u+this.paddingLeft&&this.labelRotation<=this.options.labels.maxRotation;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels); -if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation,n=!1;(this.options.labels.fontSize+4)*this.labels.length>this.width-(this.paddingLeft+this.paddingRight)&&(n=1+Math.floor((this.options.labels.fontSize+4)*this.labels.length/(this.width-(this.paddingLeft+this.paddingRight)))),i.each(this.labels,function(r,h){if(!(n>1&&h%n>0)){var l=this.getPixelForValue(r,h,null,!1),c=this.getPixelForValue(r,h,null,!0);this.options.gridLines.show&&(0===h?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,a),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(c,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())}},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;return e=this.isHorizontal()?this.left+this.width/i*(t-this.start):this.bottom-this.height/i*(t-this.start)},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=this.getRightValue(t);null===this.min?this.min=i:ithis.max&&(this.max=i)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rr?a.width+=r:a.width=t}}return this.width=a.width,this.height=a.height,a},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?(l=this.right-10,this.ctx.textAlign="right"):(l=this.left+5,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t,e){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,f=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendTemplate:'
      <% for (var i = 0; i < data.datasets.length; i++){%>
    • <%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    '}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";{var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):s[a][i]=t.type!==s[a][i].type?e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s[a]=s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?e.configMerge(s[a],t):t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),p=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),f=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=p-f,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:f,max:f+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else this._view[a]="number"==typeof i?i*t:i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames=this.dropFrames%1);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=(s-t)/this.frameDuration;this.dropFrames+=o,this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],p=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},f=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,p),i.each(r,p),i.each(h,f),i.each(l,f);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,D=o,_=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){D+=t.height}),i.each(l,function(t){_+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=D,t.bottom=D+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:D,right:w+b,bottom:D+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(){var t,e,a,r,h,l=[],c=[],u=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),u.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(u),a=i.max(u),r=i.min(c),e=i.max(c),{x:r>this._chart.width/2?r:e,y:(h+a)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id) +},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=i.min([this.chart.chart.width,this.chart.chart.height])/2-this.chart.options.elements.arc.borderWidth/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(t._model.startAngle=0===e?Math.PI*-.5:this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){{var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID)}e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u+this.paddingLeft&&this.labelRotation<=this.options.labels.maxRotation;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e) +}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation,n=!1;(this.options.labels.fontSize+4)*this.labels.length>this.width-(this.paddingLeft+this.paddingRight)&&(n=1+Math.floor((this.options.labels.fontSize+4)*this.labels.length/(this.width-(this.paddingLeft+this.paddingRight)))),i.each(this.labels,function(r,h){if(!(n>1&&h%n>0)){var l=this.getPixelForValue(r,h,null,!1),c=this.getPixelForValue(r,h,null,!0);this.options.gridLines.show&&(0===h?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,a),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(c,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())}},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,mirror:!1,padding:10,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;if(this.isHorizontal()){var a=this.width-(this.paddingLeft+this.paddingRight);e=this.left+a/i*(t-this.start),e+=this.paddingLeft}else{var s=this.height-(this.paddingTop+this.paddingBottom);e=this.bottom-s/i*(t-this.start),e+=this.paddingTop}return e},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t){var e=this.getRightValue(t);null===this.min?this.min=e:ethis.max&&(this.max=e)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rc?(s.width+=c,s.width+=3):s.width=t,this.paddingTop=this.options.labels.fontSize/2,this.paddingBottom=this.options.labels.fontSize/2}}return a&&(this.paddingLeft-=a.left,this.paddingTop-=a.top,this.paddingRight-=a.right,this.paddingBottom-=a.bottom,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingTop=Math.max(this.paddingTop,0),this.paddingRight=Math.max(this.paddingRight,0),this.paddingBottom=Math.max(this.paddingBottom,0)),this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?this.options.labels.mirror?(l=this.right+this.options.labels.padding,this.ctx.textAlign="left"):(l=this.right-this.options.labels.padding,this.ctx.textAlign="right"):this.options.labels.mirror?(l=this.left-this.options.labels.padding,this.ctx.textAlign="right"):(l=this.left+this.options.labels.padding,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;t.textAlign=0===e?"center":e===n?"center":n>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i = 0; i < data.datasets[0].data.length; i++){%>
  • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
  • <%}%>'};e.Doughnut=function(t,s){return s.options=i.configMerge(a,s.options),s.type="doughnut",new e(t,s)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={legendTemplate:'
      <% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    '};e.PolarArea=function(t,s){return s.options=i.configMerge(a,s.options),s.type="polarArea",new e(t,s)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Radar=function(t,i){return i.type="radar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function s(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function o(t){var e=t[0],i=t[1],s=t[2],o=a(t)[0],n=1/255*Math.min(e,Math.min(i,s)),s=1-1/255*Math.max(e,Math.max(i,s));return[o,100*n,100*s]}function n(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function h(t){return $[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function c(t){var e,i,a,s=l(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function u(t){return B(c(t))}function d(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function m(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function f(t){return o(d(t))}function p(t){return n(d(t))}function v(t){return h(d(t))}function x(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function y(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function w(t){return o(x(t))}function C(t){return n(x(t))}function _(t){return h(x(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function k(t){return a(D(t))}function S(t){return s(D(t))}function A(t){return n(D(t))}function P(t){return h(D(t))}function I(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function M(t){return a(I(t))}function W(t){return s(I(t))}function R(t){return o(I(t))}function V(t){return h(I(t))}function O(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function z(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function F(t){return B(z(t))}function L(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function B(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function T(t){return O(L(t))}function E(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function N(t){return L(E(t))}function H(t){return T(E(t))}function q(t){return Z[t]}function j(t){return a(q(t))}function Y(t){return s(q(t))}function X(t){return o(q(t))}function J(t){return n(q(t))}function Q(t){return c(q(t))}function U(t){return l(q(t))}e.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:u,hsl2rgb:d,hsl2hsv:m,hsl2hwb:f,hsl2cmyk:p,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:w,hsv2cmyk:C,hsv2keyword:_,hwb2rgb:D,hwb2hsl:k,hwb2hsv:S,hwb2cmyk:A,hwb2keyword:P,cmyk2rgb:I,cmyk2hsl:M,cmyk2hsv:W,cmyk2hwb:R,cmyk2keyword:V,keyword2rgb:q,keyword2hsl:j,keyword2hsv:Y,keyword2hwb:X,keyword2cmyk:J,keyword2lab:Q,keyword2xyz:U,xyz2rgb:O,xyz2lab:z,xyz2lch:F,lab2xyz:L,lab2rgb:T,lab2lch:B,lch2lab:E,lch2xyz:N,lch2rgb:H};var Z={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},$={};for(var G in Z)$[JSON.stringify(Z[G])]=G},{}],3:[function(t,e,i){var a=t("./conversions"),s=function(){return new l};for(var o in a){s[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),a[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];s[r]=s[r]||{},s[r][h]=s[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=a[t](e);if("string"==typeof i||void 0===i)return i;for(var s=0;se||t[3]&&t[3]<1?u(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function u(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function d(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?f(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function v(t){return w[t.slice(0,3)]}function b(t,e,i){return Math.min(Math.max(e,t),i)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:a,getHsla:s,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:u,percentString:d,percentaString:g,hslString:m,hslaString:f,hwbString:p,keyword:v};var w={};for(var C in y)w[y[C]]=C},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i = 0; i < data.datasets[0].data.length; i++){%>
  • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
  • <%}%>'};e.Doughnut=function(t,s){return s.options=i.configMerge(a,s.options),s.type="doughnut",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={legendTemplate:'
      <% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    '};e.PolarArea=function(t,s){return s.options=i.configMerge(a,s.options),s.type="polarArea",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Radar=function(t,i){return i.type="radar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function a(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],a=t[1],s=t[2],o=i(t)[0],n=1/255*Math.min(e,Math.min(a,s)),s=1-1/255*Math.max(e,Math.max(a,s));return[o,100*n,100*s]}function o(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function n(t){return Z[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function l(t){var e,i,a,s=h(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function c(t){return L(l(t))}function u(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function d(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return s(u(t))}function p(t){return o(u(t))}function f(t){return n(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function x(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function y(t){return s(v(t))}function w(t){return o(v(t))}function C(t){return n(v(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(D(t))}function k(t){return a(D(t))}function S(t){return o(D(t))}function A(t){return n(D(t))}function P(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return i(P(t))}function M(t){return a(P(t))}function R(t){return s(P(t))}function W(t){return n(P(t))}function V(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function O(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return L(O(t))}function F(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function L(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function B(t){return V(F(t))}function T(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function E(t){return F(T(t))}function N(t){return B(T(t))}function H(t){return U[t]}function q(t){return i(H(t))}function j(t){return a(H(t))}function Y(t){return s(H(t))}function X(t){return o(H(t))}function J(t){return l(H(t))}function Q(t){return h(H(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:u,hsl2hsv:d,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:v,hsv2hsl:x,hsv2hwb:y,hsv2cmyk:w,hsv2keyword:C,hwb2rgb:D,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:A,cmyk2rgb:P,cmyk2hsl:I,cmyk2hsv:M,cmyk2hwb:R,cmyk2keyword:W,keyword2rgb:H,keyword2hsl:q,keyword2hsv:j,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:J,keyword2xyz:Q,xyz2rgb:V,xyz2lab:O,xyz2lch:z,lab2xyz:F,lab2rgb:B,lab2lch:L,lch2lab:T,lch2xyz:E,lch2rgb:N};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in U)Z[JSON.stringify(U[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),a=function(){return new h};for(var s in i){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),n=o[1],r=o[2];a[n]=a[n]||{},a[n][r]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return d(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function d(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return y[t.slice(0,3)]}function v(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:a,getRgb:o,getHsl:n,getHwb:s,getAlpha:r,hexString:h,rgbString:l,rgbaString:c,percentString:u,percentaString:d,hslString:g,hslaString:m,hwbString:p,keyword:f};var y={};for(var w in x)y[x[w]]=w},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 1b4cbe3953c..5b611e8ea4b 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -491,7 +491,10 @@ (this.lastActive.length && this.active.length && changed)) { this.stop(); - this.update(this.options.hover.animationDuration, true); + + // We only need to render at this point. Updating will cause scales to be recomputed generating flicker & using more + // memory than necessary. + this.render(this.options.hover.animationDuration, true); } } From eb833723cd1d3ae600386451312945b9767b6ebc Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 8 Aug 2015 18:34:19 -0400 Subject: [PATCH 249/424] initial logarithmic scale --- samples/line-logarithmic.html | 154 ++++++++ src/scales/scale.logarithmic.js | 643 ++++++++++++++++++++++++++++++++ 2 files changed, 797 insertions(+) create mode 100644 samples/line-logarithmic.html create mode 100644 src/scales/scale.logarithmic.js diff --git a/samples/line-logarithmic.html b/samples/line-logarithmic.html new file mode 100644 index 00000000000..1123c23002b --- /dev/null +++ b/samples/line-logarithmic.html @@ -0,0 +1,154 @@ + + + + + Line Chart + + + + + + +
    + +
    +
    +
    + + + + + +
    +

    Legend

    +
    + +
    +
    + + + + diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js new file mode 100644 index 00000000000..68897a9509d --- /dev/null +++ b/src/scales/scale.logarithmic.js @@ -0,0 +1,643 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + display: true, + position: "left", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + + // scale numbers + reverse: false, + beginAtZero: false, + override: null, + + // label settings + labels: { + show: true, + mirror: false, + padding: 10, + template: "<%=value.toExponential()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue" + } + }; + + var LogarithmicScale = Chart.Element.extend({ + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + generateTicks: function(width, height) { + // We need to decide how many ticks we are going to have. Each tick draws a grid line. + // There are two possibilities. The first is that the user has manually overridden the scale + // calculations in which case the job is easy. The other case is that we have to do it ourselves + // + // We assume at this point that the scale object has been updated with the following values + // by the chart. + // min: this is the minimum value of the scale + // max: this is the maximum value of the scale + // options: contains the options for the scale. This is referenced from the user settings + // rather than being cloned. This ensures that updates always propogate to a redraw + + // Reset the ticks array. Later on, we will draw a grid line at these positions + // The array simply contains the numerical value of the spots where ticks will be + this.ticks = []; + + if (this.options.override) { + // The user has specified the manual override. We use <= instead of < so that + // we get the final line + for (var i = 0; i <= this.options.override.steps; ++i) { + var value = this.options.override.start + (i * this.options.override.stepWidth); + this.ticks.push(value); + } + } else { + // Figure out what the max number of ticks we can support it is based on the size of + // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 + // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on + // the graph + + var minExponent = Math.floor(helpers.log10(this.min)); + var maxExponent = Math.ceil(helpers.log10(this.max)); + + for (var exponent = minExponent; exponent < maxExponent; ++exponent) { + /*this.ticks.push(1.0 * Math.pow(10, exponent)); + this.ticks.push(2.0 * Math.pow(10, exponent)); + this.ticks.push(5.0 * Math.pow(10, exponent));*/ + for (var i = 1; i < 10; ++i) { + if (i === 1 || i === 2 || i === 3 || i === 5 || i === 7) { + this.ticks.push(i * Math.pow(10, exponent)); + } + } + } + + this.ticks.push(1.0 * Math.pow(10, maxExponent)); + + /*var maxTicks; + + if (this.isHorizontal()) { + maxTicks = Math.min(11, Math.ceil(width / 50)); + } else { + // The factor of 2 used to scale the font size has been experimentally determined. + maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); + } + + // Make sure we always have at least 2 ticks + maxTicks = Math.max(2, maxTicks); + + // To get a "nice" value for the tick spacing, we will use the appropriately named + // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks + // for details. + + // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, + // do nothing since that would make the chart weird. If the user really wants a weird chart + // axis, they can manually override it + if (this.options.beginAtZero) { + var minSign = helpers.sign(this.min); + var maxSign = helpers.sign(this.max); + + if (minSign < 0 && maxSign < 0) { + // move the top up to 0 + this.max = 0; + } else if (minSign > 0 && maxSign > 0) { + // move the botttom down to 0 + this.min = 0; + } + } + + var niceRange = helpers.niceNum(this.max - this.min, false); + var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); + var niceMin = Math.floor(this.min / spacing) * spacing; + var niceMax = Math.ceil(this.max / spacing) * spacing; + + // Put the values into the ticks array + for (var j = niceMin; j <= niceMax; j += spacing) { + this.ticks.push(j); + }*/ + } + + if (this.options.position == "left" || this.options.position == "right") { + // We are in a vertical orientation. The top value is the highest. So reverse the array + this.ticks.reverse(); + } + + // At this point, we need to update our max and min given the tick values since we have expanded the + // range of the scale + this.max = helpers.max(this.ticks); + this.min = helpers.min(this.ticks); + + if (this.options.reverse) { + this.ticks.reverse(); + + this.start = this.max; + this.end = this.min; + } else { + this.start = this.min; + this.end = this.max; + } + }, + buildLabels: function() { + // We assume that this has been run after ticks have been generated. We try to figure out + // a label for each tick. + this.labels = []; + + helpers.each(this.ticks, function(tick, index, ticks) { + var label; + + if (this.options.labels.userCallback) { + // If the user provided a callback for label generation, use that as first priority + label = this.options.labels.userCallback(tick, index, ticks); + } else if (this.options.labels.template) { + // else fall back to the template string + label = helpers.template(this.options.labels.template, { + value: tick + }); + } + + this.labels.push(label ? label : ""); // empty string will not render so we're good + }, this); + }, + // Get the correct value. If the value type is object get the x or y based on whether we are horizontal or not + getRightValue: function(rawValue) { + return typeof rawValue === "object" ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; + }, + getPixelForValue: function(value) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + var pixel; + var range = helpers.log10(this.end) - helpers.log10(this.start); + + if (this.isHorizontal()) { + if (value === 0) { + pixel = this.left + this.paddingLeft; + } else { + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + pixel = this.left + (innerWidth / range * (helpers.log10(value) - helpers.log10(this.start))); + pixel += this.paddingLeft; + } + } else { + // Bottom - top since pixels increase downard on a screen + if (value === 0) { + pixel = this.top + this.paddingTop; + } else { + var innerHeight = this.height - (this.paddingTop + this.paddingBottom); + pixel = this.bottom - (innerHeight / range * (helpers.log10(value) - helpers.log10(this.start))); + pixel += this.paddingTop; + } + } + + return pixel; + }, + + // Functions needed for line charts + calculateRange: function() { + this.min = null; + this.max = null; + + var positiveValues = []; + var negativeValues = []; + + if (this.options.stacked) { + helpers.each(this.data.datasets, function(dataset) { + if (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(rawValue, index) { + + var value = this.getRightValue(rawValue); + + positiveValues[index] = positiveValues[index] || 0; + negativeValues[index] = negativeValues[index] || 0; + + if (this.options.relativePoints) { + positiveValues[index] = 100; + } else { + if (value < 0) { + negativeValues[index] += value; + } else { + positiveValues[index] += value; + } + } + }, this); + } + }, this); + + var values = positiveValues.concat(negativeValues); + this.min = helpers.min(values); + this.max = helpers.max(values); + + } else { + helpers.each(this.data.datasets, function(dataset) { + if (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id) { + helpers.each(dataset.data, function(rawValue, index) { + var value = this.getRightValue(rawValue); + + if (this.min === null) { + this.min = value; + } else if (value < this.min) { + this.min = value; + } + + if (this.max === null) { + this.max = value; + } else if (value > this.max) { + this.max = value; + } + }, this); + } + }, this); + } + + if (this.min === this.max) { + this.min--; + this.max++; + } + }, + + getPointPixelForValue: function(rawValue, index, datasetIndex) { + var value = this.getRightValue(rawValue); + + if (this.options.stacked) { + var offsetPos = 0; + var offsetNeg = 0; + + for (var i = this.data.datasets.length - 1; i > datasetIndex; --i) { + if (this.data.datasets[i].data[index] < 0) { + offsetNeg += this.data.datasets[i].data[index]; + } else { + offsetPos += this.data.datasets[i].data[index]; + } + } + + if (value < 0) { + return this.getPixelForValue(offsetNeg + value); + } else { + return this.getPixelForValue(offsetPos + value); + } + } else { + return this.getPixelForValue(value); + } + }, + + // Functions needed for bar charts + calculateBarBase: function(datasetIndex, index) { + var base = 0; + + if (this.options.stacked) { + + var value = this.data.datasets[datasetIndex].data[index]; + + if (value < 0) { + for (var i = 0; i < datasetIndex; i++) { + if (this.data.datasets[i].yAxisID === this.id) { + base += this.data.datasets[i].data[index] < 0 ? this.data.datasets[i].data[index] : 0; + } + } + } else { + for (var j = 0; j < datasetIndex; j++) { + if (this.data.datasets[j].yAxisID === this.id) { + base += this.data.datasets[j].data[index] > 0 ? this.data.datasets[j].data[index] : 0; + } + } + } + + return this.getPixelForValue(base); + } + + base = this.getPixelForValue(this.min); + + if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { + base = this.getPixelForValue(0); + base += this.options.gridLines.lineWidth; + } else if (this.min < 0 && this.max < 0) { + // All values are negative. Use the top as the base + base = this.getPixelForValue(this.max); + } + + return base; + + }, + calculateBarY: function(datasetIndex, index) { + var value = this.data.datasets[datasetIndex].data[index]; + + if (this.options.stacked) { + + var sumPos = 0, + sumNeg = 0; + + for (var i = 0; i < datasetIndex; i++) { + if (this.data.datasets[i].data[index] < 0) { + sumNeg += this.data.datasets[i].data[index] || 0; + } else { + sumPos += this.data.datasets[i].data[index] || 0; + } + } + + if (value < 0) { + return this.getPixelForValue(sumNeg + value); + } else { + return this.getPixelForValue(sumPos + value); + } + + return this.getPixelForValue(value); + } + + var offset = 0; + + for (var j = datasetIndex; j < this.data.datasets.length; j++) { + if (j === datasetIndex && value) { + offset += value; + } else { + offset = offset + value; + } + } + + return this.getPixelForValue(value); + }, + + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight, margins) { + this.calculateRange(); + this.generateTicks(maxWidth, maxHeight); + this.buildLabels(); + + var minSize = { + width: 0, + height: 0, + }; + + // In a horizontal axis, we need some room for the scale to be drawn + // + // ----------------------------------------------------- + // | | | | | + // + // In a vertical axis, we need some room for the scale to be drawn. + // The actual grid lines will be drawn on the chart area, however, we need to show + // ticks where the axis actually is. + // We will allocate 25px for this width + // | + // -| + // | + // | + // -| + // | + // | + // -| + + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; // fill all the width + } else { + minSize.width = this.options.gridLines.show && this.options.display ? 10 : 0; + } + + // height + if (this.isHorizontal()) { + minSize.height = this.options.gridLines.show && this.options.display ? 10 : 0; + } else { + minSize.height = maxHeight; // fill all the height + } + + this.paddingLeft = 0; + this.paddingRight = 0; + this.paddingTop = 0; + this.paddingBottom = 0; + + + if (this.options.labels.show && this.options.display) { + // Don't bother fitting the labels if we are not showing them + var labelFont = helpers.fontString(this.options.labels.fontSize, + this.options.labels.fontStyle, this.options.labels.fontFamily); + + if (this.isHorizontal()) { + // A horizontal axis is more constrained by the height. + var maxLabelHeight = maxHeight - minSize.height; + var labelHeight = 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(maxHeight, minSize.height + labelHeight); + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstLabelWidth = this.ctx.measureText(this.labels[0]).width; + var lastLabelWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + + // Ensure that our labels are always inside the canvas + this.paddingLeft = firstLabelWidth / 2; + this.paddingRight = lastLabelWidth / 2; + } else { + // A vertical axis is more constrained by the width. Labels are the dominant factor + // here, so get that length first + var maxLabelWidth = maxWidth - minSize.width; + var largestTextWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + if (largestTextWidth < maxLabelWidth) { + // We don't need all the room + minSize.width += largestTextWidth; + minSize.width += 3; // extra padding + } else { + // Expand to max size + minSize.width = maxWidth; + } + + this.paddingTop = this.options.labels.fontSize / 2; + this.paddingBottom = this.options.labels.fontSize / 2; + } + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingTop -= margins.top; + this.paddingRight -= margins.right; + this.paddingBottom -= margins.bottom; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingTop = Math.max(this.paddingTop, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + this.paddingBottom = Math.max(this.paddingBottom, 0); + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + var hasZero; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + if (this.options.gridLines.show) { + // Draw the horizontal line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 5; + var yTickEnd = this.options.position == "bottom" ? this.top + 5 : this.bottom; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are vertical + var xValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the left if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xValue, yTickStart); + this.ctx.lineTo(xValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xValue, chartArea.top); + this.ctx.lineTo(xValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartY; + + if (this.options.position == "top") { + labelStartY = this.bottom - 10; + this.ctx.textBaseline = "bottom"; + } else { + // bottom side + labelStartY = this.top + 10; + this.ctx.textBaseline = "top"; + } + + this.ctx.textAlign = "center"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var xValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, xValue, labelStartY); + }, this); + } + } else { + // Vertical + if (this.options.gridLines.show) { + + // Draw the vertical line + setContextLineSettings = true; + hasZero = helpers.findNextWhere(this.ticks, function(tick) { + return tick === 0; + }) !== undefined; + var xTickStart = this.options.position == "right" ? this.left : this.right - 5; + var xTickEnd = this.options.position == "right" ? this.left + 5 : this.right; + + helpers.each(this.ticks, function(tick, index) { + // Grid lines are horizontal + var yValue = this.getPixelForValue(tick); + + if (tick === 0 || (!hasZero && index === 0)) { + // Draw the 0 point specially or the bottom if there is no 0 + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; // use boolean to indicate that we only want to do this once + } + + yValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xTickStart, yValue); + this.ctx.lineTo(xTickEnd, yValue); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(chartArea.left, yValue); + this.ctx.lineTo(chartArea.right, yValue); + } + + this.ctx.stroke(); + }, this); + } + + if (this.options.labels.show) { + // Draw the labels + + var labelStartX; + + if (this.options.position == "left") { + if (this.options.labels.mirror) { + labelStartX = this.right + this.options.labels.padding; + this.ctx.textAlign = "left"; + } else { + labelStartX = this.right - this.options.labels.padding; + this.ctx.textAlign = "right"; + } + } else { + // right side + if (this.options.labels.mirror) { + labelStartX = this.left - this.options.labels.padding; + this.ctx.textAlign = "right"; + } else { + labelStartX = this.left + this.options.labels.padding; + this.ctx.textAlign = "left"; + } + } + + this.ctx.textBaseline = "middle"; + this.ctx.font = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + + helpers.each(this.labels, function(label, index) { + var yValue = this.getPixelForValue(this.ticks[index]); + this.ctx.fillText(label, labelStartX, yValue); + }, this); + } + } + } + } + }); + Chart.scaleService.registerScaleType("logarithmic", LogarithmicScale, defaultConfig); + +}).call(this); From 94c1ec4b849d8857129c2552b39a47cf0c02de79 Mon Sep 17 00:00:00 2001 From: Fabian Strachanski Date: Thu, 13 Aug 2015 10:50:56 +0200 Subject: [PATCH 250/424] Fix for #1373 --- src/scales/scale.linear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index c9827e02ef0..642ea0c4969 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -157,7 +157,7 @@ }, // Get the correct value. If the value type is object get the x or y based on whether we are horizontal or not getRightValue: function(rawValue) { - return typeof rawValue === "object" ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; + return typeof (rawValue === "object" && rawValue !== null) ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; }, getPixelForValue: function(value) { // This must be called after fit has been run so that From dd62944b79e0294880dd510961bd2a85df540f9f Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 15 Aug 2015 10:54:34 -0400 Subject: [PATCH 251/424] Fix bracket placement --- src/scales/scale.linear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 642ea0c4969..7adf6391a52 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -157,7 +157,7 @@ }, // Get the correct value. If the value type is object get the x or y based on whether we are horizontal or not getRightValue: function(rawValue) { - return typeof (rawValue === "object" && rawValue !== null) ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; + return (typeof (rawValue) === "object" && rawValue !== null) ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; }, getPixelForValue: function(value) { // This must be called after fit has been run so that From 24a78e772c6211d43f22b918a7d37898903eba3d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 15 Aug 2015 10:56:55 -0400 Subject: [PATCH 252/424] Proper template string caching --- src/core/core.helpers.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 8f52854d97b..2fbb644a908 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -458,6 +458,7 @@ // Blows up jshint errors based on the new Function constructor //Templating methods //Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/ + templateStringCache = {}, template = helpers.template = function(templateString, valuesObject) { // If templateString is function rather than string-template - call the function for valuesObject @@ -466,17 +467,17 @@ return templateString(valuesObject); } - var cache = {}; - function tmpl(str, data) { // Figure out if we're getting a template, or if we need to // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] : + var fn; + if (templateStringCache.hasOwnProperty(str)) { + fn = templateStringCache[str]; + } else { // Generate a reusable function that will serve as a template // generator (and which will be cached). - new Function("obj", + fn = new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + // Introduce the data as local variables using with(){} @@ -494,6 +495,10 @@ "');}return p.join('');" ); + // Cache the result + templateStringCache[str] = fn; + } + // Provide some basic currying to the user return data ? fn(data) : fn; } From de413294ca363a25c8f5a28367bececa1fbe8380 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 22 Aug 2015 14:30:30 -0400 Subject: [PATCH 253/424] Category scale now takes a smaller size if no labels are being displayed. Updated linear scale code to use proper bottom padding. This is important when not displaying x axis labels --- src/scales/scale.category.js | 5 +++-- src/scales/scale.linear.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 98b28d072fa..ec355c77cd1 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -192,13 +192,14 @@ if (this.isHorizontal()) { minSize.width = maxWidth; } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + var labelWidth = this.options.labels.show ? longestLabelWidth + 6 : 0; + minSize.width = Math.min(labelWidth, maxWidth); } // Height if (this.isHorizontal() && this.options.display) { var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); + minSize.height = Math.min(this.options.labels.show ? labelHeight : 0, maxHeight); } else if (this.options.display) { minSize.height = maxHeight; } diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 7adf6391a52..b39c89bdc0c 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -172,7 +172,7 @@ } else { // Bottom - top since pixels increase downard on a screen var innerHeight = this.height - (this.paddingTop + this.paddingBottom); - pixel = this.bottom - (innerHeight / range * (value - this.start)); + pixel = (this.bottom - this.paddingBottom) - (innerHeight / range * (value - this.start)); pixel += this.paddingTop; } From 86ecca1c3878fc130fd5f8fa23e0499c1840e401 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 22 Aug 2015 16:13:19 -0400 Subject: [PATCH 254/424] If setLineDash is not available, do not set it. --- src/elements/element.line.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/elements/element.line.js b/src/elements/element.line.js index c03f066848a..62c316c959b 100644 --- a/src/elements/element.line.js +++ b/src/elements/element.line.js @@ -114,7 +114,12 @@ // Now draw the line between all the points with any borders ctx.lineCap = vm.borderCapStyle || Chart.defaults.global.elements.line.borderCapStyle; - ctx.setLineDash(vm.borderDash || Chart.defaults.global.elements.line.borderDash); + + // IE 9 and 10 do not support line dash + if (ctx.setLineDash) { + ctx.setLineDash(vm.borderDash || Chart.defaults.global.elements.line.borderDash); + } + ctx.lineDashOffset = vm.borderDashOffset || Chart.defaults.global.elements.line.borderDashOffset; ctx.lineJoin = vm.borderJoinStyle || Chart.defaults.global.elements.line.borderJoinStyle; ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; From 02abc46d5e1ece800bfb20501950aebb0d79825e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 22 Aug 2015 16:56:02 -0400 Subject: [PATCH 255/424] Count the number of bars when determining the bar width --- src/controllers/controller.bar.js | 30 +++++++++++++++++++++++++----- src/scales/scale.category.js | 10 +++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index c68d478c5e1..94decab0499 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -61,6 +61,21 @@ return this.chart.scales[scaleID]; }, + // Get the number of datasets that display bars. We use this to correctly calculate the bar width + getBarCount: function getBarCount() { + var barCount = 0; + + helpers.each(this.chart.data.datasets, function(dataset) { + if (dataset.type === 'bar') { + ++barCount; + } else if (dataset.type === undefined && this.chart.config.type === 'bar') { + ++barCount; + } + }, this); + + return barCount; + }, + addElements: function() { this.getDataset().metaData = this.getDataset().metaData || []; helpers.each(this.getDataset().data, function(value, index) { @@ -78,7 +93,10 @@ _datasetIndex: this.index, _index: index, }); - this.updateElement(rectangle, index, true); + + var numBars = this.getBarCount(); + + this.updateElement(rectangle, index, true, numBars); this.getDataset().metaData.splice(index, 0, rectangle); }, removeElement: function(index) { @@ -90,12 +108,14 @@ }, update: function(reset) { + var numBars = this.getBarCount(); + helpers.each(this.getDataset().metaData, function(rectangle, index) { - this.updateElement(rectangle, index, reset); + this.updateElement(rectangle, index, reset, numBars); }, this); }, - updateElement: function updateElement(rectangle, index, reset) { + updateElement: function updateElement(rectangle, index, reset, numBars) { var xScale = this.getScaleForId(this.getDataset().xAxisID); var yScale = this.getScaleForId(this.getDataset().yAxisID); var yScalePoint; @@ -120,7 +140,7 @@ // Desired view properties _model: { - x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), + x: xScale.calculateBarX(numBars, this.index, index), y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), // Tooltip @@ -129,7 +149,7 @@ // Appearance base: yScale.calculateBarBase(this.index, index), - width: xScale.calculateBarWidth(this.chart.data.datasets.length), + width: xScale.calculateBarWidth(numBars), backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index ec355c77cd1..d97699c1f3d 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -75,19 +75,19 @@ calculateBaseWidth: function() { return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); }, - calculateBarWidth: function(datasetCount) { + calculateBarWidth: function(barDatasetCount) { //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); + var baseWidth = this.calculateBaseWidth() - ((barDatasetCount - 1) * this.options.spacing); if (this.options.stacked) { return baseWidth; } - return (baseWidth / datasetCount); + return (baseWidth / barDatasetCount); }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + calculateBarX: function(barDatasetCount, datasetIndex, elementIndex) { var xWidth = this.calculateBaseWidth(), xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); + barWidth = this.calculateBarWidth(barDatasetCount); if (this.options.stacked) { return xAbsolute + barWidth / 2; From 04d1f0f710059fe46ab20e3237689dcfd4db99ce Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 23 Aug 2015 13:20:43 -0400 Subject: [PATCH 256/424] Category scale filter function will hide the grid line if `null` or `undefined` returned. --- docs/00-Getting-Started.md | 3 +++ samples/line-x-axis-filter.html | 2 +- src/scales/scale.category.js | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index 83b3cf691d4..5aeac0a1bd5 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -403,6 +403,9 @@ The `userCallback` method may be useful when there are a lot of labels. The foll xAxes: [{ labels: { maxRotation: 0, // set maxRotation to 0 to turn off auto-rotation + + // Return an empty string to draw the grid line but hide the label + // Return `null` or `undefined` to hide the grid line userCallback: function(labelString, index) { return (index % 5 === 0) ? labelString : ''; } diff --git a/samples/line-x-axis-filter.html b/samples/line-x-axis-filter.html index 3b5b82f280a..71a1b8844a3 100644 --- a/samples/line-x-axis-filter.html +++ b/samples/line-x-axis-filter.html @@ -55,7 +55,7 @@ display: true, labels: { userCallback: function(dataLabel, index) { - return index % 2 === 0 ? dataLabel : ''; + return index % 2 === 0 ? dataLabel : null; } } }], diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index d97699c1f3d..7912f8dcb06 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -230,7 +230,8 @@ } helpers.each(this.labels, function(label, index) { - if (skipRatio > 1 && index % skipRatio > 0) { + // Blank labels + if ((skipRatio > 1 && index % skipRatio > 0) || (label === undefined || label === null)) { return; } var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines From c1cca356df0b5cddf19da5a8285a2c93650f849b Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 23 Aug 2015 14:58:19 -0400 Subject: [PATCH 257/424] Initial test setup --- gulpfile.js | 187 +++++++++++++++++++++++++++----------------------- karma.conf.js | 9 +++ package.json | 65 ++++++++++-------- 3 files changed, 147 insertions(+), 114 deletions(-) create mode 100644 karma.conf.js diff --git a/gulpfile.js b/gulpfile.js index 9ce3dc3f4bb..d7dda48bf52 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,52 +1,55 @@ 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'), - replace = require('gulp-replace'), - htmlv = require('gulp-html-validator'), - inquirer = require('inquirer'), - semver = require('semver'), - exec = require('child_process').exec, - fs = require('fs'), - package = require('./package.json'), - bower = require('./bower.json'); + concat = require('gulp-concat'), + uglify = require('gulp-uglify'), + util = require('gulp-util'), + jshint = require('gulp-jshint'), + 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, + fs = require('fs'), + package = require('./package.json'), + bower = require('./bower.json'), + karma = require('gulp-karma'); var srcDir = './src/'; +var testDir = './test/'; /* * 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 */ +var srcFiles = [ + './src/core/core.js', + './src/core/core.helpers.js', + './src/core/core.chart.js', + './src/core/core.element.js', + './src/core/**', + './src/controllers/**', + './src/scales/**', + './src/elements/**', + './src/charts/**', + './node_modules/color/dist/color.min.js' + ]; + gulp.task('build', function() { - var srcFiles = [ - './src/core/core.js', - './src/core/core.helpers.js', - './src/core/core.chart.js', - './src/core/core.element.js', - './src/core/**', - './src/controllers/**', - './src/scales/**', - './src/elements/**', - './src/charts/**', - './node_modules/color/dist/color.min.js' - ], - isCustom = !!(util.env.types), - outputDir = (isCustom) ? 'custom' : '.'; - - return gulp.src(srcFiles) - .pipe(concat('Chart.js')) - .pipe(replace('{{ version }}', package.version)) - .pipe(gulp.dest(outputDir)) - .pipe(uglify({ - preserveComments: 'some' - })) - .pipe(concat('Chart.min.js')) - .pipe(gulp.dest(outputDir)); + var isCustom = !!(util.env.types), + outputDir = (isCustom) ? 'custom' : '.'; + + return gulp.src(srcFiles) + .pipe(concat('Chart.js')) + .pipe(replace('{{ version }}', package.version)) + .pipe(gulp.dest(outputDir)) + .pipe(uglify({ + preserveComments: 'some' + })) + .pipe(concat('Chart.min.js')) + .pipe(gulp.dest(outputDir)); }); @@ -57,66 +60,80 @@ gulp.task('build', function() { */ gulp.task('bump', function(complete) { - util.log('Current version:', util.colors.cyan(package.version)); - var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType) { - return versionType + ' (v' + semver.inc(package.version, versionType) + ')'; - }); - inquirer.prompt({ - type: 'list', - name: 'version', - message: 'What version update would you like?', - choices: choices - }, function(res) { - var increment = res.version.split(' ')[0], - newVersion = semver.inc(package.version, increment); - - // Set the new versions into the bower/package object - package.version = newVersion; - bower.version = newVersion; - - // Write these to their own files, then build the output - fs.writeFileSync('package.json', JSON.stringify(package, null, 2)); - fs.writeFileSync('bower.json', JSON.stringify(bower, null, 2)); - - complete(); - }); + util.log('Current version:', util.colors.cyan(package.version)); + var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType) { + return versionType + ' (v' + semver.inc(package.version, versionType) + ')'; + }); + inquirer.prompt({ + type: 'list', + name: 'version', + message: 'What version update would you like?', + choices: choices + }, function(res) { + var increment = res.version.split(' ')[0], + newVersion = semver.inc(package.version, increment); + + // Set the new versions into the bower/package object + package.version = newVersion; + bower.version = newVersion; + + // Write these to their own files, then build the output + fs.writeFileSync('package.json', JSON.stringify(package, null, 2)); + fs.writeFileSync('bower.json', JSON.stringify(bower, null, 2)); + + complete(); + }); }); gulp.task('release', ['build'], function() { - exec('git tag -a v' + package.version); + exec('git tag -a v' + package.version); }); gulp.task('jshint', function() { - return gulp.src(srcDir + '*.js') - .pipe(jshint()) - .pipe(jshint.reporter('default')); + return gulp.src(srcDir + '*.js') + .pipe(jshint()) + .pipe(jshint.reporter('default')); }); gulp.task('valid', function() { - return gulp.src('samples/*.html') - .pipe(htmlv()); + return gulp.src('samples/*.html') + .pipe(htmlv()); +}); + +gulp.task('unittest', function() { + var files = srcFiles.slice(); + files.push(testDir + '*.js'); + + return gulp.src(files) + .pipe(karma({ + configFile: 'karma.conf.js', + action: 'run' + })) + .on('error', function(err) { + throw err; + }); }); gulp.task('library-size', function() { - return gulp.src('Chart.min.js') - .pipe(size({ - gzip: true - })); + 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 - })); + return gulp.src(srcDir + '*.js') + .pipe(uglify({ + preserveComments: 'some' + })) + .pipe(size({ + showFiles: true, + gzip: true + })); }); gulp.task('watch', function() { - gulp.watch('./src/**', ['build']); + gulp.watch('./src/**', ['build']); }); gulp.task('test', ['jshint', 'valid']); @@ -126,15 +143,15 @@ gulp.task('size', ['library-size', 'module-sizes']); gulp.task('default', ['build', 'watch']); gulp.task('server', function() { - connect.server({ - port: 8000 - }); + 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 .'); + exec('open http://localhost:8000'); + exec('subl .'); }); gulp.task('dev', ['server', 'default']); diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000000..a0d60308f08 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,9 @@ +module.exports = function(config) { + config.set({ + autoWatch: false, + browsers: ['Chrome', 'Firefox'], + frameworks: ['jasmine'], + reporters: ['progress'], + singleRun: false + }); +}; \ No newline at end of file diff --git a/package.json b/package.json index cf30a62270e..27ed2888b1a 100644 --- a/package.json +++ b/package.json @@ -1,31 +1,38 @@ { - "name": "chart.js", - "homepage": "http://www.chartjs.org", - "description": "Simple HTML5 charts using the canvas element.", - "version": "2.0.0-alpha", - "main": "Chart.js", - "repository": { - "type": "git", - "url": "https://github.com/nnnick/Chart.js.git" - }, - "dependences": {}, - "devDependencies": { - "color": "git://github.com/chartjs/color", - "gulp": "3.5.x", - "gulp-concat": "~2.1.x", - "gulp-connect": "~2.0.5", - "gulp-html-validator": "^0.0.2", - "gulp-jshint": "~1.5.1", - "gulp-replace": "^0.4.0", - "gulp-size": "~0.4.0", - "gulp-uglify": "~0.2.x", - "gulp-util": "~2.2.x", - "inquirer": "^0.5.1", - "jquery": "^2.1.4", - "onecolor": "^2.5.0", - "semver": "^3.0.1" - }, - "spm": { - "main": "Chart.js" - } + "name": "chart.js", + "homepage": "http://www.chartjs.org", + "description": "Simple HTML5 charts using the canvas element.", + "version": "2.0.0-alpha", + "main": "Chart.js", + "repository": { + "type": "git", + "url": "https://github.com/nnnick/Chart.js.git" + }, + "dependences": {}, + "devDependencies": { + "color": "git://github.com/chartjs/color", + "gulp": "3.5.x", + "gulp-concat": "~2.1.x", + "gulp-connect": "~2.0.5", + "gulp-html-validator": "^0.0.2", + "gulp-jshint": "~1.5.1", + "gulp-karma": "0.0.4", + "gulp-replace": "^0.4.0", + "gulp-size": "~0.4.0", + "gulp-uglify": "~0.2.x", + "gulp-util": "~2.2.x", + "inquirer": "^0.5.1", + "jasmine": "^2.3.2", + "jasmine-core": "^2.3.4", + "jquery": "^2.1.4", + "karma": "^0.12.37", + "karma-chrome-launcher": "^0.2.0", + "karma-firefox-launcher": "^0.1.6", + "karma-jasmine": "^0.3.6", + "onecolor": "^2.5.0", + "semver": "^3.0.1" + }, + "spm": { + "main": "Chart.js" + } } From f636a7897712e5c4ee59e785c4f9793b6cce9513 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 23 Aug 2015 15:55:10 -0400 Subject: [PATCH 258/424] Watch mode runs tests. --- gulpfile.js | 9 +++------ karma.conf.js | 2 -- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d7dda48bf52..560c6b49641 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -107,11 +107,8 @@ gulp.task('unittest', function() { return gulp.src(files) .pipe(karma({ configFile: 'karma.conf.js', - action: 'run' - })) - .on('error', function(err) { - throw err; - }); + action: 'watch' + })); }); gulp.task('library-size', function() { @@ -133,7 +130,7 @@ gulp.task('module-sizes', function() { }); gulp.task('watch', function() { - gulp.watch('./src/**', ['build']); + gulp.watch('./src/**', ['build', 'unittest']); }); gulp.task('test', ['jshint', 'valid']); diff --git a/karma.conf.js b/karma.conf.js index a0d60308f08..cbf72b381ec 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,9 +1,7 @@ module.exports = function(config) { config.set({ - autoWatch: false, browsers: ['Chrome', 'Firefox'], frameworks: ['jasmine'], reporters: ['progress'], - singleRun: false }); }; \ No newline at end of file From b4b3bf60b81e898fac41afc716b5885e928caebc Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 23 Aug 2015 17:17:21 -0400 Subject: [PATCH 259/424] Remove wrong addition of padding --- src/scales/scale.linear.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index b39c89bdc0c..eaab69c6c30 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -173,7 +173,6 @@ // Bottom - top since pixels increase downard on a screen var innerHeight = this.height - (this.paddingTop + this.paddingBottom); pixel = (this.bottom - this.paddingBottom) - (innerHeight / range * (value - this.start)); - pixel += this.paddingTop; } return pixel; From e6dc2fd6ab9b9ae74a85b06ceda80ae52f0c61d5 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 23 Aug 2015 17:17:46 -0400 Subject: [PATCH 260/424] Initial scale tests --- test/scale.linear.tests.js | 409 +++++++++++++++++++++++++++++++++++++ 1 file changed, 409 insertions(+) create mode 100644 test/scale.linear.tests.js diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js new file mode 100644 index 00000000000..f0ac83c392f --- /dev/null +++ b/test/scale.linear.tests.js @@ -0,0 +1,409 @@ +describe('Linear Scale', function() { + + it ('Should register the constructor with the scale service', function() { + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + expect(Constructor).not.toBe(undefined); + expect(typeof Constructor).toBe('function'); + }); + + it ('Should have the correct default config', function() { + var defaultConfig = Chart.scaleService.getScaleDefaults('linear'); + expect(defaultConfig).toEqual({ + display: true, + position: "left", + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + reverse: false, + beginAtZero: false, + override: null, + labels: { + show: true, + mirror: false, + padding: 10, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue" + } + }); + }); + + it ('Should correctly determine the max & min data values', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, -5, 78, -100] + }, { + yAxisID: 'second scale', + data: [-1000, 1000], + }, { + yAxisID: scaleID, + data: [150] + } + ] + }; + + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: Chart.scaleService.getScaleDefaults('linear'), // use default config for scale + data: mockData, + id: scaleID + }); + + expect(scale).not.toEqual(undefined); // must construct + expect(scale.min).toBe(undefined); // not yet set + expect(scale.max).toBe(undefined); + + scale.calculateRange(); + expect(scale.min).toBe(-100); + expect(scale.max).toBe(150); + }); + + it ('Should correctly determine the max & min for scatter data', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [{x: 10, y: 100}, {x: -10, y: 0}, {x: 0, y: 0}, {x: 99, y: 7}] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var verticalScale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + verticalScale.calculateRange(); + expect(verticalScale.min).toBe(0); + expect(verticalScale.max).toBe(100); + + var horizontalConfig = Chart.helpers.clone(config); + horizontalConfig.position = 'bottom'; + var horizontalScale = new Constructor({ + ctx: {}, + options: horizontalConfig, + data: mockData, + id: scaleID, + }); + + horizontalScale.calculateRange(); + expect(horizontalScale.min).toBe(-10); + expect(horizontalScale.max).toBe(99); + }); + + it ('Should correctly determine the min and max data values when stacked mode is turned on', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, -5, 78, -100] + }, { + yAxisID: 'second scale', + data: [-1000, 1000], + }, { + yAxisID: scaleID, + data: [150, 0, 0, -100, -10, 9] + } + ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + config.stacked = true; // enable scale stacked mode + + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + expect(scale.min).toBe(-105); + expect(scale.max).toBe(160); + }); + + it ('Should ensure that the scale has a max and min that are not equal', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + expect(scale.min).toBe(-1); + expect(scale.max).toBe(1); + }); + + it ('Should generate tick marks', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, + ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + expect(scale.ticks).toBe(undefined); // not set + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Counts down because the lines are drawn top to bottom + expect(scale.ticks).toEqual([80, 70, 60, 50, 40, 30, 20, 10, 0]); + expect(scale.start).toBe(0); + expect(scale.end).toBe(80); + }); + + it ('Should generate tick marks in the correct order in reversed mode', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, + ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + config.reverse = true; + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + expect(scale.ticks).toBe(undefined); // not set + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Reverse mode makes this count up + expect(scale.ticks).toEqual([0, 10, 20, 30, 40, 50, 60, 70, 80]); + expect(scale.start).toBe(80); + expect(scale.end).toBe(0); + }); + + it ('Should generate tick marks using the user supplied options', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, + ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + config.override = { + steps: 10, + start: 0, + stepWidth: 10 + }; + + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + expect(scale.ticks).toEqual([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]); + expect(scale.start).toBe(0); + expect(scale.end).toBe(100); + }); + + it ('Should build labels using the default template', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, + ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Generate labels + scale.buildLabels(); + + expect(scale.labels).toEqual(['80', '70', '60', '50', '40', '30', '20', '10', '0']); + }); + + it ('Should build labels using the user supplied callback', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, + ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + config.labels.userCallback = function(value, index) { + return index.toString(); + }; + + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Generate labels + scale.buildLabels(); + + // Just the index + expect(scale.labels).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8']); + }); + + it ('Should get the correct pixel value for a point', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var verticalScale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + verticalScale.calculateRange(); + verticalScale.generateTicks(50, 100); + + // Fake out positioning of the scale service + verticalScale.left = 0; + verticalScale.top = 0; + verticalScale.right = 50; + verticalScale.bottom = 110; + verticalScale.paddingTop = 5; + verticalScale.paddingBottom = 5; + verticalScale.width = 50; + verticalScale.height = 110; + + expect(verticalScale.getPointPixelForValue(1, 0, 0)).toBe(5); // top + paddingTop + expect(verticalScale.getPointPixelForValue(-1, 0, 0)).toBe(105); // bottom - paddingBottom + expect(verticalScale.getPointPixelForValue(0, 0, 0)).toBe(55); // halfway + + var horizontalConfig = Chart.helpers.clone(config); + horizontalConfig.position = 'bottom'; + var horizontalScale = new Constructor({ + ctx: {}, + options: horizontalConfig, + data: mockData, + id: scaleID, + }); + + horizontalScale.calculateRange(); + horizontalScale.generateTicks(100, 50); + + // Fake out positioning of the scale service + horizontalScale.left = 0; + horizontalScale.top = 0; + horizontalScale.right = 110; + horizontalScale.bottom = 50; + horizontalScale.paddingLeft = 5; + horizontalScale.paddingRight = 5; + horizontalScale.width = 110; + horizontalScale.height = 50; + + // Range expands to [-2, 2] due to nicenum algorithm + expect(horizontalScale.getPointPixelForValue(2, 0, 0)).toBe(105); // right - paddingRight + expect(horizontalScale.getPointPixelForValue(-2, 0, 0)).toBe(5); // left + paddingLeft + expect(horizontalScale.getPointPixelForValue(0, 0, 0)).toBe(55); // halfway + }); +}); \ No newline at end of file From bade753fe3a476fdadc6f1f2196e001964846759 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 28 Aug 2015 15:12:35 -0600 Subject: [PATCH 261/424] Don't account for paddingLeft until after rotated --- src/scales/scale.category.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scales/scale.category.js b/src/scales/scale.category.js index 7912f8dcb06..38a69c92e9e 100644 --- a/src/scales/scale.category.js +++ b/src/scales/scale.category.js @@ -126,7 +126,7 @@ var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; //Max label rotation can be set or default to 90 - also act as a loop counter - while (this.labelWidth > (datasetWidth + this.paddingLeft) && this.labelRotation <= this.options.labels.maxRotation) { + while (this.labelWidth > datasetWidth && this.labelRotation <= this.options.labels.maxRotation) { cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); From 9c1a0cbc16b597276443137f932d87d4de0bfe86 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 28 Aug 2015 18:52:46 -0400 Subject: [PATCH 262/424] This should run the unit tests from the CI system --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 560c6b49641..46c1f2b88c5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -133,7 +133,7 @@ gulp.task('watch', function() { gulp.watch('./src/**', ['build', 'unittest']); }); -gulp.task('test', ['jshint', 'valid']); +gulp.task('test', ['jshint', 'valid', 'unittest']); gulp.task('size', ['library-size', 'module-sizes']); From edf95175a7c644602f1d663294f15085b0e19c81 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 28 Aug 2015 16:58:23 -0600 Subject: [PATCH 263/424] Organize Gulpfile, Integrate unit tests with Travis --- gulpfile.js | 112 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 41 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 560c6b49641..ba699af6b41 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -24,19 +24,39 @@ var testDir = './test/'; */ var srcFiles = [ - './src/core/core.js', - './src/core/core.helpers.js', - './src/core/core.chart.js', - './src/core/core.element.js', - './src/core/**', - './src/controllers/**', - './src/scales/**', - './src/elements/**', - './src/charts/**', - './node_modules/color/dist/color.min.js' - ]; - -gulp.task('build', function() { + './src/core/core.js', + './src/core/core.helpers.js', + './src/core/core.chart.js', + './src/core/core.element.js', + './src/core/**', + './src/controllers/**', + './src/scales/**', + './src/elements/**', + './src/charts/**', + './node_modules/color/dist/color.min.js' +]; + + +gulp.task('build', buildTask); +gulp.task('watch', watchTask); +gulp.task('bump', bumpTask); +gulp.task('release', ['build'], releaseTask); +gulp.task('jshint', jshintTask); +gulp.task('test', ['jshint', 'validHTML', 'unittest']); +gulp.task('size', ['library-size', 'module-sizes']); +gulp.task('server', serverTask); +gulp.task('validHTML', validHTMLTask); +gulp.task('unittest', unittestTask); +gulp.task('unittestWatch', unittestWatchTask); +gulp.task('library-size', librarySizeTask); +gulp.task('module-sizes', moduleSizesTask); +gulp.task('_open', _openTask); +gulp.task('dev', ['server', 'default']); + +gulp.task('default', ['build', 'watch']); + + +function buildTask() { var isCustom = !!(util.env.types), outputDir = (isCustom) ? 'custom' : '.'; @@ -51,15 +71,14 @@ gulp.task('build', function() { .pipe(concat('Chart.min.js')) .pipe(gulp.dest(outputDir)); -}); +} /* * Usage : gulp bump * Prompts: Version increment to bump * Output: - New version number written into package.json & bower.json */ - -gulp.task('bump', function(complete) { +function bumpTask(complete) { util.log('Current version:', util.colors.cyan(package.version)); var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType) { return versionType + ' (v' + semver.inc(package.version, versionType) + ')'; @@ -83,24 +102,39 @@ gulp.task('bump', function(complete) { complete(); }); -}); +} + -gulp.task('release', ['build'], function() { +function releaseTask() { exec('git tag -a v' + package.version); -}); +} + -gulp.task('jshint', function() { +function jshintTask() { return gulp.src(srcDir + '*.js') .pipe(jshint()) .pipe(jshint.reporter('default')); -}); +} -gulp.task('valid', function() { + +function validHTMLTask() { return gulp.src('samples/*.html') .pipe(htmlv()); -}); +} + + +function unittestTask() { + var files = srcFiles.slice(); + files.push(testDir + '*.js'); + + return gulp.src(files) + .pipe(karma({ + configFile: 'karma.conf.js', + action: 'run' + })); +} -gulp.task('unittest', function() { +function unittestWatchTask() { var files = srcFiles.slice(); files.push(testDir + '*.js'); @@ -109,16 +143,16 @@ gulp.task('unittest', function() { configFile: 'karma.conf.js', action: 'watch' })); -}); +} -gulp.task('library-size', function() { +function librarySizeTask() { return gulp.src('Chart.min.js') .pipe(size({ gzip: true })); -}); +} -gulp.task('module-sizes', function() { +function moduleSizesTask() { return gulp.src(srcDir + '*.js') .pipe(uglify({ preserveComments: 'some' @@ -127,28 +161,24 @@ gulp.task('module-sizes', function() { showFiles: true, gzip: true })); -}); +} -gulp.task('watch', function() { - gulp.watch('./src/**', ['build', 'unittest']); -}); -gulp.task('test', ['jshint', 'valid']); +function watchTask() { + gulp.watch('./src/**', ['build', 'unittest', 'unittestWatch']); +} -gulp.task('size', ['library-size', 'module-sizes']); -gulp.task('default', ['build', 'watch']); -gulp.task('server', function() { +function serverTask() { connect.server({ port: 8000 }); -}); +} // Convenience task for opening the project straight from the command line -gulp.task('_open', function() { + +function _openTask() { exec('open http://localhost:8000'); exec('subl .'); -}); - -gulp.task('dev', ['server', 'default']); +} From 92f1c65c1c2651c23f415d70b10e5210b2fca78c Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 28 Aug 2015 19:02:37 -0400 Subject: [PATCH 264/424] Install coverage metrics. Use `gulp coverage` to generate coverage reports --- .gitignore | 2 ++ gulpfile.js | 11 +++++++++++ karma.coverage.conf.js | 18 ++++++++++++++++++ package.json | 1 + test/core.helpers.tests.js | 0 5 files changed, 32 insertions(+) create mode 100644 karma.coverage.conf.js create mode 100644 test/core.helpers.tests.js diff --git a/.gitignore b/.gitignore index 5016e5def4b..5b80f24cbce 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ custom/* docs/index.md bower_components/ + +coverage/* diff --git a/gulpfile.js b/gulpfile.js index 46c1f2b88c5..0a5b3d3b9ec 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -111,6 +111,17 @@ gulp.task('unittest', function() { })); }); +gulp.task('coverage', function() { + var files = srcFiles.slice(); + files.push(testDir + '*.js'); + + return gulp.src(files) + .pipe(karma({ + configFile: 'karma.coverage.conf.js', + action: 'run' + })); +}); + gulp.task('library-size', function() { return gulp.src('Chart.min.js') .pipe(size({ diff --git a/karma.coverage.conf.js b/karma.coverage.conf.js new file mode 100644 index 00000000000..cc047aa4d03 --- /dev/null +++ b/karma.coverage.conf.js @@ -0,0 +1,18 @@ +module.exports = function(config) { + config.set({ + browsers: ['Chrome', 'Firefox'], + + coverageReporter: { + type: 'html', + dir: 'coverage/' + }, + + frameworks: ['jasmine'], + + preprocessors: { + 'src/**/*.js': ['coverage'] + }, + + reporters: ['progress', 'coverage'], + }); +}; \ No newline at end of file diff --git a/package.json b/package.json index 27ed2888b1a..066d6536941 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "jquery": "^2.1.4", "karma": "^0.12.37", "karma-chrome-launcher": "^0.2.0", + "karma-coverage": "^0.5.1", "karma-firefox-launcher": "^0.1.6", "karma-jasmine": "^0.3.6", "onecolor": "^2.5.0", diff --git a/test/core.helpers.tests.js b/test/core.helpers.tests.js new file mode 100644 index 00000000000..e69de29bb2d From 371bc8913f5abac58517b42a6c86a6400d09146e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 28 Aug 2015 22:32:56 -0400 Subject: [PATCH 265/424] Start writing tests for core.helpers. Fix a number of small bugs found during testing --- src/core/core.helpers.js | 135 ++----------- test/core.helpers.tests.js | 385 +++++++++++++++++++++++++++++++++++++ 2 files changed, 402 insertions(+), 118 deletions(-) diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 2fbb644a908..46ad752d882 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -57,12 +57,6 @@ }); return base; }, - merge = helpers.merge = function(base, master) { - //Merge properties in left object over to a shallow clone of object right. - var args = Array.prototype.slice.call(arguments, 0); - args.unshift({}); - return extend.apply(null, args); - }, // Need a special merge function to chart configs since they are now grouped configMerge = helpers.configMerge = function(_base) { var base = clone(_base); @@ -84,7 +78,13 @@ helpers.each(value, function(valueObj, index) { if (index < baseArray.length) { - baseArray[index] = helpers.configMerge(baseArray[index], valueObj); + if (typeof baseArray[index] == 'object' && baseArray[index] !== null && typeof valueObj == 'object' && valueObj !== null) { + // Two objects are coming together. Do a merge of them. + baseArray[index] = helpers.configMerge(baseArray[index], valueObj); + } else { + // Just overwrite in this case since there is nothing to merge + baseArray[index] = valueObj; + } } else { baseArray.push(valueObj); // nothing to merge } @@ -143,12 +143,12 @@ return base; }, getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { - if (!value) { + if (value === undefined || value === null) { return defaultValue; } - if (helpers.isArray(value) && index < value.length) { - return value[index]; + if (helpers.isArray(value)) { + return index < value.length ? value[index] : defaultValue; } return value; @@ -176,7 +176,7 @@ }, findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { // Default to start of the array - if (!startIndex) { + if (startIndex === undefined || startIndex === null) { startIndex = -1; } for (var i = startIndex + 1; i < arrayToSearch.length; i++) { @@ -188,7 +188,7 @@ }, findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { // Default to end of the array - if (!startIndex) { + if (startIndex === undefined || startIndex === null) { startIndex = arrayToSearch.length; } for (var i = startIndex - 1; i >= 0; i--) { @@ -259,18 +259,6 @@ return Math.log(x) / Math.LN10; } }, - cap = helpers.cap = function(valueToCap, maxValue, minValue) { - if (isNumber(maxValue)) { - if (valueToCap > maxValue) { - return maxValue; - } - } else if (isNumber(minValue)) { - if (valueToCap < minValue) { - return minValue; - } - } - return valueToCap; - }, getDecimalPlaces = helpers.getDecimalPlaces = function(num) { if (num % 1 !== 0 && isNumber(num)) { var s = num.toString(); @@ -335,94 +323,16 @@ }, nextItem = helpers.nextItem = function(collection, index, loop) { if (loop) { - return collection[index + 1] || collection[0]; + return index >= collection.length - 1 ? collection[0] : collection[index + 1]; } - return collection[index + 1] || collection[collection.length - 1]; + + return index >= collection.length - 1 ? collection[collection.length - 1] : collection[index + 1]; }, previousItem = helpers.previousItem = function(collection, index, loop) { if (loop) { - return collection[index - 1] || collection[collection.length - 1]; - } - return collection[index - 1] || collection[0]; - }, - calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { - return Math.floor(Math.log(val) / Math.LN10); - }, - calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { - - //Set a minimum step of two - a point at the top of the graph, and a point at the base - var minSteps = 2, - maxSteps = Math.floor(drawingSize / (textSize * 1.5)), - skipFitting = (minSteps >= maxSteps); - - var maxValue = max(valuesArray), - minValue = min(valuesArray); - - // We need some degree of seperation here to calculate the scales if all the values are the same - // Adding/minusing 0.5 will give us a range of 1. - if (maxValue === minValue) { - maxValue += 0.5; - // So we don't end up with a graph with a negative start value if we've said always start from zero - if (minValue >= 0.5 && !startFromZero) { - minValue -= 0.5; - } else { - // Make up a whole number above the values - maxValue += 0.5; - } - } - - var valueRange = Math.abs(maxValue - minValue), - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphRange = graphMax - graphMin, - stepValue = Math.pow(10, rangeOrderOfMagnitude), - numberOfSteps = Math.round(graphRange / stepValue); - - //If we have more space on the graph we'll use it to give more definition to the data - while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { - if (numberOfSteps > maxSteps) { - stepValue *= 2; - numberOfSteps = Math.round(graphRange / stepValue); - // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. - if (numberOfSteps % 1 !== 0) { - skipFitting = true; - } - } - //We can fit in double the amount of scale points on the scale - else { - //If user has declared ints only, and the step value isn't a decimal - if (integersOnly && rangeOrderOfMagnitude >= 0) { - //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float - if (stepValue / 2 % 1 === 0) { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - //If it would make it a float break out of the loop - else { - break; - } - } - //If the scale doesn't have to be an int, make the scale more granular anyway. - else { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - - } + return index <= 0 ? collection[collection.length - 1] : collection[index - 1]; } - - if (skipFitting) { - numberOfSteps = minSteps; - stepValue = graphRange / numberOfSteps; - } - return { - steps: numberOfSteps, - stepValue: stepValue, - min: graphMin, - max: graphMin + (numberOfSteps * stepValue) - }; - + return index <= 0 ? collection[0] : collection[index - 1]; }, // Implementation of the nice number algorithm used in determining where axis labels will go niceNum = helpers.niceNum = function(range, round) { @@ -505,17 +415,6 @@ return tmpl(templateString, valuesObject); }, /* jshint ignore:end */ - generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { - var labelsArray = new Array(numberOfSteps); - if (templateString) { - each(labelsArray, function(val, index) { - labelsArray[index] = template(templateString, { - value: (graphMin + (stepValue * (index + 1))) - }); - }); - } - return labelsArray; - }, //--Animation methods //Easing functions adapted from Robert Penner's easing equations //http://www.robertpenner.com/easing/ diff --git a/test/core.helpers.tests.js b/test/core.helpers.tests.js index e69de29bb2d..730222b5b57 100644 --- a/test/core.helpers.tests.js +++ b/test/core.helpers.tests.js @@ -0,0 +1,385 @@ +describe('Core helper tests', function() { + + var helpers; + + beforeAll(function() { + helpers = window.Chart.helpers; + }); + + it('Should iterate over an array and pass the extra data to that function', function() { + var testData = [0, 9, "abc"]; + var scope = {}; // fake out the scope and ensure that 'this' is the correct thing + + helpers.each(testData, function(item, index) { + expect(item).not.toBe(undefined); + expect(index).not.toBe(undefined); + + expect(testData[index]).toBe(item); + expect(this).toBe(scope); + }, scope); + + // Reverse iteration + var iterated = []; + helpers.each(testData, function(item, index) { + expect(item).not.toBe(undefined); + expect(index).not.toBe(undefined); + + expect(testData[index]).toBe(item); + expect(this).toBe(scope); + + iterated.push(item); + }, scope, true); + + expect(iterated.slice().reverse()).toEqual(testData); + }); + + it('Should iterate over properties in an object', function() { + var testData = { + myProp1: 'abc', + myProp2: 276, + myProp3: ['a', 'b'] + }; + + helpers.each(testData, function(value, key) { + if (key === 'myProp1') { + expect(value).toBe('abc'); + } else if (key === 'myProp2') { + expect(value).toBe(276); + } else if (key === 'myProp3') { + expect(value).toEqual(['a', 'b']); + } else { + expect(false).toBe(true); + } + }); + }); + + it('should not error when iterating over a null object', function() { + expect(function() { + helpers.each(undefined); + }).not.toThrow(); + }); + + it('Should clone an object', function() { + var testData = { + myProp1: 'abc', + myProp2: ['a', 'b'], + myProp3: { + myProp4: 5, + myProp5: [1, 2] + } + }; + + var clone = helpers.clone(testData); + expect(clone).toEqual(testData); + expect(clone).not.toBe(testData); + + expect(clone.myProp2).not.toBe(testData.myProp2); + expect(clone.myProp3).not.toBe(testData.myProp3); + expect(clone.myProp3.myProp5).not.toBe(testData.myProp3.myProp5); + }); + + it('should extend an object', function() { + var original = { + myProp1: 'abc', + myProp2: 56 + }; + + var extension = { + myProp3: [2, 5, 6], + myProp2: 0 + }; + + helpers.extend(original, extension); + + expect(original).toEqual({ + myProp1: 'abc', + myProp2: 0, + myProp3: [2, 5, 6], + }); + }); + + it('Should merge a normal config without scales', function() { + var baseConfig = { + valueProp: 5, + arrayProp: [1, 2, 3, 4, 5, 6], + objectProp: { + prop1: 'abc', + prop2: 56 + } + }; + + var toMerge = { + valueProp2: null, + arrayProp: ['a', 'c'], + objectProp: { + prop1: 'c', + prop3: 'prop3' + } + }; + + var merged = helpers.configMerge(baseConfig, toMerge); + expect(merged).toEqual({ + valueProp: 5, + valueProp2: null, + arrayProp: ['a', 'c', 3, 4, 5, 6], + objectProp: { + prop1: 'c', + prop2: 56, + prop3: 'prop3' + } + }); + }); + + it('should merge arrays containing objects', function() { + var baseConfig = { + arrayProp: [{ + prop1: 'abc', + prop2: 56 + }], + }; + + var toMerge = { + arrayProp: [{ + prop1: 'myProp1', + prop3: 'prop3' + }, 2, { + prop1: 'myProp1' + }], + }; + + var merged = helpers.configMerge(baseConfig, toMerge); + expect(merged).toEqual({ + arrayProp: [{ + prop1: 'myProp1', + prop2: 56, + prop3: 'prop3' + }, + 2, { + prop1: 'myProp1' + }], + }); + }); + + it ('Should merge scale configs', function() { + var baseConfig = { + scales: { + prop1: { + abc: 123, + def: '456' + }, + prop2: 777, + yAxes: [{ + type: 'linear', + }, { + type: 'log' + }] + } + }; + + var toMerge = { + scales: { + prop1: { + def: 'bbb', + ghi: 78 + }, + prop2: null, + yAxes: [{ + type: 'linear', + axisProp: 456 + }, { + // pulls in linear default config since axis type changes + type: 'linear', + position: 'right' + }, { + // Pulls in linear default config since axis not in base + type: 'linear' + }] + } + }; + + var merged = helpers.configMerge(baseConfig, toMerge); + expect(merged).toEqual({ + scales: { + prop1: { + abc: 123, + def: 'bbb', + ghi: 78 + }, + prop2: null, + yAxes: [{ + type: 'linear', + axisProp: 456 + }, { + type: 'linear', + display: true, + position: "right", + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + reverse: false, + beginAtZero: false, + override: null, + labels: { + show: true, + mirror: false, + padding: 10, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue" + } + }, { + type: 'linear', + display: true, + position: "left", + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + reverse: false, + beginAtZero: false, + override: null, + labels: { + show: true, + mirror: false, + padding: 10, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue" + } + }] + } + }); + }); + + it ('should get value or default', function() { + expect(helpers.getValueAtIndexOrDefault(98, 0, 56)).toBe(98); + expect(helpers.getValueAtIndexOrDefault(0, 0, 56)).toBe(0); + expect(helpers.getValueAtIndexOrDefault(undefined, undefined, 56)).toBe(56); + expect(helpers.getValueAtIndexOrDefault([1, 2, 3], 1, 100)).toBe(2); + expect(helpers.getValueAtIndexOrDefault([1, 2, 3], 3, 100)).toBe(100); + }); + + it ('should filter an array', function() { + var data = [-10, 0, 6, 0, 7]; + var callback = function(item) { return item > 2}; + expect(helpers.where(data, callback)).toEqual([6, 7]); + expect(helpers.findNextWhere(data, callback)).toEqual(6); + expect(helpers.findNextWhere(data, callback, 2)).toBe(7); + expect(helpers.findNextWhere(data, callback, 4)).toBe(undefined); + expect(helpers.findPreviousWhere(data, callback)).toBe(7); + expect(helpers.findPreviousWhere(data, callback, 3)).toBe(6); + expect(helpers.findPreviousWhere(data, callback, 0)).toBe(undefined); + }); + + it ('Should get the correct sign', function() { + expect(helpers.sign(0)).toBe(0); + expect(helpers.sign(10)).toBe(1); + expect(helpers.sign(-5)).toBe(-1); + }); + + it ('should do a log10 operation', function() { + expect(helpers.log10(0)).toBe(-Infinity); + expect(helpers.log10(1)).toBe(0); + expect(helpers.log10(1000)).toBe(3); + }); + + it ('Should generate ids', function() { + expect(helpers.uid()).toBe('chart-0'); + expect(helpers.uid()).toBe('chart-1'); + expect(helpers.uid()).toBe('chart-2'); + expect(helpers.uid()).toBe('chart-3'); + }); + + it ('should detect a number', function() { + expect(helpers.isNumber(123)).toBe(true); + expect(helpers.isNumber('123')).toBe(true); + expect(helpers.isNumber(null)).toBe(false); + expect(helpers.isNumber(NaN)).toBe(false); + expect(helpers.isNumber(undefined)).toBe(false); + expect(helpers.isNumber('cbc')).toBe(false); + }); + + it ('should convert between radians and degrees', function() { + expect(helpers.toRadians(180)).toBe(Math.PI); + expect(helpers.toRadians(90)).toBe(0.5 * Math.PI); + expect(helpers.toDegrees(Math.PI)).toBe(180); + expect(helpers.toDegrees(Math.PI * 3 /2)).toBe(270); + }); + + it ('should get an angle from a point', function() { + var center = { + x: 0, + y: 0 + }; + + expect(helpers.getAngleFromPoint(center, {x: 0, y: 10})).toEqual({ + angle: Math.PI / 2, + distance: 10, + }); + + expect(helpers.getAngleFromPoint(center, {x: Math.sqrt(2), y: Math.sqrt(2)})).toEqual({ + angle: Math.PI / 4, + distance: 2 + }); + + expect(helpers.getAngleFromPoint(center, {x: -1.0 * Math.sqrt(2), y: -1.0 * Math.sqrt(2)})).toEqual({ + angle: Math.PI * 1.25, + distance: 2 + }); + }); + + it ('should spline curves', function() { + expect(helpers.splineCurve({x: 0, y: 0}, {x: 1, y: 1}, { x: 2, y: 0}, 0)).toEqual({ + previous: { + x: 1, + y: 1, + }, + next: { + x: 1, + y: 1, + } + }); + + expect(helpers.splineCurve({x: 0, y: 0}, {x: 1, y: 1}, { x: 2, y: 0}, 1)).toEqual({ + previous: { + x: 0, + y: 1, + }, + next: { + x: 2, + y: 1, + } + }); + }); + + it ('should get the next or previous item in an array', function() { + var testData = [0, 1, 2]; + + expect(helpers.nextItem(testData, 0, false)).toEqual(1); + expect(helpers.nextItem(testData, 2, false)).toEqual(2); + expect(helpers.nextItem(testData, 2, true)).toEqual(0); + expect(helpers.nextItem(testData, 1, true)).toEqual(2); + expect(helpers.nextItem(testData, -1, false)).toEqual(0); + + expect(helpers.previousItem(testData, 0, false)).toEqual(0); + expect(helpers.previousItem(testData, 0, true)).toEqual(2); + expect(helpers.previousItem(testData, 2, false)).toEqual(1); + expect(helpers.previousItem(testData, 1, true)).toEqual(0); + + }); +}); \ No newline at end of file From c09414cc40fc1cc93edc94c42e7382cff0214c89 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 28 Aug 2015 23:09:58 -0400 Subject: [PATCH 266/424] First set of tests for point. Started on a mockContext object for testing. Still need to handle property setting better (fillStyle, strokeStyle, etc) --- src/elements/element.point.js | 9 +- test/element.point.tests.js | 180 ++++++++++++++++++++++++++++++++++ test/mockContext.js | 51 ++++++++++ 3 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 test/element.point.tests.js create mode 100644 test/mockContext.js diff --git a/src/elements/element.point.js b/src/elements/element.point.js index 1a4f709cb44..94565e3ca16 100644 --- a/src/elements/element.point.js +++ b/src/elements/element.point.js @@ -32,8 +32,13 @@ Chart.elements.Point = Chart.Element.extend({ inRange: function(mouseX, mouseY) { var vm = this._view; - var hoverRange = vm.hitRadius + vm.radius; - return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + + if (vm) { + var hoverRange = vm.hitRadius + vm.radius; + return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + } else { + return false; + } }, inLabelRange: function(mouseX) { var vm = this._view; diff --git a/test/element.point.tests.js b/test/element.point.tests.js new file mode 100644 index 00000000000..e20964422e7 --- /dev/null +++ b/test/element.point.tests.js @@ -0,0 +1,180 @@ +// Test the point element + +describe('Point element tests', function() { + it ('Should be constructed', function() { + var point = new Chart.elements.Point({ + _datasetIndex: 2, + _index: 1 + }); + + expect(point).not.toBe(undefined); + expect(point._datasetIndex).toBe(2); + expect(point._index).toBe(1); + }); + + it ('Should correctly identify as in range', function() { + var point = new Chart.elements.Point({ + _datasetIndex: 2, + _index: 1 + }); + + // Safely handles if these are called before the viewmodel is instantiated + expect(point.inRange(5)).toBe(false); + expect(point.inLabelRange(5)).toBe(false); + + // Attach a view object as if we were the controller + point._view = { + radius: 2, + hitRadius: 3, + x: 10, + y: 15 + }; + + expect(point.inRange(10, 15)).toBe(true); + expect(point.inRange(10, 10)).toBe(false); + expect(point.inRange(10, 5)).toBe(false); + expect(point.inRange(5, 5)).toBe(false); + + expect(point.inLabelRange(5)).toBe(false); + expect(point.inLabelRange(7)).toBe(true); + expect(point.inLabelRange(10)).toBe(true); + expect(point.inLabelRange(12)).toBe(true); + expect(point.inLabelRange(15)).toBe(false); + expect(point.inLabelRange(20)).toBe(false); + }); + + it ('should get the correct tooltip position', function() { + var point = new Chart.elements.Point({ + _datasetIndex: 2, + _index: 1 + }); + + // Attach a view object as if we were the controller + point._view = { + radius: 2, + borderWidth: 6, + x: 10, + y: 15 + }; + + expect(point.tooltipPosition()).toEqual({ + x: 10, + y: 15, + padding: 8 + }); + }); + + it ('should draw correctly', function() { + var mockContext = window.createMockContext(); + var point = new Chart.elements.Point({ + _datasetIndex: 2, + _index: 1, + _chart: { + ctx: mockContext, + } + }); + + // Attach a view object as if we were the controller + point._view = { + radius: 2, + hitRadius: 3, + borderColor: 'rgba(1, 2, 3, 1)', + borderWidth: 6, + backgroundColor: 'rgba(0, 255, 0)', + x: 10, + y: 15, + ctx: mockContext + }; + + point.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'beginPath', + args: [] + }, { + name: 'arc', + args: [10, 15, 2, 0, 2 * Math.PI] + }, { + name: 'closePath', + args: [], + }, { + name: 'fill', + args: [], + }, { + name: 'stroke', + args: [] + }]); + + expect(mockContext.lineWidth).toBe(6); + expect(mockContext.strokeStyle).toBe('rgba(1, 2, 3, 1)'); + expect(mockContext.fillStyle).toBe('rgba(0, 255, 0)'); + }); + + it ('should draw correctly with default settings if necessary', function() { + var mockContext = window.createMockContext(); + var point = new Chart.elements.Point({ + _datasetIndex: 2, + _index: 1, + _chart: { + ctx: mockContext, + } + }); + + // Attach a view object as if we were the controller + point._view = { + radius: 2, + hitRadius: 3, + x: 10, + y: 15, + ctx: mockContext + }; + + point.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'beginPath', + args: [] + }, { + name: 'arc', + args: [10, 15, 2, 0, 2 * Math.PI] + }, { + name: 'closePath', + args: [], + }, { + name: 'fill', + args: [], + }, { + name: 'stroke', + args: [] + }]); + + expect(mockContext.lineWidth).toBe(1); + expect(mockContext.strokeStyle).toBe('rgba(0,0,0,0.1)'); + expect(mockContext.fillStyle).toBe('rgba(0,0,0,0.1)'); + }); + + it ('should not draw if skipped', function() { + var mockContext = window.createMockContext(); + var point = new Chart.elements.Point({ + _datasetIndex: 2, + _index: 1, + _chart: { + ctx: mockContext, + } + }); + + // Attach a view object as if we were the controller + point._view = { + radius: 2, + hitRadius: 3, + x: 10, + y: 15, + ctx: mockContext, + skip: true + }; + + point.draw(); + + expect(mockContext.getCalls()).toEqual([]); + }); +}); \ No newline at end of file diff --git a/test/mockContext.js b/test/mockContext.js new file mode 100644 index 00000000000..ee3ce7ea47f --- /dev/null +++ b/test/mockContext.js @@ -0,0 +1,51 @@ +(function() { + // Code from http://stackoverflow.com/questions/4406864/html-canvas-unit-testing + var Context = function() { + this._calls = []; // names/args of recorded calls + this._initMethods(); + }; + + Context.prototype._initMethods = function() { + // define methods to test here + // no way to introspect so we have to do some extra work :( + var methods = { + arc: function() {}, + beginPath: function() {}, + closePath: function() {}, + fill: function() {}, + lineTo: function(x, y) {}, + moveTo: function(x, y) {}, + stroke: function() {} + }; + + // attach methods to the class itself + var scope = this; + var addMethod = function(name, method) { + scope[methodName] = function() { + scope.record(name, arguments); + method.apply(scope, arguments); + }; + } + + for (var methodName in methods) { + var method = methods[methodName]; + + addMethod(methodName, method); + } + }; + + Context.prototype.record = function(methodName, args) { + this._calls.push({ + name: methodName, + args: Array.prototype.slice.call(args) + }); + }, + + Context.prototype.getCalls = function() { + return this._calls; + } + + window.createMockContext = function() { + return new Context(); + }; +})(); \ No newline at end of file From f9a9e6bfb74f33c03def269cdb086bb44f64d8e4 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 28 Aug 2015 23:20:01 -0400 Subject: [PATCH 267/424] Do mock context properties better --- test/element.point.tests.js | 26 ++++++++++++++++++-------- test/mockContext.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/test/element.point.tests.js b/test/element.point.tests.js index e20964422e7..8a4052ca740 100644 --- a/test/element.point.tests.js +++ b/test/element.point.tests.js @@ -97,6 +97,15 @@ describe('Point element tests', function() { }, { name: 'closePath', args: [], + }, { + name: 'setStrokeStyle', + args: ['rgba(1, 2, 3, 1)'] + }, { + name: 'setLineWidth', + args: [6] + }, { + name: 'setFillStyle', + args: ['rgba(0, 255, 0)'] }, { name: 'fill', args: [], @@ -104,10 +113,6 @@ describe('Point element tests', function() { name: 'stroke', args: [] }]); - - expect(mockContext.lineWidth).toBe(6); - expect(mockContext.strokeStyle).toBe('rgba(1, 2, 3, 1)'); - expect(mockContext.fillStyle).toBe('rgba(0, 255, 0)'); }); it ('should draw correctly with default settings if necessary', function() { @@ -140,6 +145,15 @@ describe('Point element tests', function() { }, { name: 'closePath', args: [], + }, { + name: 'setStrokeStyle', + args: ['rgba(0,0,0,0.1)'] + }, { + name: 'setLineWidth', + args: [1] + }, { + name: 'setFillStyle', + args: ['rgba(0,0,0,0.1)'] }, { name: 'fill', args: [], @@ -147,10 +161,6 @@ describe('Point element tests', function() { name: 'stroke', args: [] }]); - - expect(mockContext.lineWidth).toBe(1); - expect(mockContext.strokeStyle).toBe('rgba(0,0,0,0.1)'); - expect(mockContext.fillStyle).toBe('rgba(0,0,0,0.1)'); }); it ('should not draw if skipped', function() { diff --git a/test/mockContext.js b/test/mockContext.js index ee3ce7ea47f..111aabbdf8f 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -3,6 +3,35 @@ var Context = function() { this._calls = []; // names/args of recorded calls this._initMethods(); + + this._fillStyle = null; + this._lineWidth = null; + this._strokeStyle = null; + + // Define properties here so that we can record each time they are set + Object.defineProperties(this, { + "fillStyle": { + 'get': function() { return this._fillStyle; }, + 'set': function(style) { + this._fillStyle = style; + this.record('setFillStyle', [style]); + } + }, + 'lineWidth': { + 'get': function() { return this._lineWidth; }, + 'set': function (width) { + this._lineWidth = width; + this.record('setLineWidth', [width]); + } + }, + 'strokeStyle': { + 'get': function() { return this._strokeStyle; }, + 'set': function(style) { + this._strokeStyle = style; + this.record('setStrokeStyle', [style]); + } + }, + }); }; Context.prototype._initMethods = function() { From 26684b6371cca9db250edc9e7c0a056fb8081d4d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 29 Aug 2015 08:53:42 -0400 Subject: [PATCH 268/424] Rectangle element tests --- src/elements/element.rectangle.js | 23 ++- test/element.rectangle.tests.js | 246 ++++++++++++++++++++++++++++++ 2 files changed, 263 insertions(+), 6 deletions(-) create mode 100644 test/element.rectangle.tests.js diff --git a/src/elements/element.rectangle.js b/src/elements/element.rectangle.js index 10682b1c07d..3d9539eb9f2 100644 --- a/src/elements/element.rectangle.js +++ b/src/elements/element.rectangle.js @@ -55,15 +55,26 @@ }, inRange: function(mouseX, mouseY) { var vm = this._view; - if (vm.y < vm.base) { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); - } else { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); - } + var inRange = false; + + if (vm) { + if (vm.y < vm.base) { + inRange = (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); + } else { + inRange = (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); + } + } + + return inRange; }, inLabelRange: function(mouseX) { var vm = this._view; - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + + if (vm) { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + } else { + return false; + } }, tooltipPosition: function() { var vm = this._view; diff --git a/test/element.rectangle.tests.js b/test/element.rectangle.tests.js new file mode 100644 index 00000000000..f8bd51efd55 --- /dev/null +++ b/test/element.rectangle.tests.js @@ -0,0 +1,246 @@ +// Test the rectangle element + +describe('Rectangle element tests', function() { + it ('Should be constructed', function() { + var rectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1 + }); + + expect(rectangle).not.toBe(undefined); + expect(rectangle._datasetIndex).toBe(2); + expect(rectangle._index).toBe(1); + }); + + it ('Should correctly identify as in range', function() { + var rectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1 + }); + + // Safely handles if these are called before the viewmodel is instantiated + expect(rectangle.inRange(5)).toBe(false); + expect(rectangle.inLabelRange(5)).toBe(false); + + // Attach a view object as if we were the controller + rectangle._view = { + base: 0, + width: 4, + x: 10, + y: 15 + }; + + expect(rectangle.inRange(10, 15)).toBe(true); + expect(rectangle.inRange(10, 10)).toBe(true); + expect(rectangle.inRange(10, 16)).toBe(false); + expect(rectangle.inRange(5, 5)).toBe(false); + + expect(rectangle.inLabelRange(5)).toBe(false); + expect(rectangle.inLabelRange(7)).toBe(false); + expect(rectangle.inLabelRange(10)).toBe(true); + expect(rectangle.inLabelRange(12)).toBe(true); + expect(rectangle.inLabelRange(15)).toBe(false); + expect(rectangle.inLabelRange(20)).toBe(false); + + // Test when the y is below the base (negative bar) + var negativeRectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1 + }); + + // Attach a view object as if we were the controller + negativeRectangle._view = { + base: 0, + width: 4, + x: 10, + y: -15 + }; + + expect(negativeRectangle.inRange(10, -16)).toBe(false); + expect(negativeRectangle.inRange(10, 1)).toBe(false); + expect(negativeRectangle.inRange(10, -5)).toBe(true); + }); + + it ('should get the correct height', function() { + var rectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1 + }); + + // Attach a view object as if we were the controller + rectangle._view = { + base: 0, + width: 4, + x: 10, + y: 15 + }; + + expect(rectangle.height()).toBe(-15); + + // Test when the y is below the base (negative bar) + var negativeRectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1 + }); + + // Attach a view object as if we were the controller + negativeRectangle._view = { + base: -10, + width: 4, + x: 10, + y: -15 + }; + expect(negativeRectangle.height()).toBe(5); + }); + + it ('should get the correct tooltip position', function() { + var rectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1 + }); + + // Attach a view object as if we were the controller + rectangle._view = { + base: 0, + width: 4, + x: 10, + y: 15 + }; + + expect(rectangle.tooltipPosition()).toEqual({ + x: 10, + y: 0, + }); + + // Test when the y is below the base (negative bar) + var negativeRectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1 + }); + + // Attach a view object as if we were the controller + negativeRectangle._view = { + base: -10, + width: 4, + x: 10, + y: -15 + }; + + expect(negativeRectangle.tooltipPosition()).toEqual({ + x: 10, + y: -15, + }); + }); + + it ('should draw correctly', function() { + var mockContext = window.createMockContext(); + var rectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1, + _chart: { + ctx: mockContext, + } + }); + + // Attach a view object as if we were the controller + rectangle._view = { + backgroundColor: 'rgb(255, 0, 0)', + base: 0, + borderColor: 'rgb(0, 0, 255)', + borderWidth: 1, + ctx: mockContext, + width: 4, + x: 10, + y: 15, + }; + + rectangle.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'beginPath', + args: [], + }, { + name: 'setFillStyle', + args: ['rgb(255, 0, 0)'] + }, { + name: 'setStrokeStyle', + args: ['rgb(0, 0, 255)'], + }, { + name: 'setLineWidth', + args: [1] + }, { + name: 'moveTo', + args: [8.5, 0] + }, { + name: 'lineTo', + args: [8.5, 15.5] + }, { + name: 'lineTo', + args: [11.5, 15.5] + }, { + name: 'lineTo', + args: [11.5, 0] + }, { + name: 'fill', + args: [], + }, { + name: 'stroke', + args: [] + }]); + }); + + it ('should draw correctly with no stroke', function() { + var mockContext = window.createMockContext(); + var rectangle = new Chart.elements.Rectangle({ + _datasetIndex: 2, + _index: 1, + _chart: { + ctx: mockContext, + } + }); + + // Attach a view object as if we were the controller + rectangle._view = { + backgroundColor: 'rgb(255, 0, 0)', + base: 0, + borderColor: 'rgb(0, 0, 255)', + ctx: mockContext, + width: 4, + x: 10, + y: 15, + }; + + rectangle.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'beginPath', + args: [], + }, { + name: 'setFillStyle', + args: ['rgb(255, 0, 0)'] + }, { + name: 'setStrokeStyle', + args: ['rgb(0, 0, 255)'], + }, { + name: 'setLineWidth', + args: [undefined] + }, { + name: 'moveTo', + args: [8, 0] + }, { + name: 'lineTo', + args: [8, 15] + }, { + name: 'lineTo', + args: [12, 15] + }, { + name: 'lineTo', + args: [12, 0] + }, { + name: 'fill', + args: [], + }]); + }); + + +}); \ No newline at end of file From 17c075eb0ed67be788643ef806d94fa3a642b8db Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 29 Aug 2015 12:31:44 -0400 Subject: [PATCH 269/424] Arc element tests --- src/elements/element.arc.js | 27 +++--- test/element.arc.tests.js | 176 ++++++++++++++++++++++++++++++++++++ test/mockContext.js | 8 ++ 3 files changed, 199 insertions(+), 12 deletions(-) create mode 100644 test/element.arc.tests.js diff --git a/src/elements/element.arc.js b/src/elements/element.arc.js index e09f0cf5795..209c505d931 100644 --- a/src/elements/element.arc.js +++ b/src/elements/element.arc.js @@ -37,21 +37,24 @@ var vm = this._view; - var pointRelativePosition = helpers.getAngleFromPoint(vm, { - x: chartX, - y: chartY - }); + if (vm) { + var pointRelativePosition = helpers.getAngleFromPoint(vm, { + x: chartX, + y: chartY + }); - // Put into the range of (-PI/2, 3PI/2] - var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; - var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle + // Put into the range of (-PI/2, 3PI/2] + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle - //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), - withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); + //Check if within the range of the open/close angle + var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), + withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); - return (betweenAngles && withinRadius); - //Ensure within the outside of the arc centre, but inside arc outer + return (betweenAngles && withinRadius); + } else { + return false; + } }, tooltipPosition: function() { var vm = this._view; diff --git a/test/element.arc.tests.js b/test/element.arc.tests.js new file mode 100644 index 00000000000..4ba8545754c --- /dev/null +++ b/test/element.arc.tests.js @@ -0,0 +1,176 @@ +// Test the rectangle element + +describe('Arc element tests', function() { + it ('Should be constructed', function() { + var arc = new Chart.elements.Arc({ + _datasetIndex: 2, + _index: 1 + }); + + expect(arc).not.toBe(undefined); + expect(arc._datasetIndex).toBe(2); + expect(arc._index).toBe(1); + }); + + it ('should determine if in range', function() { + var arc = new Chart.elements.Arc({ + _datasetIndex: 2, + _index: 1 + }); + + // Make sure we can run these before the view is added + expect(arc.inRange(2, 2)).toBe(false); + expect(arc.inLabelRange(2)).toBe(false); + + // Mock out the view as if the controller put it there + arc._view = { + startAngle: 0, + endAngle: Math.PI / 2, + x: 0, + y: 0, + innerRadius: 5, + outerRadius: 10, + }; + + expect(arc.inRange(2, 2)).toBe(false); + expect(arc.inRange(7, 0)).toBe(true); + expect(arc.inRange(0, 11)).toBe(false); + expect(arc.inRange(Math.sqrt(32), Math.sqrt(32))).toBe(true); + expect(arc.inRange(-1.0 * Math.sqrt(7), Math.sqrt(7))).toBe(false); + }); + + it ('should get the tooltip position', function() { + var arc = new Chart.elements.Arc({ + _datasetIndex: 2, + _index: 1 + }); + + // Mock out the view as if the controller put it there + arc._view = { + startAngle: 0, + endAngle: Math.PI / 2, + x: 0, + y: 0, + innerRadius: 0, + outerRadius: Math.sqrt(2), + }; + + var pos = arc.tooltipPosition(); + expect(pos.x).toBeCloseTo(0.5); + expect(pos.y).toBeCloseTo(0.5); + }); + + it ('should draw correctly with no border', function() { + var mockContext = window.createMockContext(); + var arc = new Chart.elements.Arc({ + _datasetIndex: 2, + _index: 1, + _chart: { + ctx: mockContext, + } + }); + + // Mock out the view as if the controller put it there + arc._view = { + startAngle: 0, + endAngle: Math.PI / 2, + x: 10, + y: 5, + innerRadius: 1, + outerRadius: 3, + + backgroundColor: 'rgb(0, 0, 255)', + borderColor: 'rgb(255, 0, 0)', + }; + + arc.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'beginPath', + args: [] + }, { + name: 'arc', + args: [10, 5, 3, 0, Math.PI / 2] + }, { + name: 'arc', + args: [10, 5, 1, Math.PI / 2, 0, true] + }, { + name: 'closePath', + args: [] + }, { + name: 'setStrokeStyle', + args: ['rgb(255, 0, 0)'] + }, { + name: 'setLineWidth', + args: [undefined] + }, { + name: 'setFillStyle', + args: ['rgb(0, 0, 255)'] + }, { + name: 'fill', + args: [] + }, { + name: 'setLineJoin', + args: ['bevel'] + }]); + }); + + it ('should draw correctly with a border', function() { + var mockContext = window.createMockContext(); + var arc = new Chart.elements.Arc({ + _datasetIndex: 2, + _index: 1, + _chart: { + ctx: mockContext, + } + }); + + // Mock out the view as if the controller put it there + arc._view = { + startAngle: 0, + endAngle: Math.PI / 2, + x: 10, + y: 5, + innerRadius: 1, + outerRadius: 3, + + backgroundColor: 'rgb(0, 0, 255)', + borderColor: 'rgb(255, 0, 0)', + borderWidth: 5 + }; + + arc.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'beginPath', + args: [] + }, { + name: 'arc', + args: [10, 5, 3, 0, Math.PI / 2] + }, { + name: 'arc', + args: [10, 5, 1, Math.PI / 2, 0, true] + }, { + name: 'closePath', + args: [] + }, { + name: 'setStrokeStyle', + args: ['rgb(255, 0, 0)'] + }, { + name: 'setLineWidth', + args: [5] + }, { + name: 'setFillStyle', + args: ['rgb(0, 0, 255)'] + }, { + name: 'fill', + args: [] + }, { + name: 'setLineJoin', + args: ['bevel'] + }, { + name: 'stroke', + args: [] + }]); + }); +}); \ No newline at end of file diff --git a/test/mockContext.js b/test/mockContext.js index 111aabbdf8f..f357715f175 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -5,6 +5,7 @@ this._initMethods(); this._fillStyle = null; + this._lineJoin = null; this._lineWidth = null; this._strokeStyle = null; @@ -17,6 +18,13 @@ this.record('setFillStyle', [style]); } }, + 'lineJoin': { + 'get': function() { return this._lineJoin; }, + 'set': function(join) { + this._lineJoin = join; + this.record('setLineJoin', [join]); + } + }, 'lineWidth': { 'get': function() { return this._lineWidth; }, 'set': function (width) { From eadfbbee6fa791f91e22388bfeb49aafe6b4b613 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 29 Aug 2015 14:16:37 -0400 Subject: [PATCH 270/424] Initial line element tests. Did not test the skipNull functionality since it seems to be broken. --- src/elements/element.line.js | 7 +- test/element.line.tests.js | 526 +++++++++++++++++++++++++++++++++++ test/mockContext.js | 20 ++ 3 files changed, 549 insertions(+), 4 deletions(-) create mode 100644 test/element.line.tests.js diff --git a/src/elements/element.line.js b/src/elements/element.line.js index 62c316c959b..88c21369926 100644 --- a/src/elements/element.line.js +++ b/src/elements/element.line.js @@ -114,7 +114,7 @@ // Now draw the line between all the points with any borders ctx.lineCap = vm.borderCapStyle || Chart.defaults.global.elements.line.borderCapStyle; - + // IE 9 and 10 do not support line dash if (ctx.setLineDash) { ctx.setLineDash(vm.borderDash || Chart.defaults.global.elements.line.borderDash); @@ -122,7 +122,7 @@ ctx.lineDashOffset = vm.borderDashOffset || Chart.defaults.global.elements.line.borderDashOffset; ctx.lineJoin = vm.borderJoinStyle || Chart.defaults.global.elements.line.borderJoinStyle; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.line.borderWidth; ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; ctx.beginPath(); @@ -184,10 +184,9 @@ } } - ctx.stroke(); ctx.restore(); }, }); -}).call(this); +}).call(this); \ No newline at end of file diff --git a/test/element.line.tests.js b/test/element.line.tests.js new file mode 100644 index 00000000000..5e41d7ff22d --- /dev/null +++ b/test/element.line.tests.js @@ -0,0 +1,526 @@ +// Tests for the line element +describe('Line element tests', function() { + it ('should be constructed', function() { + var line = new Chart.elements.Line({ + _datasetindex: 2, + _points: [1, 2, 3, 4] + }); + + expect(line).not.toBe(undefined); + expect(line._datasetindex).toBe(2); + expect(line._points).toEqual([1, 2, 3, 4]); + }); + + it ('should draw with default settings', function() { + var mockContext = window.createMockContext(); + + // Create our points + var points = []; + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 0, + _view: { + x: 0, + y: 10 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 1, + _view: { + x: 5, + y: 0 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 2, + _view: { + x: 15, + y: -10 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 3, + _view: { + x: 19, + y: -5 + } + })); + + var line = new Chart.elements.Line({ + _datasetindex: 2, + _chart: { + ctx: mockContext, + }, + _children: points, + // Need to provide some settings + _view: { + fill: false, // don't want to fill + tension: 0.0, // no bezier curve for now + } + }) + + line.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'save', + args: [], + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'lineTo', + args: [5, 0] + }, { + name: 'lineTo', + args: [15, -10] + }, { + name: 'lineTo', + args: [19, -5] + }, { + name: 'setLineCap', + args: ['butt'] + }, { + name: 'setLineDash', + args: [[]] + }, { + name: 'setLineDashOffset', + args: [0.0] + }, { + name: 'setLineJoin', + args: ['miter'] + }, { + name: 'setLineWidth', + args: [3] + }, { + name: 'setStrokeStyle', + args: ['rgba(0,0,0,0.1)'] + }, { + name: 'beginPath', + args: [] + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'lineTo', + args: [5, 0] + }, { + name: 'lineTo', + args: [15, -10] + }, { + name: 'lineTo', + args: [19, -5] + }, { + name: 'stroke', + args: [], + }, { + name: 'restore', + args: [] + }]) + }); + + it ('should draw with custom settings', function() { + var mockContext = window.createMockContext(); + + // Create our points + var points = []; + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 0, + _view: { + x: 0, + y: 10 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 1, + _view: { + x: 5, + y: 0 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 2, + _view: { + x: 15, + y: -10 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 3, + _view: { + x: 19, + y: -5 + } + })); + + var line = new Chart.elements.Line({ + _datasetindex: 2, + _chart: { + ctx: mockContext, + }, + _children: points, + // Need to provide some settings + _view: { + fill: true, + scaleZero: 2, // for filling lines + tension: 0.0, // no bezier curve for now + + borderCapStyle: 'round', + borderColor: 'rgb(255, 255, 0)', + borderDash: [2, 2], + borderDashOffset: 1.5, + borderJoinStyle: 'bevel', + borderWidth: 4, + backgroundColor: 'rgb(0, 0, 0)' + } + }) + + line.draw(); + + var expected = [{ + name: 'save', + args: [], + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'lineTo', + args: [5, 0] + }, { + name: 'lineTo', + args: [15, -10] + }, { + name: 'lineTo', + args: [19, -5] + }, { + name: 'lineTo', + args: [19, 2] + }, { + name: 'lineTo', + args: [0, 2] + }, { + name: 'setFillStyle', + args: ['rgb(0, 0, 0)'] + }, { + name: 'closePath', + args: [] + }, { + name: 'fill', + args: [] + }, { + name: 'setLineCap', + args: ['round'] + }, { + name: 'setLineDash', + args: [[2, 2]] + }, { + name: 'setLineDashOffset', + args: [1.5] + }, { + name: 'setLineJoin', + args: ['bevel'] + }, { + name: 'setLineWidth', + args: [4] + }, { + name: 'setStrokeStyle', + args: ['rgb(255, 255, 0)'] + }, { + name: 'beginPath', + args: [] + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'lineTo', + args: [5, 0] + }, { + name: 'lineTo', + args: [15, -10] + }, { + name: 'lineTo', + args: [19, -5] + }, { + name: 'stroke', + args: [], + }, { + name: 'restore', + args: [] + }]; + expect(mockContext.getCalls()).toEqual(expected) + }); + + it ('should be able to draw with a loop back to the beginning point', function() { + var mockContext = window.createMockContext(); + + // Create our points + var points = []; + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 0, + _view: { + x: 0, + y: 10 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 1, + _view: { + x: 5, + y: 0 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 2, + _view: { + x: 15, + y: -10 + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 3, + _view: { + x: 19, + y: -5 + } + })); + + var line = new Chart.elements.Line({ + _datasetindex: 2, + _chart: { + ctx: mockContext, + }, + _children: points, + _loop: true, // want the line to loop back to the first point + // Need to provide some settings + _view: { + fill: false, // don't want to fill + tension: 0.0, // no bezier curve for now + } + }) + + line.draw(); + + expect(mockContext.getCalls()).toEqual([{ + name: 'save', + args: [], + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'lineTo', + args: [5, 0] + }, { + name: 'lineTo', + args: [15, -10] + }, { + name: 'lineTo', + args: [19, -5] + }, { + name: 'lineTo', + args: [0, 10] + }, { + name: 'setLineCap', + args: ['butt'] + }, { + name: 'setLineDash', + args: [[]] + }, { + name: 'setLineDashOffset', + args: [0.0] + }, { + name: 'setLineJoin', + args: ['miter'] + }, { + name: 'setLineWidth', + args: [3] + }, { + name: 'setStrokeStyle', + args: ['rgba(0,0,0,0.1)'] + }, { + name: 'beginPath', + args: [] + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'lineTo', + args: [5, 0] + }, { + name: 'lineTo', + args: [15, -10] + }, { + name: 'lineTo', + args: [19, -5] + }, { + name: 'lineTo', + args: [0, 10] + }, { + name: 'stroke', + args: [], + }, { + name: 'restore', + args: [] + }]) + }); + + it ('should draw with bezier curves if tension > 0', function() { + var mockContext = window.createMockContext(); + + // Create our points + var points = []; + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 0, + _view: { + x: 0, + y: 10, + controlPointNextX: 1, + controlPointNextY: 1, + controlPointPreviousX: 0, + controlPointPreviousY: 0, + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 1, + _view: { + x: 5, + y: 0, + controlPointNextX: 6, + controlPointNextY: 7, + controlPointPreviousX: 4, + controlPointPreviousY: 3, + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 2, + _view: { + x: 15, + y: -10, + controlPointNextX: 16, + controlPointNextY: 17, + controlPointPreviousX: 14, + controlPointPreviousY: 13, + } + })); + points.push(new Chart.elements.Point({ + _datasetindex: 2, + _index: 3, + _view: { + x: 19, + y: -5, + controlPointNextX: 20, + controlPointNextY: 21, + controlPointPreviousX: 18, + controlPointPreviousY: 17, + } + })); + + var line = new Chart.elements.Line({ + _datasetindex: 2, + _chart: { + ctx: mockContext, + }, + _children: points, + // Need to provide some settings + _view: { + fill: true, + scaleZero: 2, // for filling lines + tension: 0.5, // have bezier curves + + borderCapStyle: 'round', + borderColor: 'rgb(255, 255, 0)', + borderDash: [2, 2], + borderDashOffset: 1.5, + borderJoinStyle: 'bevel', + borderWidth: 4, + backgroundColor: 'rgb(0, 0, 0)' + } + }) + + line.draw(); + + var expected = [{ + name: 'save', + args: [], + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'bezierCurveTo', + args: [1, 1, 4, 3, 5, 0] + }, { + name: 'bezierCurveTo', + args: [6, 7, 14, 13, 15, -10] + }, { + name: 'bezierCurveTo', + args: [16, 17, 18, 17, 19, -5] + }, { + name: 'lineTo', + args: [19, 2] + }, { + name: 'lineTo', + args: [0, 2] + }, { + name: 'setFillStyle', + args: ['rgb(0, 0, 0)'] + }, { + name: 'closePath', + args: [] + }, { + name: 'fill', + args: [] + }, { + name: 'setLineCap', + args: ['round'] + }, { + name: 'setLineDash', + args: [[2, 2]] + }, { + name: 'setLineDashOffset', + args: [1.5] + }, { + name: 'setLineJoin', + args: ['bevel'] + }, { + name: 'setLineWidth', + args: [4] + }, { + name: 'setStrokeStyle', + args: ['rgb(255, 255, 0)'] + }, { + name: 'beginPath', + args: [] + }, { + name: 'moveTo', + args: [0, 10] + }, { + name: 'bezierCurveTo', + args: [1, 1, 4, 3, 5, 0] + }, { + name: 'bezierCurveTo', + args: [6, 7, 14, 13, 15, -10] + }, { + name: 'bezierCurveTo', + args: [16, 17, 18, 17, 19, -5] + }, { + name: 'stroke', + args: [], + }, { + name: 'restore', + args: [] + }]; + expect(mockContext.getCalls()).toEqual(expected) + }); +}); \ No newline at end of file diff --git a/test/mockContext.js b/test/mockContext.js index f357715f175..239a0a3e48e 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -5,6 +5,8 @@ this._initMethods(); this._fillStyle = null; + this._lineCap = null; + this._lineDashOffset = null; this._lineJoin = null; this._lineWidth = null; this._strokeStyle = null; @@ -18,6 +20,20 @@ this.record('setFillStyle', [style]); } }, + 'lineCap': { + 'get': function() { return this._lineCap; }, + 'set': function(cap) { + this._lineCap = cap; + this.record('setLineCap', [cap]); + } + }, + 'lineDashOffset': { + 'get': function() { return this._lineDashOffset; }, + 'set': function(offset) { + this._lineDashOffset = offset; + this.record('setLineDashOffset', [offset]); + } + }, 'lineJoin': { 'get': function() { return this._lineJoin; }, 'set': function(join) { @@ -48,10 +64,14 @@ var methods = { arc: function() {}, beginPath: function() {}, + bezierCurveTo: function() {}, closePath: function() {}, fill: function() {}, lineTo: function(x, y) {}, moveTo: function(x, y) {}, + restore: function() {}, + save: function() {}, + setLineDash: function() {}, stroke: function() {} }; From 471618d2876761a3c8998b13cc83f18fc9419841 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 29 Aug 2015 22:27:40 -0400 Subject: [PATCH 271/424] Initial bar controller tests --- src/controllers/controller.bar.js | 14 ++ test/controller.bar.tests.js | 280 ++++++++++++++++++++++++++++++ 2 files changed, 294 insertions(+) create mode 100644 test/controller.bar.tests.js diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 94decab0499..4d85d78fe43 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -110,6 +110,20 @@ update: function(reset) { var numBars = this.getBarCount(); + var numData = this.getDataset().data.length; + var numRectangles = this.getDataset().metaData.length; + + // Make sure that we handle number of datapoints changing + if (numData < numRectangles) { + // Remove excess bars for data points that have been removed + this.getDataset().metaData.splice(numData, numRectangles - numData) + } else if (numData > numRectangles) { + // Add new elements + for (var index = numRectangles; index < numData; ++index) { + this.addElementAndReset(index); + } + } + helpers.each(this.getDataset().metaData, function(rectangle, index) { this.updateElement(rectangle, index, reset, numBars); }, this); diff --git a/test/controller.bar.tests.js b/test/controller.bar.tests.js new file mode 100644 index 00000000000..91efd48ddba --- /dev/null +++ b/test/controller.bar.tests.js @@ -0,0 +1,280 @@ +// Test the bar controller +describe('Bar controller tests', function() { + it('Should be constructed', function() { + var chart = { + data: { + datasets: [{ + + }, { + xAxisID: 'myXAxis', + yAxisID: 'myYAxis', + data: [] + }] + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + expect(controller).not.toBe(undefined); + expect(controller.index).toBe(1); + expect(chart.data.datasets[1].metaData).toEqual([]); + + controller.updateIndex(0); + expect(controller.index).toBe(0); + }); + + it('Should use the first scale IDs if the dataset does not specify them', function() { + var chart = { + data: { + datasets: [{ + + }, { + data: [] + }] + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + expect(chart.data.datasets[1].xAxisID).toBe('firstXScaleID'); + expect(chart.data.datasets[1].yAxisID).toBe('firstYScaleID'); + }); + + it('should correctly count the number of bar datasets', function() { + var chart = { + data: { + datasets: [{ + type: 'line' + }, { + type: 'bar' + }, { + // no type, defaults to bar + }] + }, + config: { + type: 'bar' + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + expect(controller.getBarCount()).toBe(2); + }); + + it('Should create rectangle elements for each data item during initialization', function() { + var chart = { + data: { + datasets: [{}, { + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'bar' + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + + expect(chart.data.datasets[1].metaData.length).toBe(4); // 4 rectangles created + expect(chart.data.datasets[1].metaData[0] instanceof Chart.elements.Rectangle).toBe(true); + expect(chart.data.datasets[1].metaData[1] instanceof Chart.elements.Rectangle).toBe(true); + expect(chart.data.datasets[1].metaData[2] instanceof Chart.elements.Rectangle).toBe(true); + expect(chart.data.datasets[1].metaData[3] instanceof Chart.elements.Rectangle).toBe(true); + }); + + it('should remove elements', function() { + var chart = { + data: { + datasets: [{}, { + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'bar' + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + controller.removeElement(1); + expect(chart.data.datasets[1].metaData.length).toBe(3); + }); + + it('should update elements', function() { + var chart = { + data: { + datasets: [{ + data: [1, 2], + label: 'dataset1', + }, { + data: [10, 15, 0, -4], + label: 'dataset2' + }], + labels: ['label1', 'label2', 'label3', 'label4'] + }, + config: { + type: 'bar' + }, + options: { + elements: { + rectangle: { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + } + }, + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + }, + scales: { + firstXScaleID: { + calculateBarWidth: function(numBars) { return numBars * 5; }, + calculateBarX: function(numBars, datasetIndex, index) { + return chart.data.datasets[datasetIndex].data[index]; + }, + }, + firstYScaleID: { + calculateBarBase: function(datasetIndex, index) { + return this.getPixelForValue(0); + }, + calculateBarY: function(datasetIndex, index) { + return this.getPixelForValue(chart.data.datasets[datasetIndex].data[index]); + }, + getPixelForValue: function(value) { + return value * 2; + }, + max: 10, + min: -10, + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + + chart.data.datasets[1].data = [1, 2]; // remove 2 items + controller.update(); + + expect(chart.data.datasets[1].metaData.length).toBe(2); + + var bar1 = chart.data.datasets[1].metaData[0]; + var bar2 = chart.data.datasets[1].metaData[1]; + + expect(bar1._datasetIndex).toBe(1); + expect(bar1._index).toBe(0); + expect(bar1._xScale).toBe(chart.scales.firstXScaleID); + expect(bar1._yScale).toBe(chart.scales.firstYScaleID); + expect(bar1._model).toEqual({ + x: 1, + y: 2, + label: 'label1', + datasetLabel: 'dataset2', + + base: 0, + width: 10, + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + }); + + expect(bar2._datasetIndex).toBe(1); + expect(bar2._index).toBe(1); + expect(bar2._xScale).toBe(chart.scales.firstXScaleID); + expect(bar2._yScale).toBe(chart.scales.firstYScaleID); + expect(bar2._model).toEqual({ + x: 2, + y: 4, + label: 'label2', + datasetLabel: 'dataset2', + + base: 0, + width: 10, + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + }); + + chart.data.datasets[1].data = [1, 2, 3]; + controller.update(); + + expect(chart.data.datasets[1].metaData.length).toBe(3); // should add a new meta data item + }); + + it ('should draw all bars', function() { + var chart = { + data: { + datasets: [{}, { + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'bar' + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + + spyOn(chart.data.datasets[1].metaData[0], 'draw'); + spyOn(chart.data.datasets[1].metaData[1], 'draw'); + spyOn(chart.data.datasets[1].metaData[2], 'draw'); + spyOn(chart.data.datasets[1].metaData[3], 'draw'); + + controller.draw(); + + expect(chart.data.datasets[1].metaData[0].draw.calls.count()).toBe(1); + expect(chart.data.datasets[1].metaData[1].draw.calls.count()).toBe(1); + expect(chart.data.datasets[1].metaData[2].draw.calls.count()).toBe(1); + expect(chart.data.datasets[1].metaData[3].draw.calls.count()).toBe(1); + }); +}); \ No newline at end of file From fcad4de670f673d0f0ff1c34264e9017cc245d62 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 10:42:00 -0400 Subject: [PATCH 272/424] Finish up bar controller tests --- src/controllers/controller.bar.js | 2 +- test/controller.bar.tests.js | 188 ++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 1 deletion(-) diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 4d85d78fe43..6f9724e8b51 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -185,7 +185,7 @@ rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, rectangle._model.borderWidth); }, removeHoverStyle: function(rectangle) { diff --git a/test/controller.bar.tests.js b/test/controller.bar.tests.js index 91efd48ddba..df27506a16a 100644 --- a/test/controller.bar.tests.js +++ b/test/controller.bar.tests.js @@ -277,4 +277,192 @@ describe('Bar controller tests', function() { expect(chart.data.datasets[1].metaData[2].draw.calls.count()).toBe(1); expect(chart.data.datasets[1].metaData[3].draw.calls.count()).toBe(1); }); + + it ('should set hover styles on rectangles', function() { + var chart = { + data: { + datasets: [{}, { + data: [10, 15, 0, -4] + }], + labels: ['label1', 'label2', 'label3', 'label4'] + }, + config: { + type: 'bar' + }, + options: { + elements: { + rectangle: { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + } + }, + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + }, + scales: { + firstXScaleID: { + calculateBarWidth: function(numBars) { return numBars * 5; }, + calculateBarX: function(numBars, datasetIndex, index) { + return chart.data.datasets[datasetIndex].data[index]; + }, + }, + firstYScaleID: { + calculateBarBase: function(datasetIndex, index) { + return this.getPixelForValue(0); + }, + calculateBarY: function(datasetIndex, index) { + return this.getPixelForValue(chart.data.datasets[datasetIndex].data[index]); + }, + getPixelForValue: function(value) { + return value * 2; + }, + max: 10, + min: -10, + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + controller.update(); + var bar = chart.data.datasets[1].metaData[0]; + controller.setHoverStyle(bar); + + expect(bar._model.backgroundColor).toBe('rgb(230, 0, 0)'); + expect(bar._model.borderColor).toBe('rgb(0, 0, 230)'); + expect(bar._model.borderWidth).toBe(2); + + // Set a dataset style + chart.data.datasets[1].hoverBackgroundColor = 'rgb(128, 128, 128)'; + chart.data.datasets[1].hoverBorderColor = 'rgb(0, 0, 0)'; + chart.data.datasets[1].hoverBorderWidth = 5; + + controller.setHoverStyle(bar); + + expect(bar._model.backgroundColor).toBe('rgb(128, 128, 128)'); + expect(bar._model.borderColor).toBe('rgb(0, 0, 0)'); + expect(bar._model.borderWidth).toBe(5); + + // Should work with array styles so that we can set per bar + chart.data.datasets[1].hoverBackgroundColor = ['rgb(255, 255, 255)', 'rgb(128, 128, 128)']; + chart.data.datasets[1].hoverBorderColor = ['rgb(9, 9, 9)', 'rgb(0, 0, 0)']; + chart.data.datasets[1].hoverBorderWidth = [2.5, 5]; + + controller.setHoverStyle(bar); + + expect(bar._model.backgroundColor).toBe('rgb(255, 255, 255)'); + expect(bar._model.borderColor).toBe('rgb(9, 9, 9)'); + expect(bar._model.borderWidth).toBe(2.5); + + // Should allow a custom style + bar.custom = { + hoverBackgroundColor: 'rgb(255, 0, 0)', + hoverBorderColor: 'rgb(0, 255, 0)', + hoverBorderWidth: 1.5 + }; + + controller.setHoverStyle(bar); + + expect(bar._model.backgroundColor).toBe('rgb(255, 0, 0)'); + expect(bar._model.borderColor).toBe('rgb(0, 255, 0)'); + expect(bar._model.borderWidth).toBe(1.5); + }); + + it ('should remove a hover style from a bar', function() { + var chart = { + data: { + datasets: [{}, { + data: [10, 15, 0, -4] + }], + labels: ['label1', 'label2', 'label3', 'label4'] + }, + config: { + type: 'bar' + }, + options: { + elements: { + rectangle: { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + } + }, + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + }, + scales: { + firstXScaleID: { + calculateBarWidth: function(numBars) { return numBars * 5; }, + calculateBarX: function(numBars, datasetIndex, index) { + return chart.data.datasets[datasetIndex].data[index]; + }, + }, + firstYScaleID: { + calculateBarBase: function(datasetIndex, index) { + return this.getPixelForValue(0); + }, + calculateBarY: function(datasetIndex, index) { + return this.getPixelForValue(chart.data.datasets[datasetIndex].data[index]); + }, + getPixelForValue: function(value) { + return value * 2; + }, + max: 10, + min: -10, + } + } + }; + + var controller = new Chart.controllers.bar(chart, 1); + controller.update(); + var bar = chart.data.datasets[1].metaData[0]; + + // Change default + chart.options.elements.rectangle.backgroundColor = 'rgb(128, 128, 128)'; + chart.options.elements.rectangle.borderColor = 'rgb(15, 15, 15)'; + chart.options.elements.rectangle.borderWidth = 3.14; + + // Remove to defaults + controller.removeHoverStyle(bar); + + expect(bar._model.backgroundColor).toBe('rgb(128, 128, 128)'); + expect(bar._model.borderColor).toBe('rgb(15, 15, 15)'); + expect(bar._model.borderWidth).toBe(3.14); + + // Should work with array styles so that we can set per bar + chart.data.datasets[1].backgroundColor = ['rgb(255, 255, 255)', 'rgb(128, 128, 128)']; + chart.data.datasets[1].borderColor = ['rgb(9, 9, 9)', 'rgb(0, 0, 0)']; + chart.data.datasets[1].borderWidth = [2.5, 5]; + + controller.removeHoverStyle(bar); + + expect(bar._model.backgroundColor).toBe('rgb(255, 255, 255)'); + expect(bar._model.borderColor).toBe('rgb(9, 9, 9)'); + expect(bar._model.borderWidth).toBe(2.5); + + // Should allow a custom style + bar.custom = { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 255, 0)', + borderWidth: 1.5 + }; + + controller.removeHoverStyle(bar); + + expect(bar._model.backgroundColor).toBe('rgb(255, 0, 0)'); + expect(bar._model.borderColor).toBe('rgb(0, 255, 0)'); + expect(bar._model.borderWidth).toBe(1.5); + }); }); \ No newline at end of file From 8e9de00529b00a3811b09d969a4b7bc87ca8be16 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 14:56:48 -0400 Subject: [PATCH 273/424] Doughnut controller tests --- src/controllers/controller.doughnut.js | 28 +- test/controller.doughnut.tests.js | 429 +++++++++++++++++++++++++ 2 files changed, 448 insertions(+), 9 deletions(-) create mode 100644 test/controller.doughnut.tests.js diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 8b161c29a35..2513a068985 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -49,10 +49,6 @@ return this.chart.data.datasets[this.index]; }, - getScaleForId: function(scaleID) { - return this.chart.scales[scaleID]; - }, - addElements: function() { this.getDataset().metaData = this.getDataset().metaData || []; helpers.each(this.getDataset().data, function(value, index) { @@ -71,7 +67,9 @@ _index: index, }); - this.getDataset().backgroundColor.splice(index, 0, colorForNewElement); + if (colorForNewElement && helpers.isArray(this.getDataset().backgroundColor)) { + this.getDataset().backgroundColor.splice(index, 0, colorForNewElement); + } // Reset the point this.updateElement(arc, index, true); @@ -92,7 +90,6 @@ this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; - this.getDataset().total = 0; helpers.each(this.getDataset().data, function(value) { this.getDataset().total += Math.abs(value); @@ -101,6 +98,21 @@ this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index); this.innerRadius = this.outerRadius - this.chart.radiusLength; + // Make sure we have metaData for each data point + var numData = this.getDataset().data.length; + var numArcs = this.getDataset().metaData.length; + + // Make sure that we handle number of datapoints changing + if (numData < numArcs) { + // Remove excess bars for data points that have been removed + this.getDataset().metaData.splice(numData, numArcs - numData) + } else if (numData > numArcs) { + // Add new elements + for (var index = numArcs; index < numData; ++index) { + this.addElementAndReset(index); + } + } + helpers.each(this.getDataset().metaData, function(arc, index) { this.updateElement(arc, index, reset); }, this); @@ -165,15 +177,13 @@ }, this); }, - - setHoverStyle: function(arc) { var dataset = this.chart.data.datasets[arc._datasetIndex]; var index = arc._index; arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(arc._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, arc._model.borderWidth); + arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, arc._model.borderWidth); }, removeHoverStyle: function(arc) { diff --git a/test/controller.doughnut.tests.js b/test/controller.doughnut.tests.js new file mode 100644 index 00000000000..cef6062637f --- /dev/null +++ b/test/controller.doughnut.tests.js @@ -0,0 +1,429 @@ +// Test the bar controller +describe('Doughnut controller tests', function() { + it('Should be constructed', function() { + var chart = { + data: { + datasets: [{ + data: [] + }] + } + }; + + var controller = new Chart.controllers.doughnut(chart, 0); + expect(controller).not.toBe(undefined); + expect(controller.index).toBe(0); + expect(chart.data.datasets[0].metaData).toEqual([]); + + controller.updateIndex(1); + expect(controller.index).toBe(1); + }); + + it('Should create arc elements for each data item during initialization', function() { + var chart = { + data: { + datasets: [{ + data: [10, 15, 0, 4] + }] + }, + config: { + type: 'doughnut' + }, + options: { + } + }; + + var controller = new Chart.controllers.doughnut(chart, 0); + + expect(chart.data.datasets[0].metaData.length).toBe(4); // 4 rectangles created + expect(chart.data.datasets[0].metaData[0] instanceof Chart.elements.Arc).toBe(true); + expect(chart.data.datasets[0].metaData[1] instanceof Chart.elements.Arc).toBe(true); + expect(chart.data.datasets[0].metaData[2] instanceof Chart.elements.Arc).toBe(true); + expect(chart.data.datasets[0].metaData[3] instanceof Chart.elements.Arc).toBe(true); + }); + + it ('Should remove elements', function() { + var chart = { + data: { + datasets: [{ + data: [10, 15, 0, 4] + }] + }, + config: { + type: 'doughnut' + }, + options: { + } + }; + + var controller = new Chart.controllers.doughnut(chart, 0); + controller.removeElement(1); + expect(chart.data.datasets[0].metaData.length).toBe(3); + }); + + it ('Should reset and update elements', function() { + var chart = { + chart: { + width: 100, + height: 200, + }, + data: { + datasets: [{ + data: [10, 15, 0, 4] + }, { + data: [1] + }], + labels: ['label0', 'label1', 'label2', 'label3'] + }, + config: { + type: 'doughnut' + }, + options: { + animation: { + animateRotate: false, + animateScale: false + }, + cutoutPercentage: 50, + elements: { + arc: { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + hoverBackgroundColor: 'rgb(255, 255, 255)' + } + } + } + }; + + var controller = new Chart.controllers.doughnut(chart, 0); + controller.reset(); // reset first + + expect(chart.data.datasets[0].metaData[0]._model).toEqual({ + x: 50, + y: 100, + startAngle: Math.PI * -0.5, + circumference: 2.166614539857563, + outerRadius: 49, + innerRadius: 36.75, + }); + + expect(chart.data.datasets[0].metaData[1]._model).toEqual({ + x: 50, + y: 100, + startAngle: Math.PI * -0.5, + circumference: 3.2499218097863447, + outerRadius: 49, + innerRadius: 36.75, + }); + + expect(chart.data.datasets[0].metaData[2]._model).toEqual({ + x: 50, + y: 100, + startAngle: Math.PI * -0.5, + circumference: 0, + outerRadius: 49, + innerRadius: 36.75, + }); + + expect(chart.data.datasets[0].metaData[3]._model).toEqual({ + x: 50, + y: 100, + startAngle: Math.PI * -0.5, + circumference: 0.8666458159430251, + outerRadius: 49, + innerRadius: 36.75, + }); + + controller.update(); + + expect(chart.data.datasets[0].metaData[0]._model).toEqual({ + x: 50, + y: 100, + startAngle: Math.PI * -0.5, + endAngle: 0.5958182130626666, + circumference: 2.166614539857563, + outerRadius: 49, + innerRadius: 36.75, + + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + hoverBackgroundColor: 'rgb(255, 255, 255)', + + label: 'label0', + }); + + expect(chart.data.datasets[0].metaData[1]._model).toEqual({ + x: 50, + y: 100, + startAngle: 0.5958182130626666, + endAngle: 3.8457400228490113, + circumference: 3.2499218097863447, + outerRadius: 49, + innerRadius: 36.75, + + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + hoverBackgroundColor: 'rgb(255, 255, 255)', + + label: 'label1' + }); + + expect(chart.data.datasets[0].metaData[2]._model).toEqual({ + x: 50, + y: 100, + startAngle: 3.8457400228490113, + endAngle: 3.8457400228490113, + circumference: 0, + outerRadius: 49, + innerRadius: 36.75, + + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + hoverBackgroundColor: 'rgb(255, 255, 255)', + + label: 'label2' + }); + + expect(chart.data.datasets[0].metaData[3]._model).toEqual({ + x: 50, + y: 100, + startAngle: 3.8457400228490113, + endAngle: 4.712385838792036, + circumference: 0.8666458159430251, + outerRadius: 49, + innerRadius: 36.75, + + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + hoverBackgroundColor: 'rgb(255, 255, 255)', + + label: 'label3' + }); + + // Change the amount of data and ensure that arcs are updated accordingly + chart.data.datasets[0].data = [1, 2]; // remove 2 elements from dataset 0 + controller.update(); + + expect(chart.data.datasets[0].metaData.length).toBe(2); + expect(chart.data.datasets[0].metaData[0] instanceof Chart.elements.Arc).toBe(true); + expect(chart.data.datasets[0].metaData[1] instanceof Chart.elements.Arc).toBe(true); + + // Add data + chart.data.datasets[0].data = [1, 2, 3, 4]; + controller.update(); + + expect(chart.data.datasets[0].metaData.length).toBe(4); + expect(chart.data.datasets[0].metaData[0] instanceof Chart.elements.Arc).toBe(true); + expect(chart.data.datasets[0].metaData[1] instanceof Chart.elements.Arc).toBe(true); + expect(chart.data.datasets[0].metaData[2] instanceof Chart.elements.Arc).toBe(true); + expect(chart.data.datasets[0].metaData[3] instanceof Chart.elements.Arc).toBe(true); + }); + + it ('should draw all arcs', function() { + var chart = { + chart: { + width: 100, + height: 200, + }, + data: { + datasets: [{ + data: [10, 15, 0, 4] + }], + labels: ['label0', 'label1', 'label2', 'label3'] + }, + config: { + type: 'doughnut' + }, + options: { + animation: { + animateRotate: false, + animateScale: false + }, + cutoutPercentage: 50, + elements: { + arc: { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + hoverBackgroundColor: 'rgb(255, 255, 255)' + } + } + } + }; + + var controller = new Chart.controllers.doughnut(chart, 0); + + spyOn(chart.data.datasets[0].metaData[0], 'draw'); + spyOn(chart.data.datasets[0].metaData[1], 'draw'); + spyOn(chart.data.datasets[0].metaData[2], 'draw'); + spyOn(chart.data.datasets[0].metaData[3], 'draw'); + + controller.draw(); + + expect(chart.data.datasets[0].metaData[0].draw.calls.count()).toBe(1); + expect(chart.data.datasets[0].metaData[1].draw.calls.count()).toBe(1); + expect(chart.data.datasets[0].metaData[2].draw.calls.count()).toBe(1); + expect(chart.data.datasets[0].metaData[3].draw.calls.count()).toBe(1); + }); + + it ('should set the hover style of an arc', function() { + var chart = { + chart: { + width: 100, + height: 200, + }, + data: { + datasets: [{ + data: [10, 15, 0, 4] + }], + labels: ['label0', 'label1', 'label2', 'label3'] + }, + config: { + type: 'doughnut' + }, + options: { + animation: { + animateRotate: false, + animateScale: false + }, + cutoutPercentage: 50, + elements: { + arc: { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + } + } + } + }; + + var controller = new Chart.controllers.doughnut(chart, 0); + controller.reset(); // reset first + controller.update(); + + var arc = chart.data.datasets[0].metaData[0]; + + controller.setHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(230, 0, 0)'); + expect(arc._model.borderColor).toBe('rgb(0, 0, 230)'); + expect(arc._model.borderWidth).toBe(2); + + // Set a dataset style to take precedence + chart.data.datasets[0].hoverBackgroundColor = 'rgb(9, 9, 9)'; + chart.data.datasets[0].hoverBorderColor = 'rgb(18, 18, 18)'; + chart.data.datasets[0].hoverBorderWidth = 1.56; + + controller.setHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(9, 9, 9)'); + expect(arc._model.borderColor).toBe('rgb(18, 18, 18)'); + expect(arc._model.borderWidth).toBe(1.56); + + // Dataset styles can be an array + chart.data.datasets[0].hoverBackgroundColor = ['rgb(255, 255, 255)', 'rgb(9, 9, 9)']; + chart.data.datasets[0].hoverBorderColor = ['rgb(18, 18, 18)']; + chart.data.datasets[0].hoverBorderWidth = [0.1, 1.56]; + + controller.setHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(255, 255, 255)'); + expect(arc._model.borderColor).toBe('rgb(18, 18, 18)'); + expect(arc._model.borderWidth).toBe(0.1); + + // Element custom styles also work + arc.custom = { + hoverBackgroundColor: 'rgb(7, 7, 7)', + hoverBorderColor: 'rgb(17, 17, 17)', + hoverBorderWidth: 3.14159, + }; + + controller.setHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(7, 7, 7)'); + expect(arc._model.borderColor).toBe('rgb(17, 17, 17)'); + expect(arc._model.borderWidth).toBe(3.14159); + }); + + it ('should unset the hover style of an arc', function() { + var chart = { + chart: { + width: 100, + height: 200, + }, + data: { + datasets: [{ + data: [10, 15, 0, 4] + }], + labels: ['label0', 'label1', 'label2', 'label3'] + }, + config: { + type: 'doughnut' + }, + options: { + animation: { + animateRotate: false, + animateScale: false + }, + cutoutPercentage: 50, + elements: { + arc: { + backgroundColor: 'rgb(255, 0, 0)', + borderColor: 'rgb(0, 0, 255)', + borderWidth: 2, + } + } + } + }; + + var controller = new Chart.controllers.doughnut(chart, 0); + controller.reset(); // reset first + controller.update(); + + var arc = chart.data.datasets[0].metaData[0]; + + controller.removeHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(255, 0, 0)'); + expect(arc._model.borderColor).toBe('rgb(0, 0, 255)'); + expect(arc._model.borderWidth).toBe(2); + + // Set a dataset style to take precedence + chart.data.datasets[0].backgroundColor = 'rgb(9, 9, 9)'; + chart.data.datasets[0].borderColor = 'rgb(18, 18, 18)'; + chart.data.datasets[0].borderWidth = 1.56; + + controller.removeHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(9, 9, 9)'); + expect(arc._model.borderColor).toBe('rgb(18, 18, 18)'); + expect(arc._model.borderWidth).toBe(1.56); + + // Dataset styles can be an array + chart.data.datasets[0].backgroundColor = ['rgb(255, 255, 255)', 'rgb(9, 9, 9)']; + chart.data.datasets[0].borderColor = ['rgb(18, 18, 18)']; + chart.data.datasets[0].borderWidth = [0.1, 1.56]; + + controller.removeHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(255, 255, 255)'); + expect(arc._model.borderColor).toBe('rgb(18, 18, 18)'); + expect(arc._model.borderWidth).toBe(0.1); + + // Element custom styles also work + arc.custom = { + backgroundColor: 'rgb(7, 7, 7)', + borderColor: 'rgb(17, 17, 17)', + borderWidth: 3.14159, + }; + + controller.removeHoverStyle(arc); + + expect(arc._model.backgroundColor).toBe('rgb(7, 7, 7)'); + expect(arc._model.borderColor).toBe('rgb(17, 17, 17)'); + expect(arc._model.borderWidth).toBe(3.14159); + }); +}); \ No newline at end of file From ce623075e336cef842253f0ddc7c7767b40c167a Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 17:42:42 -0400 Subject: [PATCH 274/424] Add line controller tests. Fixed an issue when the number of data points changes. When adding the tension to a point, get the same tension as the line if it has been overridden at the dataset level. When setting the hover style of a point, allow setting the radius independently of the regular radius. Use the hoverRadius property in point.custom or the dataset.pointHoverRadius. Allow setting the border width independently at the dataset level. Use dataset.pointHoverBorderWidth. This can be an array or a number. --- src/controllers/controller.line.js | 25 +- test/controller.line.tests.js | 814 +++++++++++++++++++++++++++++ 2 files changed, 832 insertions(+), 7 deletions(-) create mode 100644 test/controller.line.tests.js diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index d007498a896..608b5d704bf 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -109,6 +109,21 @@ var xScale = this.getScaleForId(this.getDataset().xAxisID); var scaleBase; + // Handle the number of data points changing + var numData = this.getDataset().data.length; + var numPoints = this.getDataset().metaData.length; + + // Make sure that we handle number of datapoints changing + if (numData < numPoints) { + // Remove excess bars for data points that have been removed + this.getDataset().metaData.splice(numData, numPoints - numData) + } else if (numData > numPoints) { + // Add new elements + for (var index = numPoints; index < numData; ++index) { + this.addElementAndReset(index); + } + } + if (yScale.min < 0 && yScale.max < 0) { scaleBase = yScale.getPixelForValue(yScale.max); } else if (yScale.min > 0 && yScale.max > 0) { @@ -180,7 +195,7 @@ x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + tension: point.custom && point.custom.tension ? point.custom.tension : (this.getDataset().tension || this.chart.options.elements.line.tension), radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), @@ -253,10 +268,10 @@ var dataset = this.chart.data.datasets[point._datasetIndex]; var index = point._index; - point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + point._model.radius = point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, point._model.borderWidth); }, removeHoverStyle: function(point) { @@ -268,9 +283,5 @@ point._model.borderColor = point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor); point._model.borderWidth = point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth); } - }); - - - }).call(this); diff --git a/test/controller.line.tests.js b/test/controller.line.tests.js new file mode 100644 index 00000000000..154435c70c3 --- /dev/null +++ b/test/controller.line.tests.js @@ -0,0 +1,814 @@ +// Test the bar controller +describe('Line controller tests', function() { + it('Should be constructed', function() { + var chart = { + data: { + datasets: [{ + xAxisID: 'myXAxis', + yAxisID: 'myYAxis', + data: [] + }] + } + }; + + var controller = new Chart.controllers.line(chart, 0); + expect(controller).not.toBe(undefined); + expect(controller.index).toBe(0); + expect(chart.data.datasets[0].metaData).toEqual([]); + + controller.updateIndex(1); + expect(controller.index).toBe(1); + }); + + it('Should use the first scale IDs if the dataset does not specify them', function() { + var chart = { + data: { + datasets: [{ + data: [] + }] + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + expect(chart.data.datasets[0].xAxisID).toBe('firstXScaleID'); + expect(chart.data.datasets[0].yAxisID).toBe('firstYScaleID'); + }); + + it('Should create line elements and point elements for each data item during initialization', function() { + var chart = { + data: { + datasets: [{ + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'line' + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + + expect(chart.data.datasets[0].metaData.length).toBe(4); // 4 points created + expect(chart.data.datasets[0].metaData[0] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[1] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[2] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[3] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaDataset instanceof Chart.elements.Line).toBe(true); // 1 line element + }); + + it('should remove elements', function() { + var chart = { + data: { + datasets: [{ + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'line' + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + controller.removeElement(0); + expect(chart.data.datasets[0].metaData.length).toBe(3); + }); + + it ('should draw all elements', function() { + var chart = { + data: { + datasets: [{ + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'line' + }, + options: { + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + + spyOn(chart.data.datasets[0].metaDataset, 'draw'); + spyOn(chart.data.datasets[0].metaData[0], 'draw'); + spyOn(chart.data.datasets[0].metaData[1], 'draw'); + spyOn(chart.data.datasets[0].metaData[2], 'draw'); + spyOn(chart.data.datasets[0].metaData[3], 'draw'); + + controller.draw(); + + expect(chart.data.datasets[0].metaDataset.draw.calls.count()).toBe(1); + expect(chart.data.datasets[0].metaData[0].draw.calls.count()).toBe(1); + expect(chart.data.datasets[0].metaData[2].draw.calls.count()).toBe(1); + expect(chart.data.datasets[0].metaData[3].draw.calls.count()).toBe(1); + }); + + it ('should update elements', function() { + var chart = { + chartArea: { + bottom: 100, + left: 0, + right: 200, + top: 0 + }, + data: { + datasets: [{ + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'line' + }, + options: { + elements: { + line: { + backgroundColor: 'rgb(255, 0, 0)', + borderCapStyle: 'round', + borderColor: 'rgb(0, 255, 0)', + borderDash: [], + borderDashOffset: 0.1, + borderJoinStyle: 'bevel', + borderWidth: 1.2, + fill: true, + skipNull: true, + tension: 0.1, + }, + point: { + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1, + radius: 3, + } + }, + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + }, + scales: { + firstXScaleID: { + getPointPixelForValue: function(value, index) { + return index * 3; + } + }, + firstYScaleID: { + calculateBarBase: function(datasetIndex, index) { + return this.getPixelForValue(0); + }, + getPointPixelForValue: function(value, datasetIndex, index) { + return this.getPixelForValue(value); + }, + getPixelForValue: function(value) { + return value * 2; + }, + max: 10, + min: -10, + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + controller.update(); + + // Line element + expect(chart.data.datasets[0].metaDataset._model).toEqual({ + backgroundColor: 'rgb(255, 0, 0)', + borderCapStyle: 'round', + borderColor: 'rgb(0, 255, 0)', + borderDash: [], + borderDashOffset: 0.1, + borderJoinStyle: 'bevel', + borderWidth: 1.2, + fill: true, + drawNull: undefined, + skipNull: true, + tension: 0.1, + + scaleTop: undefined, + scaleBottom: undefined, + scaleZero: 0, + }); + + expect(chart.data.datasets[0].metaData[0]._model).toEqual({ + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + hitRadius: 1, + radius: 3, + skip: false, + tension: 0.1, + + // Point + x: 0, + y: 20, + + // Control points + controlPointPreviousX: 0, + controlPointPreviousY: 20, + controlPointNextX: 0.30000000000000004, + controlPointNextY: 21, + }); + + expect(chart.data.datasets[0].metaData[1]._model).toEqual({ + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + hitRadius: 1, + radius: 3, + skip: false, + tension: 0.1, + + // Point + x: 3, + y: 30, + + // Control points + controlPointPreviousX: 2.845671490812908, + controlPointPreviousY: 30.514428363956974, + controlPointNextX: 3.4456714908129076, + controlPointNextY: 28.514428363956974, + }); + + expect(chart.data.datasets[0].metaData[2]._model).toEqual({ + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + hitRadius: 1, + radius: 3, + skip: false, + tension: 0.1, + + // Point + x: 6, + y: 0, + + // Control points + controlPointPreviousX: 5.532486979550596, + controlPointPreviousY: 2.9609157961795605, + controlPointNextX: 6.132486979550595, + controlPointNextY: 0, + }); + + expect(chart.data.datasets[0].metaData[3]._model).toEqual({ + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + hitRadius: 1, + radius: 3, + skip: false, + tension: 0.1, + + // Point + x: 9, + y: -8, + + // Control points + controlPointPreviousX: 8.7, + controlPointPreviousY: 0, + controlPointNextX: 9, + controlPointNextY: 0, + }); + + // Use dataset level styles for lines & points + chart.data.datasets[0].tension = 0.2; + chart.data.datasets[0].backgroundColor = 'rgb(98, 98, 98)'; + chart.data.datasets[0].borderColor = 'rgb(8, 8, 8)'; + chart.data.datasets[0].borderWidth = 0.55; + chart.data.datasets[0].borderCapStyle = 'butt'; + chart.data.datasets[0].borderDash = [2, 3]; + chart.data.datasets[0].borderDashOffset = 7; + chart.data.datasets[0].borderJoinStyle = 'miter'; + chart.data.datasets[0].fill = false; + chart.data.datasets[0].skipNull = false; + chart.data.datasets[0].drawNull = true; + + // point styles + chart.data.datasets[0].radius = 22; + chart.data.datasets[0].hitRadius = 3.3; + chart.data.datasets[0].pointBackgroundColor = 'rgb(128, 129, 130)'; + chart.data.datasets[0].pointBorderColor = 'rgb(56, 57, 58)'; + chart.data.datasets[0].pointBorderWidth = 1.123; + + controller.update(); + + expect(chart.data.datasets[0].metaDataset._model).toEqual({ + backgroundColor: 'rgb(98, 98, 98)', + borderCapStyle: 'butt', + borderColor: 'rgb(8, 8, 8)', + borderDash: [2, 3], + borderDashOffset: 7, + borderJoinStyle: 'miter', + borderWidth: 0.55, + fill: false, + drawNull: true, + skipNull: false, + tension: 0.2, + + scaleTop: undefined, + scaleBottom: undefined, + scaleZero: 0, + }); + + expect(chart.data.datasets[0].metaData[0]._model).toEqual({ + backgroundColor: 'rgb(128, 129, 130)', + borderWidth: 1.123, + borderColor: 'rgb(56, 57, 58)', + hitRadius: 3.3, + radius: 22, + skip: false, + tension: 0.2, + + // Point + x: 0, + y: 20, + + // Control points + controlPointPreviousX: 0, + controlPointPreviousY: 20, + controlPointNextX: 0.6000000000000001, + controlPointNextY: 22, + }); + + expect(chart.data.datasets[0].metaData[1]._model).toEqual({ + backgroundColor: 'rgb(128, 129, 130)', + borderWidth: 1.123, + borderColor: 'rgb(56, 57, 58)', + hitRadius: 3.3, + radius: 22, + skip: false, + tension: 0.2, + + // Point + x: 3, + y: 30, + + // Control points + controlPointPreviousX: 2.6913429816258154, + controlPointPreviousY: 31.028856727913947, + controlPointNextX: 3.891342981625815, + controlPointNextY: 27.028856727913947, + }); + + expect(chart.data.datasets[0].metaData[2]._model).toEqual({ + backgroundColor: 'rgb(128, 129, 130)', + borderWidth: 1.123, + borderColor: 'rgb(56, 57, 58)', + hitRadius: 3.3, + radius: 22, + skip: false, + tension: 0.2, + + // Point + x: 6, + y: 0, + + // Control points + controlPointPreviousX: 5.0649739591011915, + controlPointPreviousY: 5.921831592359121, + controlPointNextX: 6.264973959101192, + controlPointNextY: 0, + }); + + expect(chart.data.datasets[0].metaData[3]._model).toEqual({ + backgroundColor: 'rgb(128, 129, 130)', + borderWidth: 1.123, + borderColor: 'rgb(56, 57, 58)', + hitRadius: 3.3, + radius: 22, + skip: false, + tension: 0.2, + + // Point + x: 9, + y: -8, + + // Control points + controlPointPreviousX: 8.4, + controlPointPreviousY: 0, + controlPointNextX: 9, + controlPointNextY: 0, + }); + + // Use custom styles for lines & first point + chart.data.datasets[0].metaDataset.custom = { + tension: 0.25, + backgroundColor: 'rgb(55, 55, 54)', + borderColor: 'rgb(8, 7, 6)', + borderWidth: 0.3, + borderCapStyle: 'square', + borderDash: [4, 3], + borderDashOffset: 4.4, + borderJoinStyle: 'round', + fill: true, + skipNull: true, + drawNull: false, + }; + + // point styles + chart.data.datasets[0].metaData[0].custom = { + radius: 2.2, + backgroundColor: 'rgb(0, 1, 3)', + borderColor: 'rgb(4, 6, 8)', + borderWidth: 0.787, + tension: 0.15, + skip: true, + hitRadius: 5, + }; + + controller.update(); + + expect(chart.data.datasets[0].metaDataset._model).toEqual({ + backgroundColor: 'rgb(55, 55, 54)', + borderCapStyle: 'square', + borderColor: 'rgb(8, 7, 6)', + borderDash: [4, 3], + borderDashOffset: 4.4, + borderJoinStyle: 'round', + borderWidth: 0.3, + fill: true, + drawNull: true, + skipNull: false, + tension: 0.25, + + scaleTop: undefined, + scaleBottom: undefined, + scaleZero: 0, + }); + + expect(chart.data.datasets[0].metaData[0]._model).toEqual({ + backgroundColor: 'rgb(0, 1, 3)', + borderWidth: 0.787, + borderColor: 'rgb(4, 6, 8)', + hitRadius: 5, + radius: 2.2, + skip: true, + tension: 0.15, + + // Point + x: 0, + y: 20, + + // Control points + controlPointPreviousX: 0, + controlPointPreviousY: 20, + controlPointNextX: 0.44999999999999996, + controlPointNextY: 21.5, + }); + }); + + it ('should handle number of data point changes in update', function() { + var chart = { + chartArea: { + bottom: 100, + left: 0, + right: 200, + top: 0 + }, + data: { + datasets: [{ + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'line' + }, + options: { + elements: { + line: { + backgroundColor: 'rgb(255, 0, 0)', + borderCapStyle: 'round', + borderColor: 'rgb(0, 255, 0)', + borderDash: [], + borderDashOffset: 0.1, + borderJoinStyle: 'bevel', + borderWidth: 1.2, + fill: true, + skipNull: true, + tension: 0.1, + }, + point: { + backgroundColor: Chart.defaults.global.defaultColor, + borderWidth: 1, + borderColor: Chart.defaults.global.defaultColor, + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1, + radius: 3, + } + }, + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + }, + scales: { + firstXScaleID: { + getPointPixelForValue: function(value, index) { + return index * 3; + } + }, + firstYScaleID: { + calculateBarBase: function(datasetIndex, index) { + return this.getPixelForValue(0); + }, + getPointPixelForValue: function(value, datasetIndex, index) { + return this.getPixelForValue(value); + }, + getPixelForValue: function(value) { + return value * 2; + }, + max: 10, + min: -10, + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + chart.data.datasets[0].data = [1, 2]; // remove 2 items + + controller.update(); + expect(chart.data.datasets[0].metaData.length).toBe(2); + expect(chart.data.datasets[0].metaData[0] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[1] instanceof Chart.elements.Point).toBe(true); + + chart.data.datasets[0].data = [1, 2, 3, 4, 5]; // add 3 items + + controller.update(); + expect(chart.data.datasets[0].metaData.length).toBe(5); + expect(chart.data.datasets[0].metaData[0] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[1] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[2] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[3] instanceof Chart.elements.Point).toBe(true); + expect(chart.data.datasets[0].metaData[4] instanceof Chart.elements.Point).toBe(true); + }); + + it ('should set point hover styles', function() { + var chart = { + chartArea: { + bottom: 100, + left: 0, + right: 200, + top: 0 + }, + data: { + datasets: [{ + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'line' + }, + options: { + elements: { + line: { + backgroundColor: 'rgb(255, 0, 0)', + borderCapStyle: 'round', + borderColor: 'rgb(0, 255, 0)', + borderDash: [], + borderDashOffset: 0.1, + borderJoinStyle: 'bevel', + borderWidth: 1.2, + fill: true, + skipNull: true, + tension: 0.1, + }, + point: { + backgroundColor: 'rgb(255, 255, 0)', + borderWidth: 1, + borderColor: 'rgb(255, 255, 255)', + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1, + radius: 3, + } + }, + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + }, + scales: { + firstXScaleID: { + getPointPixelForValue: function(value, index) { + return index * 3; + } + }, + firstYScaleID: { + calculateBarBase: function(datasetIndex, index) { + return this.getPixelForValue(0); + }, + getPointPixelForValue: function(value, datasetIndex, index) { + return this.getPixelForValue(value); + }, + getPixelForValue: function(value) { + return value * 2; + }, + max: 10, + min: -10, + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + controller.update(); + var point = chart.data.datasets[0].metaData[0]; + + controller.setHoverStyle(point); + expect(point._model.backgroundColor).toBe('rgb(229, 230, 0)'); + expect(point._model.borderColor).toBe('rgb(230, 230, 230)'); + expect(point._model.borderWidth).toBe(1); + expect(point._model.radius).toBe(4); + + // Can set hover style per dataset + chart.data.datasets[0].pointHoverRadius = 3.3; + chart.data.datasets[0].pointHoverBackgroundColor = 'rgb(77, 79, 81)'; + chart.data.datasets[0].pointHoverBorderColor = 'rgb(123, 125, 127)'; + chart.data.datasets[0].pointHoverBorderWidth = 2.1; + + controller.setHoverStyle(point); + expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)'); + expect(point._model.borderColor).toBe('rgb(123, 125, 127)'); + expect(point._model.borderWidth).toBe(2.1); + expect(point._model.radius).toBe(3.3); + + // Custom style + point.custom = { + hoverRadius: 4.4, + hoverBorderWidth: 5.5, + hoverBackgroundColor: 'rgb(0, 0, 0)', + hoverBorderColor: 'rgb(10, 10, 10)' + }; + + controller.setHoverStyle(point); + expect(point._model.backgroundColor).toBe('rgb(0, 0, 0)'); + expect(point._model.borderColor).toBe('rgb(10, 10, 10)'); + expect(point._model.borderWidth).toBe(5.5); + expect(point._model.radius).toBe(4.4); + }); + + it ('should remove hover styles', function() { + var chart = { + chartArea: { + bottom: 100, + left: 0, + right: 200, + top: 0 + }, + data: { + datasets: [{ + data: [10, 15, 0, -4] + }] + }, + config: { + type: 'line' + }, + options: { + elements: { + line: { + backgroundColor: 'rgb(255, 0, 0)', + borderCapStyle: 'round', + borderColor: 'rgb(0, 255, 0)', + borderDash: [], + borderDashOffset: 0.1, + borderJoinStyle: 'bevel', + borderWidth: 1.2, + fill: true, + skipNull: true, + tension: 0.1, + }, + point: { + backgroundColor: 'rgb(255, 255, 0)', + borderWidth: 1, + borderColor: 'rgb(255, 255, 255)', + hitRadius: 1, + hoverRadius: 4, + hoverBorderWidth: 1, + radius: 3, + } + }, + scales: { + xAxes: [{ + id: 'firstXScaleID' + }], + yAxes: [{ + id: 'firstYScaleID' + }] + } + }, + scales: { + firstXScaleID: { + getPointPixelForValue: function(value, index) { + return index * 3; + } + }, + firstYScaleID: { + calculateBarBase: function(datasetIndex, index) { + return this.getPixelForValue(0); + }, + getPointPixelForValue: function(value, datasetIndex, index) { + return this.getPixelForValue(value); + }, + getPixelForValue: function(value) { + return value * 2; + }, + max: 10, + min: -10, + } + } + }; + + var controller = new Chart.controllers.line(chart, 0); + controller.update(); + var point = chart.data.datasets[0].metaData[0]; + + chart.options.elements.point.backgroundColor = 'rgb(45, 46, 47)'; + chart.options.elements.point.borderColor = 'rgb(50, 51, 52)'; + chart.options.elements.point.borderWidth = 10.1; + chart.options.elements.point.radius = 1.01; + + controller.removeHoverStyle(point); + expect(point._model.backgroundColor).toBe('rgb(45, 46, 47)'); + expect(point._model.borderColor).toBe('rgb(50, 51, 52)'); + expect(point._model.borderWidth).toBe(10.1); + expect(point._model.radius).toBe(1.01); + + // Can set hover style per dataset + chart.data.datasets[0].radius = 3.3; + chart.data.datasets[0].pointBackgroundColor = 'rgb(77, 79, 81)'; + chart.data.datasets[0].pointBorderColor = 'rgb(123, 125, 127)'; + chart.data.datasets[0].pointBorderWidth = 2.1; + + controller.removeHoverStyle(point); + expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)'); + expect(point._model.borderColor).toBe('rgb(123, 125, 127)'); + expect(point._model.borderWidth).toBe(2.1); + expect(point._model.radius).toBe(3.3); + + // Custom style + point.custom = { + radius: 4.4, + borderWidth: 5.5, + backgroundColor: 'rgb(0, 0, 0)', + borderColor: 'rgb(10, 10, 10)' + }; + + controller.removeHoverStyle(point); + expect(point._model.backgroundColor).toBe('rgb(0, 0, 0)'); + expect(point._model.borderColor).toBe('rgb(10, 10, 10)'); + expect(point._model.borderWidth).toBe(5.5); + expect(point._model.radius).toBe(4.4); + }); +}); \ No newline at end of file From e681d8cf23238463416ff83a2eab7dba81b3e89e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 18:23:53 -0400 Subject: [PATCH 275/424] Better debug page reporting of failed tests --- karma.conf.js | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index cbf72b381ec..bce079624ae 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,6 +2,6 @@ module.exports = function(config) { config.set({ browsers: ['Chrome', 'Firefox'], frameworks: ['jasmine'], - reporters: ['progress'], + reporters: ['progress', 'html'], }); }; \ No newline at end of file diff --git a/package.json b/package.json index 066d6536941..0e7b319399b 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "karma-coverage": "^0.5.1", "karma-firefox-launcher": "^0.1.6", "karma-jasmine": "^0.3.6", + "karma-jasmine-html-reporter": "^0.1.8", "onecolor": "^2.5.0", "semver": "^3.0.1" }, From bb0a8991dff664d2b56cf420f8007547c3b88af5 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 20:17:24 -0400 Subject: [PATCH 276/424] Core element tests --- test/core.element.tests.js | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/core.element.tests.js diff --git a/test/core.element.tests.js b/test/core.element.tests.js new file mode 100644 index 00000000000..6443de099d0 --- /dev/null +++ b/test/core.element.tests.js @@ -0,0 +1,45 @@ +// Test the core element functionality +describe('Core element tests', function() { + it ('should transition model properties', function() { + var element = new Chart.Element({ + _model: { + numberProp: 0, + numberProp2: 100, + _underscoreProp: 0, + stringProp: 'abc', + objectProp: { + myObject: true + }, + colorProp: 'rgb(0, 0, 0)' + } + }); + + // First transition clones model into view + element.transition(0.25); + expect(element._view).toEqual(element._model); + expect(element._start).toEqual(element._model); // also cloned + + expect(element._view.objectProp).toBe(element._model.objectProp); // not cloned + expect(element._start.objectProp).toEqual(element._model.objectProp); // not cloned + + element._model.numberProp = 100; + element._model.numberProp2 = 250; + element._model._underscoreProp = 200; + element._model.stringProp = 'def' + element._model.newStringProp = 'newString'; + element._model.colorProp = 'rgb(255, 255, 0)' + + element.transition(0.25); + expect(element._view).toEqual({ + numberProp: 25, + numberProp2: 137.5, + _underscoreProp: 0, // underscore props are not transition to a new value + stringProp: 'def', + newStringProp: 'newString', + objectProp: { + myObject: true + }, + colorProp: 'rgb(64, 64, 0)', + }); + }); +}); \ No newline at end of file From 702b9553e7ed770830a991342215bdd8abb8dcf1 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 20:46:26 -0400 Subject: [PATCH 277/424] More helper tests --- test/core.helpers.tests.js | 53 ++++++++++++++++++++++++++++++++++++++ test/mockContext.js | 2 ++ 2 files changed, 55 insertions(+) diff --git a/test/core.helpers.tests.js b/test/core.helpers.tests.js index 730222b5b57..bbc7f4ab447 100644 --- a/test/core.helpers.tests.js +++ b/test/core.helpers.tests.js @@ -380,6 +380,59 @@ describe('Core helper tests', function() { expect(helpers.previousItem(testData, 0, true)).toEqual(2); expect(helpers.previousItem(testData, 2, false)).toEqual(1); expect(helpers.previousItem(testData, 1, true)).toEqual(0); + }); + + it ('should clear a canvas', function() { + var context = window.createMockContext(); + helpers.clear({ + width: 100, + height: 150, + ctx: context + }); + + expect(context.getCalls()).toEqual([{ + name: 'clearRect', + args: [0, 0, 100, 150] + }]); + }); + it ('should draw a rounded rectangle', function() { + var context = window.createMockContext(); + helpers.drawRoundedRectangle(context, 10, 20, 30, 40, 5); + + expect(context.getCalls()).toEqual([{ + name: 'beginPath', + args: [] + }, { + name: 'moveTo', + args: [15, 20] + }, { + name: 'lineTo', + args: [35, 20] + }, { + name: 'quadraticCurveTo', + args: [40, 20, 40, 25] + }, { + name: 'lineTo', + args: [40, 55] + }, { + name: 'quadraticCurveTo', + args: [40, 60, 35, 60] + }, { + name: 'lineTo', + args: [15, 60] + }, { + name: 'quadraticCurveTo', + args: [10, 60, 10, 55] + }, { + name: 'lineTo', + args: [10, 25] + }, { + name: 'quadraticCurveTo', + args: [10, 20, 15, 20] + }, { + name: 'closePath', + args: [] + }]) }); }); \ No newline at end of file diff --git a/test/mockContext.js b/test/mockContext.js index 239a0a3e48e..d8b8e41b8d0 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -65,10 +65,12 @@ arc: function() {}, beginPath: function() {}, bezierCurveTo: function() {}, + clearRect: function() {}, closePath: function() {}, fill: function() {}, lineTo: function(x, y) {}, moveTo: function(x, y) {}, + quadraticCurveTo: function() {}, restore: function() {}, save: function() {}, setLineDash: function() {}, From c8d585621696797aec1aeef037aa0725eecda9ed Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 21:49:39 -0400 Subject: [PATCH 278/424] Start testing the linear scale fit code --- src/scales/scale.linear.js | 10 ---------- test/mockContext.js | 6 +++++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index eaab69c6c30..94dd0a3ac52 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -329,16 +329,6 @@ return this.getPixelForValue(value); } - var offset = 0; - - for (var j = datasetIndex; j < this.data.datasets.length; j++) { - if (j === datasetIndex && value) { - offset += value; - } else { - offset = offset + value; - } - } - return this.getPixelForValue(value); }, diff --git a/test/mockContext.js b/test/mockContext.js index d8b8e41b8d0..8fa62436edf 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -69,6 +69,10 @@ closePath: function() {}, fill: function() {}, lineTo: function(x, y) {}, + measureText: function(text) { + // return the number of characters * fixed size + return text ? { width: text.length * 10 } : {width: 0}; + }, moveTo: function(x, y) {}, quadraticCurveTo: function() {}, restore: function() {}, @@ -82,7 +86,7 @@ var addMethod = function(name, method) { scope[methodName] = function() { scope.record(name, arguments); - method.apply(scope, arguments); + return method.apply(scope, arguments); }; } From 02e0f3f85657bbb85fd02c0d1a50ff50d07db619 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 21:50:41 -0400 Subject: [PATCH 279/424] Check some more data on the linear scale after fitting --- test/scale.linear.tests.js | 123 +++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js index f0ac83c392f..811876ab0d8 100644 --- a/test/scale.linear.tests.js +++ b/test/scale.linear.tests.js @@ -162,6 +162,47 @@ describe('Linear Scale', function() { expect(scale.max).toBe(1); }); + it ('should forcibly include 0 in the range if the beginAtZero option is used', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [20, 30, 40, 50] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + + + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + scale.generateTicks(400, 400); + expect(scale.ticks).toEqual([50, 45, 40, 35, 30, 25, 20]); + + config.beginAtZero = true; + scale.calculateRange(); + scale.generateTicks(400, 400); + expect(scale.ticks).toEqual([50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0]); + + mockData.datasets[0].data = [-20, -30, -40, -50]; + scale.calculateRange(); + scale.generateTicks(400, 400); + expect(scale.ticks).toEqual([0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50]); + + config.beginAtZero = false; + scale.calculateRange(); + scale.generateTicks(400, 400); + expect(scale.ticks).toEqual([-20, -25, -30, -35, -40, -45, -50]); + }); + it ('Should generate tick marks', function() { var scaleID = 'myScale'; @@ -406,4 +447,86 @@ describe('Linear Scale', function() { expect(horizontalScale.getPointPixelForValue(-2, 0, 0)).toBe(5); // left + paddingLeft expect(horizontalScale.getPointPixelForValue(0, 0, 0)).toBe(55); // halfway }); + + it ('should get the correct pixel value for a bar', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [-5, 0, 2, -3, 5] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var verticalScale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + verticalScale.calculateRange(); + verticalScale.generateTicks(50, 100); + + // Fake out positioning of the scale service + verticalScale.left = 0; + verticalScale.top = 0; + verticalScale.right = 50; + verticalScale.bottom = 110; + verticalScale.paddingTop = 5; + verticalScale.paddingBottom = 5; + verticalScale.width = 50; + verticalScale.height = 110; + + expect(verticalScale.calculateBarBase()).toBe(56); // 0 point + expect(verticalScale.calculateBarY(0, 0)).toBe(96.66666666666667); // bottom + }); + + it ('should fit correctly', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [-5, 0, 2, -3, 5] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var verticalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = verticalScale.fit(100, 300); + expect(minSize).toEqual({ + width: 33, + height: 300, + }); + expect(verticalScale.width).toBe(33); + expect(verticalScale.height).toBe(300); + expect(verticalScale.paddingTop).toBe(6); + expect(verticalScale.paddingBottom).toBe(6); + expect(verticalScale.paddingLeft).toBe(0); + expect(verticalScale.paddingRight).toBe(0); + + // Refit with margins to see the padding go away + minSize = verticalScale.fit(33, 300, {left: 0, right: 0, top: 15, bottom: 3}); + expect(minSize).toEqual({ + width: 33, + height: 300, + }); + expect(verticalScale.paddingTop).toBe(0); + expect(verticalScale.paddingBottom).toBe(3); + expect(verticalScale.paddingLeft).toBe(0); + expect(verticalScale.paddingRight).toBe(0); + }); }); \ No newline at end of file From 54858b921d2fbe67f02bfad95fde7abe68b1ecc0 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 31 Aug 2015 20:42:29 -0400 Subject: [PATCH 280/424] More linear scale tests --- test/mockContext.js | 5 + test/scale.linear.tests.js | 849 ++++++++++++++++++++++++++++++++++--- 2 files changed, 791 insertions(+), 63 deletions(-) diff --git a/test/mockContext.js b/test/mockContext.js index 8fa62436edf..5f42c719cd1 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -68,6 +68,7 @@ clearRect: function() {}, closePath: function() {}, fill: function() {}, + fillText: function() {}, lineTo: function(x, y) {}, measureText: function(text) { // return the number of characters * fixed size @@ -108,6 +109,10 @@ return this._calls; } + Context.prototype.resetCalls = function() { + this._calls = []; + }; + window.createMockContext = function() { return new Context(); }; diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js index 811876ab0d8..94970d4c17f 100644 --- a/test/scale.linear.tests.js +++ b/test/scale.linear.tests.js @@ -1,12 +1,12 @@ describe('Linear Scale', function() { - it ('Should register the constructor with the scale service', function() { + it('Should register the constructor with the scale service', function() { var Constructor = Chart.scaleService.getScaleConstructor('linear'); expect(Constructor).not.toBe(undefined); expect(typeof Constructor).toBe('function'); }); - it ('Should have the correct default config', function() { + it('Should have the correct default config', function() { var defaultConfig = Chart.scaleService.getScaleDefaults('linear'); expect(defaultConfig).toEqual({ display: true, @@ -36,21 +36,20 @@ describe('Linear Scale', function() { }); }); - it ('Should correctly determine the max & min data values', function() { + it('Should correctly determine the max & min data values', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ - yAxisID: scaleID, - data: [10, 5, 0, -5, 78, -100] - }, { - yAxisID: 'second scale', - data: [-1000, 1000], - }, { - yAxisID: scaleID, - data: [150] - } - ] + yAxisID: scaleID, + data: [10, 5, 0, -5, 78, -100] + }, { + yAxisID: 'second scale', + data: [-1000, 1000], + }, { + yAxisID: scaleID, + data: [150] + }] }; var Constructor = Chart.scaleService.getScaleConstructor('linear'); @@ -70,14 +69,26 @@ describe('Linear Scale', function() { expect(scale.max).toBe(150); }); - it ('Should correctly determine the max & min for scatter data', function() { + it('Should correctly determine the max & min for scatter data', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ xAxisID: scaleID, // for the horizontal scale yAxisID: scaleID, - data: [{x: 10, y: 100}, {x: -10, y: 0}, {x: 0, y: 0}, {x: 99, y: 7}] + data: [{ + x: 10, + y: 100 + }, { + x: -10, + y: 0 + }, { + x: 0, + y: 0 + }, { + x: 99, + y: 7 + }] }] }; @@ -108,21 +119,20 @@ describe('Linear Scale', function() { expect(horizontalScale.max).toBe(99); }); - it ('Should correctly determine the min and max data values when stacked mode is turned on', function() { + it('Should correctly determine the min and max data values when stacked mode is turned on', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ - yAxisID: scaleID, - data: [10, 5, 0, -5, 78, -100] - }, { - yAxisID: 'second scale', - data: [-1000, 1000], - }, { - yAxisID: scaleID, - data: [150, 0, 0, -100, -10, 9] - } - ] + yAxisID: scaleID, + data: [10, 5, 0, -5, 78, -100] + }, { + yAxisID: 'second scale', + data: [-1000, 1000], + }, { + yAxisID: scaleID, + data: [150, 0, 0, -100, -10, 9] + }] }; var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); @@ -141,7 +151,7 @@ describe('Linear Scale', function() { expect(scale.max).toBe(160); }); - it ('Should ensure that the scale has a max and min that are not equal', function() { + it('Should ensure that the scale has a max and min that are not equal', function() { var scaleID = 'myScale'; var mockData = { @@ -162,7 +172,7 @@ describe('Linear Scale', function() { expect(scale.max).toBe(1); }); - it ('should forcibly include 0 in the range if the beginAtZero option is used', function() { + it('should forcibly include 0 in the range if the beginAtZero option is used', function() { var scaleID = 'myScale'; var mockData = { @@ -173,7 +183,7 @@ describe('Linear Scale', function() { }; var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); - + var Constructor = Chart.scaleService.getScaleConstructor('linear'); var scale = new Constructor({ @@ -203,15 +213,14 @@ describe('Linear Scale', function() { expect(scale.ticks).toEqual([-20, -25, -30, -35, -40, -45, -50]); }); - it ('Should generate tick marks', function() { + it('Should generate tick marks', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ - yAxisID: scaleID, - data: [10, 5, 0, 25, 78] - }, - ] + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, ] }; var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); @@ -229,7 +238,7 @@ describe('Linear Scale', function() { // Large enough to be unimportant var maxWidth = 400; - var maxHeight = 400; + var maxHeight = 400; scale.generateTicks(maxWidth, maxHeight); // Counts down because the lines are drawn top to bottom @@ -238,15 +247,14 @@ describe('Linear Scale', function() { expect(scale.end).toBe(80); }); - it ('Should generate tick marks in the correct order in reversed mode', function() { + it('Should generate tick marks in the correct order in reversed mode', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ - yAxisID: scaleID, - data: [10, 5, 0, 25, 78] - }, - ] + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, ] }; var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); @@ -265,7 +273,7 @@ describe('Linear Scale', function() { // Large enough to be unimportant var maxWidth = 400; - var maxHeight = 400; + var maxHeight = 400; scale.generateTicks(maxWidth, maxHeight); // Reverse mode makes this count up @@ -274,15 +282,14 @@ describe('Linear Scale', function() { expect(scale.end).toBe(0); }); - it ('Should generate tick marks using the user supplied options', function() { + it('Should generate tick marks using the user supplied options', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ - yAxisID: scaleID, - data: [10, 5, 0, 25, 78] - }, - ] + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, ] }; var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); @@ -304,7 +311,7 @@ describe('Linear Scale', function() { // Large enough to be unimportant var maxWidth = 400; - var maxHeight = 400; + var maxHeight = 400; scale.generateTicks(maxWidth, maxHeight); expect(scale.ticks).toEqual([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]); @@ -312,15 +319,14 @@ describe('Linear Scale', function() { expect(scale.end).toBe(100); }); - it ('Should build labels using the default template', function() { + it('Should build labels using the default template', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ - yAxisID: scaleID, - data: [10, 5, 0, 25, 78] - }, - ] + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, ] }; var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); @@ -336,7 +342,7 @@ describe('Linear Scale', function() { // Large enough to be unimportant var maxWidth = 400; - var maxHeight = 400; + var maxHeight = 400; scale.generateTicks(maxWidth, maxHeight); // Generate labels @@ -345,15 +351,14 @@ describe('Linear Scale', function() { expect(scale.labels).toEqual(['80', '70', '60', '50', '40', '30', '20', '10', '0']); }); - it ('Should build labels using the user supplied callback', function() { + it('Should build labels using the user supplied callback', function() { var scaleID = 'myScale'; var mockData = { datasets: [{ - yAxisID: scaleID, - data: [10, 5, 0, 25, 78] - }, - ] + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, ] }; var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); @@ -373,7 +378,7 @@ describe('Linear Scale', function() { // Large enough to be unimportant var maxWidth = 400; - var maxHeight = 400; + var maxHeight = 400; scale.generateTicks(maxWidth, maxHeight); // Generate labels @@ -383,7 +388,7 @@ describe('Linear Scale', function() { expect(scale.labels).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8']); }); - it ('Should get the correct pixel value for a point', function() { + it('Should get the correct pixel value for a point', function() { var scaleID = 'myScale'; var mockData = { @@ -448,7 +453,7 @@ describe('Linear Scale', function() { expect(horizontalScale.getPointPixelForValue(0, 0, 0)).toBe(55); // halfway }); - it ('should get the correct pixel value for a bar', function() { + it('should get the correct pixel value for a bar', function() { var scaleID = 'myScale'; var mockData = { @@ -485,7 +490,7 @@ describe('Linear Scale', function() { expect(verticalScale.calculateBarY(0, 0)).toBe(96.66666666666667); // bottom }); - it ('should fit correctly', function() { + it('should fit correctly', function() { var scaleID = 'myScale'; var mockData = { @@ -519,7 +524,12 @@ describe('Linear Scale', function() { expect(verticalScale.paddingRight).toBe(0); // Refit with margins to see the padding go away - minSize = verticalScale.fit(33, 300, {left: 0, right: 0, top: 15, bottom: 3}); + minSize = verticalScale.fit(33, 300, { + left: 0, + right: 0, + top: 15, + bottom: 3 + }); expect(minSize).toEqual({ width: 33, height: 300, @@ -529,4 +539,717 @@ describe('Linear Scale', function() { expect(verticalScale.paddingLeft).toBe(0); expect(verticalScale.paddingRight).toBe(0); }); + + it('should fit correctly when horizontal', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [-5, 0, 2, -3, 5] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + config.position = "bottom"; + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var verticalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = verticalScale.fit(100, 300); + expect(minSize).toEqual({ + width: 100, + height: 28, + }); + expect(verticalScale.width).toBe(100); + expect(verticalScale.height).toBe(28); + expect(verticalScale.paddingTop).toBe(0); + expect(verticalScale.paddingBottom).toBe(0); + expect(verticalScale.paddingLeft).toBe(15); + expect(verticalScale.paddingRight).toBe(10); + + // Refit with margins to see the padding go away + minSize = verticalScale.fit(100, 28, { + left: 10, + right: 6, + top: 15, + bottom: 3 + }); + expect(minSize).toEqual({ + width: 100, + height: 28, + }); + expect(verticalScale.paddingTop).toBe(0); + expect(verticalScale.paddingBottom).toBe(0); + expect(verticalScale.paddingLeft).toBe(5); + expect(verticalScale.paddingRight).toBe(4); + }); + + it('should draw correctly horizontally', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [-5, 0, 2, -3, 5] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + config.position = "bottom"; + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var horizontalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = horizontalScale.fit(100, 300); + minSize = horizontalScale.fit(100, 28, { + left: 10, + right: 6, + top: 15, + bottom: 3 + }); + + horizontalScale.left = 0; + horizontalScale.right = minSize.width; + horizontalScale.top = 0; + horizontalScale.bottom = minSize.height; + + var chartArea = { + top: 100, + bottom: 0, + left: 0, + right: minSize.width + }; + horizontalScale.draw(chartArea); + + expect(mockContext.getCalls()).toEqual([{ + "name": "measureText", + "args": ["-10"] + }, { + "name": "measureText", + "args": ["10"] + }, { + "name": "measureText", + "args": ["-10"] + }, { + "name": "measureText", + "args": ["10"] + }, { + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [5.5, 0] + }, { + "name": "lineTo", + "args": [5.5, 5] + }, { + "name": "moveTo", + "args": [5.5, 100] + }, { + "name": "lineTo", + "args": [5.5, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [51, 0] + }, { + "name": "lineTo", + "args": [51, 5] + }, { + "name": "moveTo", + "args": [51, 100] + }, { + "name": "lineTo", + "args": [51, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [96.5, 0] + }, { + "name": "lineTo", + "args": [96.5, 5] + }, { + "name": "moveTo", + "args": [96.5, 100] + }, { + "name": "lineTo", + "args": [96.5, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "fillText", + "args": ["-10", 5, 10] + }, { + "name": "fillText", + "args": ["0", 50.5, 10] + }, { + "name": "fillText", + "args": ["10", 96, 10] + }]); + + // Turn off some drawing + config.gridLines.drawTicks = false; + config.gridLines.drawOnChartArea = false; + config.labels.show = false; + + mockContext.resetCalls(); + + horizontalScale.draw(); + expect(mockContext.getCalls()).toEqual([{ + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }]); + + // Turn off displat + + mockContext.resetCalls(); + config.display = false; + horizontalScale.draw(); + expect(mockContext.getCalls()).toEqual([]); + }); + + it('should draw correctly vertically', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [-5, 0, 2, -3, 5] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear')); + var Constructor = Chart.scaleService.getScaleConstructor('linear'); + var verticalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = verticalScale.fit(100, 300); + minSize = verticalScale.fit(33, 300, { + left: 0, + right: 0, + top: 15, + bottom: 3 + }); + expect(minSize).toEqual({ + width: 33, + height: 300, + }); + + verticalScale.left = 0; + verticalScale.right = minSize.width; + verticalScale.top = 0; + verticalScale.bottom = minSize.height; + + var chartArea = { + top: 0, + bottom: minSize.height, + left: minSize.width, + right: minSize.width + 100 + }; + verticalScale.draw(chartArea); + + expect(mockContext.getCalls()).toEqual([{ + "name": "measureText", + "args": ["5"] + }, { + "name": "measureText", + "args": ["4"] + }, { + "name": "measureText", + "args": ["3"] + }, { + "name": "measureText", + "args": ["2"] + }, { + "name": "measureText", + "args": ["1"] + }, { + "name": "measureText", + "args": ["0"] + }, { + "name": "measureText", + "args": ["-1"] + }, { + "name": "measureText", + "args": ["-2"] + }, { + "name": "measureText", + "args": ["-3"] + }, { + "name": "measureText", + "args": ["-4"] + }, { + "name": "measureText", + "args": ["-5"] + }, { + "name": "measureText", + "args": ["5"] + }, { + "name": "measureText", + "args": ["4"] + }, { + "name": "measureText", + "args": ["3"] + }, { + "name": "measureText", + "args": ["2"] + }, { + "name": "measureText", + "args": ["1"] + }, { + "name": "measureText", + "args": ["0"] + }, { + "name": "measureText", + "args": ["-1"] + }, { + "name": "measureText", + "args": ["-2"] + }, { + "name": "measureText", + "args": ["-3"] + }, { + "name": "measureText", + "args": ["-4"] + }, { + "name": "measureText", + "args": ["-5"] + }, { + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 0.5] + }, { + "name": "lineTo", + "args": [33, 0.5] + }, { + "name": "moveTo", + "args": [33, 0.5] + }, { + "name": "lineTo", + "args": [133, 0.5] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 30.19999999999999] + }, { + "name": "lineTo", + "args": [33, 30.19999999999999] + }, { + "name": "moveTo", + "args": [33, 30.19999999999999] + }, { + "name": "lineTo", + "args": [133, 30.19999999999999] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 59.900000000000006] + }, { + "name": "lineTo", + "args": [33, 59.900000000000006] + }, { + "name": "moveTo", + "args": [33, 59.900000000000006] + }, { + "name": "lineTo", + "args": [133, 59.900000000000006] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 89.6] + }, { + "name": "lineTo", + "args": [33, 89.6] + }, { + "name": "moveTo", + "args": [33, 89.6] + }, { + "name": "lineTo", + "args": [133, 89.6] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 119.30000000000001] + }, { + "name": "lineTo", + "args": [33, 119.30000000000001] + }, { + "name": "moveTo", + "args": [33, 119.30000000000001] + }, { + "name": "lineTo", + "args": [133, 119.30000000000001] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 149] + }, { + "name": "lineTo", + "args": [33, 149] + }, { + "name": "moveTo", + "args": [33, 149] + }, { + "name": "lineTo", + "args": [133, 149] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 178.7] + }, { + "name": "lineTo", + "args": [33, 178.7] + }, { + "name": "moveTo", + "args": [33, 178.7] + }, { + "name": "lineTo", + "args": [133, 178.7] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 208.4] + }, { + "name": "lineTo", + "args": [33, 208.4] + }, { + "name": "moveTo", + "args": [33, 208.4] + }, { + "name": "lineTo", + "args": [133, 208.4] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 238.1] + }, { + "name": "lineTo", + "args": [33, 238.1] + }, { + "name": "moveTo", + "args": [33, 238.1] + }, { + "name": "lineTo", + "args": [133, 238.1] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 267.8] + }, { + "name": "lineTo", + "args": [33, 267.8] + }, { + "name": "moveTo", + "args": [33, 267.8] + }, { + "name": "lineTo", + "args": [133, 267.8] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 297.5] + }, { + "name": "lineTo", + "args": [33, 297.5] + }, { + "name": "moveTo", + "args": [33, 297.5] + }, { + "name": "lineTo", + "args": [133, 297.5] + }, { + "name": "stroke", + "args": [] + }, { + "name": "fillText", + "args": ["5", 23, 0] + }, { + "name": "fillText", + "args": ["4", 23, 29.69999999999999] + }, { + "name": "fillText", + "args": ["3", 23, 59.400000000000006] + }, { + "name": "fillText", + "args": ["2", 23, 89.1] + }, { + "name": "fillText", + "args": ["1", 23, 118.80000000000001] + }, { + "name": "fillText", + "args": ["0", 23, 148.5] + }, { + "name": "fillText", + "args": ["-1", 23, 178.2] + }, { + "name": "fillText", + "args": ["-2", 23, 207.9] + }, { + "name": "fillText", + "args": ["-3", 23, 237.6] + }, { + "name": "fillText", + "args": ["-4", 23, 267.3] + }, { + "name": "fillText", + "args": ["-5", 23, 297] + }]); + + // Turn off some drawing + config.gridLines.drawTicks = false; + config.gridLines.drawOnChartArea = false; + config.labels.show = false; + + mockContext.resetCalls(); + + verticalScale.draw(); + expect(mockContext.getCalls()).toEqual([{ + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }]); + }); }); \ No newline at end of file From eabdbab89e90309172755ec851c57a6f0ee9c558 Mon Sep 17 00:00:00 2001 From: etimberg Date: Mon, 31 Aug 2015 21:49:51 -0400 Subject: [PATCH 281/424] If the element has a label, use that in the tooltip instead of the dataset label. --- src/core/core.tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 90539681a64..3f4a892c41a 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -80,7 +80,7 @@ // These variables are available in the template function. Add others here element: this._active[0], value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], - label: this._data.labels ? this._data.labels[this._active[0]._index] : '', + label: this._active[0]._model.label !== undefined ? this._active[0]._model.label : this._data.labels ? this._data.labels[this._active[0]._index] : '', }), }); From 9cc2c18059112fb1b33c5fbd6a9fb3505b2c6944 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 1 Sep 2015 18:12:37 -0400 Subject: [PATCH 282/424] Latest built changes --- Chart.js | 358 ++++++++++++++++++++++++--------------------------- Chart.min.js | 12 +- 2 files changed, 171 insertions(+), 199 deletions(-) diff --git a/Chart.js b/Chart.js index 2a33c6d1d78..35a27e8dbbe 100644 --- a/Chart.js +++ b/Chart.js @@ -166,12 +166,6 @@ }); return base; }, - merge = helpers.merge = function(base, master) { - //Merge properties in left object over to a shallow clone of object right. - var args = Array.prototype.slice.call(arguments, 0); - args.unshift({}); - return extend.apply(null, args); - }, // Need a special merge function to chart configs since they are now grouped configMerge = helpers.configMerge = function(_base) { var base = clone(_base); @@ -193,7 +187,13 @@ helpers.each(value, function(valueObj, index) { if (index < baseArray.length) { - baseArray[index] = helpers.configMerge(baseArray[index], valueObj); + if (typeof baseArray[index] == 'object' && baseArray[index] !== null && typeof valueObj == 'object' && valueObj !== null) { + // Two objects are coming together. Do a merge of them. + baseArray[index] = helpers.configMerge(baseArray[index], valueObj); + } else { + // Just overwrite in this case since there is nothing to merge + baseArray[index] = valueObj; + } } else { baseArray.push(valueObj); // nothing to merge } @@ -252,12 +252,12 @@ return base; }, getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault = function(value, index, defaultValue) { - if (!value) { + if (value === undefined || value === null) { return defaultValue; } - if (helpers.isArray(value) && index < value.length) { - return value[index]; + if (helpers.isArray(value)) { + return index < value.length ? value[index] : defaultValue; } return value; @@ -285,7 +285,7 @@ }, findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) { // Default to start of the array - if (!startIndex) { + if (startIndex === undefined || startIndex === null) { startIndex = -1; } for (var i = startIndex + 1; i < arrayToSearch.length; i++) { @@ -297,7 +297,7 @@ }, findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) { // Default to end of the array - if (!startIndex) { + if (startIndex === undefined || startIndex === null) { startIndex = arrayToSearch.length; } for (var i = startIndex - 1; i >= 0; i--) { @@ -368,18 +368,6 @@ return Math.log(x) / Math.LN10; } }, - cap = helpers.cap = function(valueToCap, maxValue, minValue) { - if (isNumber(maxValue)) { - if (valueToCap > maxValue) { - return maxValue; - } - } else if (isNumber(minValue)) { - if (valueToCap < minValue) { - return minValue; - } - } - return valueToCap; - }, getDecimalPlaces = helpers.getDecimalPlaces = function(num) { if (num % 1 !== 0 && isNumber(num)) { var s = num.toString(); @@ -444,94 +432,16 @@ }, nextItem = helpers.nextItem = function(collection, index, loop) { if (loop) { - return collection[index + 1] || collection[0]; + return index >= collection.length - 1 ? collection[0] : collection[index + 1]; } - return collection[index + 1] || collection[collection.length - 1]; + + return index >= collection.length - 1 ? collection[collection.length - 1] : collection[index + 1]; }, previousItem = helpers.previousItem = function(collection, index, loop) { if (loop) { - return collection[index - 1] || collection[collection.length - 1]; - } - return collection[index - 1] || collection[0]; - }, - calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) { - return Math.floor(Math.log(val) / Math.LN10); - }, - calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) { - - //Set a minimum step of two - a point at the top of the graph, and a point at the base - var minSteps = 2, - maxSteps = Math.floor(drawingSize / (textSize * 1.5)), - skipFitting = (minSteps >= maxSteps); - - var maxValue = max(valuesArray), - minValue = min(valuesArray); - - // We need some degree of seperation here to calculate the scales if all the values are the same - // Adding/minusing 0.5 will give us a range of 1. - if (maxValue === minValue) { - maxValue += 0.5; - // So we don't end up with a graph with a negative start value if we've said always start from zero - if (minValue >= 0.5 && !startFromZero) { - minValue -= 0.5; - } else { - // Make up a whole number above the values - maxValue += 0.5; - } - } - - var valueRange = Math.abs(maxValue - minValue), - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange), - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude), - graphRange = graphMax - graphMin, - stepValue = Math.pow(10, rangeOrderOfMagnitude), - numberOfSteps = Math.round(graphRange / stepValue); - - //If we have more space on the graph we'll use it to give more definition to the data - while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) { - if (numberOfSteps > maxSteps) { - stepValue *= 2; - numberOfSteps = Math.round(graphRange / stepValue); - // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps. - if (numberOfSteps % 1 !== 0) { - skipFitting = true; - } - } - //We can fit in double the amount of scale points on the scale - else { - //If user has declared ints only, and the step value isn't a decimal - if (integersOnly && rangeOrderOfMagnitude >= 0) { - //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float - if (stepValue / 2 % 1 === 0) { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - //If it would make it a float break out of the loop - else { - break; - } - } - //If the scale doesn't have to be an int, make the scale more granular anyway. - else { - stepValue /= 2; - numberOfSteps = Math.round(graphRange / stepValue); - } - - } - } - - if (skipFitting) { - numberOfSteps = minSteps; - stepValue = graphRange / numberOfSteps; + return index <= 0 ? collection[collection.length - 1] : collection[index - 1]; } - return { - steps: numberOfSteps, - stepValue: stepValue, - min: graphMin, - max: graphMin + (numberOfSteps * stepValue) - }; - + return index <= 0 ? collection[0] : collection[index - 1]; }, // Implementation of the nice number algorithm used in determining where axis labels will go niceNum = helpers.niceNum = function(range, round) { @@ -567,6 +477,7 @@ // Blows up jshint errors based on the new Function constructor //Templating methods //Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/ + templateStringCache = {}, template = helpers.template = function(templateString, valuesObject) { // If templateString is function rather than string-template - call the function for valuesObject @@ -575,17 +486,17 @@ return templateString(valuesObject); } - var cache = {}; - function tmpl(str, data) { // Figure out if we're getting a template, or if we need to // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] : + var fn; + if (templateStringCache.hasOwnProperty(str)) { + fn = templateStringCache[str]; + } else { // Generate a reusable function that will serve as a template // generator (and which will be cached). - new Function("obj", + fn = new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + // Introduce the data as local variables using with(){} @@ -603,23 +514,16 @@ "');}return p.join('');" ); + // Cache the result + templateStringCache[str] = fn; + } + // Provide some basic currying to the user return data ? fn(data) : fn; } return tmpl(templateString, valuesObject); }, /* jshint ignore:end */ - generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) { - var labelsArray = new Array(numberOfSteps); - if (templateString) { - each(labelsArray, function(val, index) { - labelsArray[index] = template(templateString, { - value: (graphMin + (stepValue * (index + 1))) - }); - }); - } - return labelsArray; - }, //--Animation methods //Easing functions adapted from Robert Penner's easing equations //http://www.robertpenner.com/easing/ @@ -2068,7 +1972,7 @@ // These variables are available in the template function. Add others here element: this._active[0], value: this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index], - label: this._data.labels ? this._data.labels[this._active[0]._index] : '', + label: this._active[0]._model.label !== undefined ? this._active[0]._model.label : this._data.labels ? this._data.labels[this._active[0]._index] : '', }), }); @@ -2393,6 +2297,21 @@ return this.chart.scales[scaleID]; }, + // Get the number of datasets that display bars. We use this to correctly calculate the bar width + getBarCount: function getBarCount() { + var barCount = 0; + + helpers.each(this.chart.data.datasets, function(dataset) { + if (dataset.type === 'bar') { + ++barCount; + } else if (dataset.type === undefined && this.chart.config.type === 'bar') { + ++barCount; + } + }, this); + + return barCount; + }, + addElements: function() { this.getDataset().metaData = this.getDataset().metaData || []; helpers.each(this.getDataset().data, function(value, index) { @@ -2410,7 +2329,10 @@ _datasetIndex: this.index, _index: index, }); - this.updateElement(rectangle, index, true); + + var numBars = this.getBarCount(); + + this.updateElement(rectangle, index, true, numBars); this.getDataset().metaData.splice(index, 0, rectangle); }, removeElement: function(index) { @@ -2422,12 +2344,28 @@ }, update: function(reset) { + var numBars = this.getBarCount(); + + var numData = this.getDataset().data.length; + var numRectangles = this.getDataset().metaData.length; + + // Make sure that we handle number of datapoints changing + if (numData < numRectangles) { + // Remove excess bars for data points that have been removed + this.getDataset().metaData.splice(numData, numRectangles - numData) + } else if (numData > numRectangles) { + // Add new elements + for (var index = numRectangles; index < numData; ++index) { + this.addElementAndReset(index); + } + } + helpers.each(this.getDataset().metaData, function(rectangle, index) { - this.updateElement(rectangle, index, reset); + this.updateElement(rectangle, index, reset, numBars); }, this); }, - updateElement: function updateElement(rectangle, index, reset) { + updateElement: function updateElement(rectangle, index, reset, numBars) { var xScale = this.getScaleForId(this.getDataset().xAxisID); var yScale = this.getScaleForId(this.getDataset().yAxisID); var yScalePoint; @@ -2452,7 +2390,7 @@ // Desired view properties _model: { - x: xScale.calculateBarX(this.chart.data.datasets.length, this.index, index), + x: xScale.calculateBarX(numBars, this.index, index), y: reset ? yScalePoint : yScale.calculateBarY(this.index, index), // Tooltip @@ -2461,7 +2399,7 @@ // Appearance base: yScale.calculateBarBase(this.index, index), - width: xScale.calculateBarWidth(this.chart.data.datasets.length), + width: xScale.calculateBarWidth(numBars), backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor), borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor), borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth), @@ -2483,7 +2421,7 @@ rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth); + rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, rectangle._model.borderWidth); }, removeHoverStyle: function(rectangle) { @@ -2552,10 +2490,6 @@ return this.chart.data.datasets[this.index]; }, - getScaleForId: function(scaleID) { - return this.chart.scales[scaleID]; - }, - addElements: function() { this.getDataset().metaData = this.getDataset().metaData || []; helpers.each(this.getDataset().data, function(value, index) { @@ -2574,7 +2508,9 @@ _index: index, }); - this.getDataset().backgroundColor.splice(index, 0, colorForNewElement); + if (colorForNewElement && helpers.isArray(this.getDataset().backgroundColor)) { + this.getDataset().backgroundColor.splice(index, 0, colorForNewElement); + } // Reset the point this.updateElement(arc, index, true); @@ -2595,7 +2531,6 @@ this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; - this.getDataset().total = 0; helpers.each(this.getDataset().data, function(value) { this.getDataset().total += Math.abs(value); @@ -2604,6 +2539,21 @@ this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index); this.innerRadius = this.outerRadius - this.chart.radiusLength; + // Make sure we have metaData for each data point + var numData = this.getDataset().data.length; + var numArcs = this.getDataset().metaData.length; + + // Make sure that we handle number of datapoints changing + if (numData < numArcs) { + // Remove excess bars for data points that have been removed + this.getDataset().metaData.splice(numData, numArcs - numData) + } else if (numData > numArcs) { + // Add new elements + for (var index = numArcs; index < numData; ++index) { + this.addElementAndReset(index); + } + } + helpers.each(this.getDataset().metaData, function(arc, index) { this.updateElement(arc, index, reset); }, this); @@ -2668,15 +2618,13 @@ }, this); }, - - setHoverStyle: function(arc) { var dataset = this.chart.data.datasets[arc._datasetIndex]; var index = arc._index; arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(arc._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, arc._model.borderWidth); + arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, arc._model.borderWidth); }, removeHoverStyle: function(arc) { @@ -2812,6 +2760,21 @@ var xScale = this.getScaleForId(this.getDataset().xAxisID); var scaleBase; + // Handle the number of data points changing + var numData = this.getDataset().data.length; + var numPoints = this.getDataset().metaData.length; + + // Make sure that we handle number of datapoints changing + if (numData < numPoints) { + // Remove excess bars for data points that have been removed + this.getDataset().metaData.splice(numData, numPoints - numData) + } else if (numData > numPoints) { + // Add new elements + for (var index = numPoints; index < numData; ++index) { + this.addElementAndReset(index); + } + } + if (yScale.min < 0 && yScale.max < 0) { scaleBase = yScale.getPixelForValue(yScale.max); } else if (yScale.min > 0 && yScale.max > 0) { @@ -2883,7 +2846,7 @@ x: xScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), y: reset ? scaleBase : yScale.getPointPixelForValue(this.getDataset().data[index], index, this.index), // Appearance - tension: point.custom && point.custom.tension ? point.custom.tension : this.chart.options.elements.line.tension, + tension: point.custom && point.custom.tension ? point.custom.tension : (this.getDataset().tension || this.chart.options.elements.line.tension), radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius), backgroundColor: point.custom && point.custom.backgroundColor ? point.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor, index, this.chart.options.elements.point.backgroundColor), borderColor: point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor), @@ -2956,10 +2919,10 @@ var dataset = this.chart.data.datasets[point._datasetIndex]; var index = point._index; - point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); + point._model.radius = point.custom && point.custom.hoverRadius ? point.custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); point._model.backgroundColor = point.custom && point.custom.hoverBackgroundColor ? point.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.color(point._model.backgroundColor).saturate(0.5).darken(0.1).rgbString()); point._model.borderColor = point.custom && point.custom.hoverBorderColor ? point.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.color(point._model.borderColor).saturate(0.5).darken(0.1).rgbString()); - point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, point._model.borderWidth); + point._model.borderWidth = point.custom && point.custom.hoverBorderWidth ? point.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, point._model.borderWidth); }, removeHoverStyle: function(point) { @@ -2971,11 +2934,7 @@ point._model.borderColor = point.custom && point.custom.borderColor ? point.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderColor, index, this.chart.options.elements.point.borderColor); point._model.borderWidth = point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth, index, this.chart.options.elements.point.borderWidth); } - }); - - - }).call(this); (function() { @@ -3518,19 +3477,19 @@ calculateBaseWidth: function() { return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); }, - calculateBarWidth: function(datasetCount) { + calculateBarWidth: function(barDatasetCount) { //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset - var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * this.options.spacing); + var baseWidth = this.calculateBaseWidth() - ((barDatasetCount - 1) * this.options.spacing); if (this.options.stacked) { return baseWidth; } - return (baseWidth / datasetCount); + return (baseWidth / barDatasetCount); }, - calculateBarX: function(datasetCount, datasetIndex, elementIndex) { + calculateBarX: function(barDatasetCount, datasetIndex, elementIndex) { var xWidth = this.calculateBaseWidth(), xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), - barWidth = this.calculateBarWidth(datasetCount); + barWidth = this.calculateBarWidth(barDatasetCount); if (this.options.stacked) { return xAbsolute + barWidth / 2; @@ -3569,7 +3528,7 @@ var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; //Max label rotation can be set or default to 90 - also act as a loop counter - while (this.labelWidth > (datasetWidth + this.paddingLeft) && this.labelRotation <= this.options.labels.maxRotation) { + while (this.labelWidth > datasetWidth && this.labelRotation <= this.options.labels.maxRotation) { cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); @@ -3635,13 +3594,14 @@ if (this.isHorizontal()) { minSize.width = maxWidth; } else if (this.options.display) { - minSize.width = Math.min(longestLabelWidth + 6, maxWidth); + var labelWidth = this.options.labels.show ? longestLabelWidth + 6 : 0; + minSize.width = Math.min(labelWidth, maxWidth); } // Height if (this.isHorizontal() && this.options.display) { var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; - minSize.height = Math.min(labelHeight, maxHeight); + minSize.height = Math.min(this.options.labels.show ? labelHeight : 0, maxHeight); } else if (this.options.display) { minSize.height = maxHeight; } @@ -3672,7 +3632,8 @@ } helpers.each(this.labels, function(label, index) { - if (skipRatio > 1 && index % skipRatio > 0) { + // Blank labels + if ((skipRatio > 1 && index % skipRatio > 0) || (label === undefined || label === null)) { return; } var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines @@ -3894,7 +3855,7 @@ }, // Get the correct value. If the value type is object get the x or y based on whether we are horizontal or not getRightValue: function(rawValue) { - return typeof rawValue === "object" ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; + return (typeof (rawValue) === "object" && rawValue !== null) ? (this.isHorizontal() ? rawValue.x : rawValue.y) : rawValue; }, getPixelForValue: function(value) { // This must be called after fit has been run so that @@ -3909,8 +3870,7 @@ } else { // Bottom - top since pixels increase downard on a screen var innerHeight = this.height - (this.paddingTop + this.paddingBottom); - pixel = this.bottom - (innerHeight / range * (value - this.start)); - pixel += this.paddingTop; + pixel = (this.bottom - this.paddingBottom) - (innerHeight / range * (value - this.start)); } return pixel; @@ -4067,16 +4027,6 @@ return this.getPixelForValue(value); } - var offset = 0; - - for (var j = datasetIndex; j < this.data.datasets.length; j++) { - if (j === datasetIndex && value) { - offset += value; - } else { - offset = offset + value; - } - } - return this.getPixelForValue(value); }, @@ -4848,21 +4798,24 @@ var vm = this._view; - var pointRelativePosition = helpers.getAngleFromPoint(vm, { - x: chartX, - y: chartY - }); + if (vm) { + var pointRelativePosition = helpers.getAngleFromPoint(vm, { + x: chartX, + y: chartY + }); - // Put into the range of (-PI/2, 3PI/2] - var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; - var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle + // Put into the range of (-PI/2, 3PI/2] + var startAngle = vm.startAngle < (-0.5 * Math.PI) ? vm.startAngle + (2.0 * Math.PI) : vm.startAngle > (1.5 * Math.PI) ? vm.startAngle - (2.0 * Math.PI) : vm.startAngle; + var endAngle = vm.endAngle < (-0.5 * Math.PI) ? vm.endAngle + (2.0 * Math.PI) : vm.endAngle > (1.5 * Math.PI) ? vm.endAngle - (2.0 * Math.PI) : vm.endAngle - //Check if within the range of the open/close angle - var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), - withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); + //Check if within the range of the open/close angle + var betweenAngles = (pointRelativePosition.angle >= startAngle && pointRelativePosition.angle <= endAngle), + withinRadius = (pointRelativePosition.distance >= vm.innerRadius && pointRelativePosition.distance <= vm.outerRadius); - return (betweenAngles && withinRadius); - //Ensure within the outside of the arc centre, but inside arc outer + return (betweenAngles && withinRadius); + } else { + return false; + } }, tooltipPosition: function() { var vm = this._view; @@ -5019,10 +4972,15 @@ // Now draw the line between all the points with any borders ctx.lineCap = vm.borderCapStyle || Chart.defaults.global.elements.line.borderCapStyle; - ctx.setLineDash(vm.borderDash || Chart.defaults.global.elements.line.borderDash); + + // IE 9 and 10 do not support line dash + if (ctx.setLineDash) { + ctx.setLineDash(vm.borderDash || Chart.defaults.global.elements.line.borderDash); + } + ctx.lineDashOffset = vm.borderDashOffset || Chart.defaults.global.elements.line.borderDashOffset; ctx.lineJoin = vm.borderJoinStyle || Chart.defaults.global.elements.line.borderJoinStyle; - ctx.lineWidth = vm.borderWidth || Chart.defaults.global.defaultColor; + ctx.lineWidth = vm.borderWidth || Chart.defaults.global.elements.line.borderWidth; ctx.strokeStyle = vm.borderColor || Chart.defaults.global.defaultColor; ctx.beginPath(); @@ -5084,14 +5042,12 @@ } } - ctx.stroke(); ctx.restore(); }, }); }).call(this); - /*! * Chart.js * http://chartjs.org/ @@ -5126,8 +5082,13 @@ Chart.elements.Point = Chart.Element.extend({ inRange: function(mouseX, mouseY) { var vm = this._view; - var hoverRange = vm.hitRadius + vm.radius; - return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + + if (vm) { + var hoverRange = vm.hitRadius + vm.radius; + return ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(hoverRange, 2)); + } else { + return false; + } }, inLabelRange: function(mouseX) { var vm = this._view; @@ -5234,15 +5195,26 @@ }, inRange: function(mouseX, mouseY) { var vm = this._view; - if (vm.y < vm.base) { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); - } else { - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); - } + var inRange = false; + + if (vm) { + if (vm.y < vm.base) { + inRange = (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base); + } else { + inRange = (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); + } + } + + return inRange; }, inLabelRange: function(mouseX) { var vm = this._view; - return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + + if (vm) { + return (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2); + } else { + return false; + } }, tooltipPosition: function() { var vm = this._view; @@ -5388,4 +5360,4 @@ } }).call(this); -!function e(r,t,n){function a(i,u){if(!t[i]){if(!r[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(s)return s(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var o=t[i]={exports:{}};r[i][0].call(o.exports,function(e){var t=r[i][1][e];return a(t?t:e)},o,o.exports,e,r,t,n)}return t[i].exports}for(var s="function"==typeof require&&require,i=0;i=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*r[0]+.7152*r[1]+.0722*r[2]},contrast:function(e){var r=this.luminosity(),t=e.luminosity();return r>t?(r+.05)/(t+.05):(t+.05)/(r+.05)},level:function(e){var r=this.contrast(e);return r>=7.1?"AAA":r>=4.5?"AA":""},dark:function(){var e=this.values.rgb,r=(299*e[0]+587*e[1]+114*e[2])/1e3;return 128>r},light:function(){return!this.dark()},negate:function(){for(var e=[],r=0;3>r;r++)e[r]=255-this.values.rgb[r];return this.setValues("rgb",e),this},lighten:function(e){return this.values.hsl[2]+=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},darken:function(e){return this.values.hsl[2]-=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},saturate:function(e){return this.values.hsl[1]+=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},desaturate:function(e){return this.values.hsl[1]-=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},whiten:function(e){return this.values.hwb[1]+=this.values.hwb[1]*e,this.setValues("hwb",this.values.hwb),this},blacken:function(e){return this.values.hwb[2]+=this.values.hwb[2]*e,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var e=this.values.rgb,r=.3*e[0]+.59*e[1]+.11*e[2];return this.setValues("rgb",[r,r,r]),this},clearer:function(e){return this.setValues("alpha",this.values.alpha-this.values.alpha*e),this},opaquer:function(e){return this.setValues("alpha",this.values.alpha+this.values.alpha*e),this},rotate:function(e){var r=this.values.hsl[0];return r=(r+e)%360,r=0>r?360+r:r,this.values.hsl[0]=r,this.setValues("hsl",this.values.hsl),this},mix:function(e,r){r=1-(null==r?.5:r);for(var t=2*r-1,n=this.alpha()-e.alpha(),a=((t*n==-1?t:(t+n)/(1+t*n))+1)/2,s=1-a,i=this.rgbArray(),u=e.rgbArray(),l=0;lr&&(r+=360),n=(u+l)/2,t=l==u?0:.5>=n?h/(l+u):h/(2-l-u),[r,100*t,100*n]}function s(e){var r,t,n,a=e[0],s=e[1],i=e[2],u=Math.min(a,s,i),l=Math.max(a,s,i),h=l-u;return t=0==l?0:h/l*1e3/10,l==u?r=0:a==l?r=(s-i)/h:s==l?r=2+(i-a)/h:i==l&&(r=4+(a-s)/h),r=Math.min(60*r,360),0>r&&(r+=360),n=l/255*1e3/10,[r,t,n]}function i(e){var r=e[0],t=e[1],n=e[2],s=a(e)[0],i=1/255*Math.min(r,Math.min(t,n)),n=1-1/255*Math.max(r,Math.max(t,n));return[s,100*i,100*n]}function u(e){var r,t,n,a,s=e[0]/255,i=e[1]/255,u=e[2]/255;return a=Math.min(1-s,1-i,1-u),r=(1-s-a)/(1-a)||0,t=(1-i-a)/(1-a)||0,n=(1-u-a)/(1-a)||0,[100*r,100*t,100*n,100*a]}function l(e){return X[JSON.stringify(e)]}function h(e){var r=e[0]/255,t=e[1]/255,n=e[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*r+.3576*t+.1805*n,s=.2126*r+.7152*t+.0722*n,i=.0193*r+.1192*t+.9505*n;return[100*a,100*s,100*i]}function o(e){var r,t,n,a=h(e),s=a[0],i=a[1],u=a[2];return s/=95.047,i/=100,u/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,r=116*i-16,t=500*(s-i),n=200*(i-u),[r,t,n]}function c(e){return J(o(e))}function v(e){var r,t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100;if(0==u)return s=255*l,[s,s,s];t=.5>l?l*(1+u):l+u-l*u,r=2*l-t,a=[0,0,0];for(var h=0;3>h;h++)n=i+1/3*-(h-1),0>n&&n++,n>1&&n--,s=1>6*n?r+6*(t-r)*n:1>2*n?t:2>3*n?r+(t-r)*(2/3-n)*6:r,a[h]=255*s;return a}function f(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return s*=2,a*=1>=s?s:2-s,t=(s+a)/2,r=2*a/(s+a),[n,100*r,100*t]}function d(e){return i(v(e))}function p(e){return u(v(e))}function m(e){return l(v(e))}function y(e){var r=e[0]/60,t=e[1]/100,n=e[2]/100,a=Math.floor(r)%6,s=r-Math.floor(r),i=255*n*(1-t),u=255*n*(1-t*s),l=255*n*(1-t*(1-s)),n=255*n;switch(a){case 0:return[n,l,i];case 1:return[u,n,i];case 2:return[i,n,l];case 3:return[i,u,n];case 4:return[l,i,n];case 5:return[n,i,u]}}function w(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return t=(2-a)*s,r=a*s,r/=1>=t?t:2-t,r=r||0,t/=2,[n,100*r,100*t]}function k(e){return i(y(e))}function M(e){return u(y(e))}function S(e){return l(y(e))}function x(e){var t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100,h=u+l;switch(h>1&&(u/=h,l/=h),t=Math.floor(6*i),n=1-l,a=6*i-t,0!=(1&t)&&(a=1-a),s=u+a*(n-u),t){default:case 6:case 0:r=n,g=s,b=u;break;case 1:r=s,g=n,b=u;break;case 2:r=u,g=n,b=s;break;case 3:r=u,g=s,b=n;break;case 4:r=s,g=u,b=n;break;case 5:r=n,g=u,b=s}return[255*r,255*g,255*b]}function V(e){return a(x(e))}function q(e){return s(x(e))}function A(e){return u(x(e))}function C(e){return l(x(e))}function F(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100,u=e[3]/100;return r=1-Math.min(1,a*(1-u)+u),t=1-Math.min(1,s*(1-u)+u),n=1-Math.min(1,i*(1-u)+u),[255*r,255*t,255*n]}function N(e){return a(F(e))}function z(e){return s(F(e))}function I(e){return i(F(e))}function O(e){return l(F(e))}function E(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100;return r=3.2406*a+-1.5372*s+i*-.4986,t=a*-.9689+1.8758*s+.0415*i,n=.0557*a+s*-.204+1.057*i,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=12.92*r,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:t=12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,r=Math.min(Math.max(0,r),1),t=Math.min(Math.max(0,t),1),n=Math.min(Math.max(0,n),1),[255*r,255*t,255*n]}function H(e){var r,t,n,a=e[0],s=e[1],i=e[2];return a/=95.047,s/=100,i/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,r=116*s-16,t=500*(a-s),n=200*(s-i),[r,t,n]}function U(e){return J(H(e))}function j(e){var r,t,n,a,s=e[0],i=e[1],u=e[2];return 8>=s?(t=100*s/903.3,a=7.787*(t/100)+16/116):(t=100*Math.pow((s+16)/116,3),a=Math.pow(t/100,1/3)),r=.008856>=r/95.047?r=95.047*(i/500+a-16/116)/7.787:95.047*Math.pow(i/500+a,3),n=.008859>=n/108.883?n=108.883*(a-u/200-16/116)/7.787:108.883*Math.pow(a-u/200,3),[r,t,n]}function J(e){var r,t,n,a=e[0],s=e[1],i=e[2];return r=Math.atan2(i,s),t=360*r/2/Math.PI,0>t&&(t+=360),n=Math.sqrt(s*s+i*i),[a,n,t]}function R(e){return E(j(e))}function $(e){var r,t,n,a=e[0],s=e[1],i=e[2];return n=i/360*2*Math.PI,r=s*Math.cos(n),t=s*Math.sin(n),[a,r,t]}function D(e){return j($(e))}function P(e){return R($(e))}function _(e){return W[e]}function L(e){return a(_(e))}function T(e){return s(_(e))}function B(e){return i(_(e))}function G(e){return u(_(e))}function K(e){return o(_(e))}function Q(e){return h(_(e))}t.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:i,rgb2cmyk:u,rgb2keyword:l,rgb2xyz:h,rgb2lab:o,rgb2lch:c,hsl2rgb:v,hsl2hsv:f,hsl2hwb:d,hsl2cmyk:p,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:k,hsv2cmyk:M,hsv2keyword:S,hwb2rgb:x,hwb2hsl:V,hwb2hsv:q,hwb2cmyk:A,hwb2keyword:C,cmyk2rgb:F,cmyk2hsl:N,cmyk2hsv:z,cmyk2hwb:I,cmyk2keyword:O,keyword2rgb:_,keyword2hsl:L,keyword2hsv:T,keyword2hwb:B,keyword2cmyk:G,keyword2lab:K,keyword2xyz:Q,xyz2rgb:E,xyz2lab:H,xyz2lch:U,lab2xyz:j,lab2rgb:R,lab2lch:J,lch2lab:$,lch2xyz:D,lch2rgb:P};var W={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},X={};for(var Y in W)X[JSON.stringify(W[Y])]=Y},{}],3:[function(e,r,t){var n=e("./conversions"),a=function(){return new h};for(var s in n){a[s+"Raw"]=function(e){return function(r){return"number"==typeof r&&(r=Array.prototype.slice.call(arguments)),n[e](r)}}(s);var i=/(\w+)2(\w+)/.exec(s),u=i[1],l=i[2];a[u]=a[u]||{},a[u][l]=a[s]=function(e){return function(r){"number"==typeof r&&(r=Array.prototype.slice.call(arguments));var t=n[e](r);if("string"==typeof t||void 0===t)return t;for(var a=0;ar||e[3]&&e[3]<1?c(e,r):"rgb("+e[0]+", "+e[1]+", "+e[2]+")"}function c(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+r+")"}function g(e,r){if(1>r||e[3]&&e[3]<1)return v(e,r);var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgb("+t+"%, "+n+"%, "+a+"%)"}function v(e,r){var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgba("+t+"%, "+n+"%, "+a+"%, "+(r||e[3]||1)+")"}function f(e,r){return 1>r||e[3]&&e[3]<1?d(e,r):"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)"}function d(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+r+")"}function b(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+(void 0!==r&&1!==r?", "+r:"")+")"}function p(e){return k[e.slice(0,3)]}function m(e,r,t){return Math.min(Math.max(r,e),t)}function y(e){var r=e.toString(16).toUpperCase();return r.length<2?"0"+r:r}var w=e("color-name");r.exports={getRgba:n,getHsla:a,getRgb:i,getHsl:u,getHwb:s,getAlpha:l,hexString:h,rgbString:o,rgbaString:c,percentString:g,percentaString:v,hslString:f,hslaString:d,hwbString:b,keyword:p};var k={};for(var M in w)k[w[M]]=M},{"color-name":5}],5:[function(e,r,t){r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +!function e(r,t,n){function a(i,u){if(!t[i]){if(!r[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(s)return s(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var o=t[i]={exports:{}};r[i][0].call(o.exports,function(e){var t=r[i][1][e];return a(t?t:e)},o,o.exports,e,r,t,n)}return t[i].exports}for(var s="function"==typeof require&&require,i=0;i=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*r[0]+.7152*r[1]+.0722*r[2]},contrast:function(e){var r=this.luminosity(),t=e.luminosity();return r>t?(r+.05)/(t+.05):(t+.05)/(r+.05)},level:function(e){var r=this.contrast(e);return r>=7.1?"AAA":r>=4.5?"AA":""},dark:function(){var e=this.values.rgb,r=(299*e[0]+587*e[1]+114*e[2])/1e3;return 128>r},light:function(){return!this.dark()},negate:function(){for(var e=[],r=0;3>r;r++)e[r]=255-this.values.rgb[r];return this.setValues("rgb",e),this},lighten:function(e){return this.values.hsl[2]+=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},darken:function(e){return this.values.hsl[2]-=this.values.hsl[2]*e,this.setValues("hsl",this.values.hsl),this},saturate:function(e){return this.values.hsl[1]+=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},desaturate:function(e){return this.values.hsl[1]-=this.values.hsl[1]*e,this.setValues("hsl",this.values.hsl),this},whiten:function(e){return this.values.hwb[1]+=this.values.hwb[1]*e,this.setValues("hwb",this.values.hwb),this},blacken:function(e){return this.values.hwb[2]+=this.values.hwb[2]*e,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var e=this.values.rgb,r=.3*e[0]+.59*e[1]+.11*e[2];return this.setValues("rgb",[r,r,r]),this},clearer:function(e){return this.setValues("alpha",this.values.alpha-this.values.alpha*e),this},opaquer:function(e){return this.setValues("alpha",this.values.alpha+this.values.alpha*e),this},rotate:function(e){var r=this.values.hsl[0];return r=(r+e)%360,r=0>r?360+r:r,this.values.hsl[0]=r,this.setValues("hsl",this.values.hsl),this},mix:function(e,r){r=1-(null==r?.5:r);for(var t=2*r-1,n=this.alpha()-e.alpha(),a=((t*n==-1?t:(t+n)/(1+t*n))+1)/2,s=1-a,i=this.rgbArray(),u=e.rgbArray(),l=0;lr&&(r+=360),n=(u+l)/2,t=l==u?0:.5>=n?h/(l+u):h/(2-l-u),[r,100*t,100*n]}function s(e){var r,t,n,a=e[0],s=e[1],i=e[2],u=Math.min(a,s,i),l=Math.max(a,s,i),h=l-u;return t=0==l?0:h/l*1e3/10,l==u?r=0:a==l?r=(s-i)/h:s==l?r=2+(i-a)/h:i==l&&(r=4+(a-s)/h),r=Math.min(60*r,360),0>r&&(r+=360),n=l/255*1e3/10,[r,t,n]}function i(e){var r=e[0],t=e[1],n=e[2],s=a(e)[0],i=1/255*Math.min(r,Math.min(t,n)),n=1-1/255*Math.max(r,Math.max(t,n));return[s,100*i,100*n]}function u(e){var r,t,n,a,s=e[0]/255,i=e[1]/255,u=e[2]/255;return a=Math.min(1-s,1-i,1-u),r=(1-s-a)/(1-a)||0,t=(1-i-a)/(1-a)||0,n=(1-u-a)/(1-a)||0,[100*r,100*t,100*n,100*a]}function l(e){return X[JSON.stringify(e)]}function h(e){var r=e[0]/255,t=e[1]/255,n=e[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var a=.4124*r+.3576*t+.1805*n,s=.2126*r+.7152*t+.0722*n,i=.0193*r+.1192*t+.9505*n;return[100*a,100*s,100*i]}function o(e){var r,t,n,a=h(e),s=a[0],i=a[1],u=a[2];return s/=95.047,i/=100,u/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,r=116*i-16,t=500*(s-i),n=200*(i-u),[r,t,n]}function c(e){return J(o(e))}function v(e){var r,t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100;if(0==u)return s=255*l,[s,s,s];t=.5>l?l*(1+u):l+u-l*u,r=2*l-t,a=[0,0,0];for(var h=0;3>h;h++)n=i+1/3*-(h-1),0>n&&n++,n>1&&n--,s=1>6*n?r+6*(t-r)*n:1>2*n?t:2>3*n?r+(t-r)*(2/3-n)*6:r,a[h]=255*s;return a}function f(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return s*=2,a*=1>=s?s:2-s,t=(s+a)/2,r=2*a/(s+a),[n,100*r,100*t]}function d(e){return i(v(e))}function p(e){return u(v(e))}function m(e){return l(v(e))}function y(e){var r=e[0]/60,t=e[1]/100,n=e[2]/100,a=Math.floor(r)%6,s=r-Math.floor(r),i=255*n*(1-t),u=255*n*(1-t*s),l=255*n*(1-t*(1-s)),n=255*n;switch(a){case 0:return[n,l,i];case 1:return[u,n,i];case 2:return[i,n,l];case 3:return[i,u,n];case 4:return[l,i,n];case 5:return[n,i,u]}}function w(e){var r,t,n=e[0],a=e[1]/100,s=e[2]/100;return t=(2-a)*s,r=a*s,r/=1>=t?t:2-t,r=r||0,t/=2,[n,100*r,100*t]}function k(e){return i(y(e))}function M(e){return u(y(e))}function S(e){return l(y(e))}function x(e){var t,n,a,s,i=e[0]/360,u=e[1]/100,l=e[2]/100,h=u+l;switch(h>1&&(u/=h,l/=h),t=Math.floor(6*i),n=1-l,a=6*i-t,0!=(1&t)&&(a=1-a),s=u+a*(n-u),t){default:case 6:case 0:r=n,g=s,b=u;break;case 1:r=s,g=n,b=u;break;case 2:r=u,g=n,b=s;break;case 3:r=u,g=s,b=n;break;case 4:r=s,g=u,b=n;break;case 5:r=n,g=u,b=s}return[255*r,255*g,255*b]}function V(e){return a(x(e))}function q(e){return s(x(e))}function A(e){return u(x(e))}function C(e){return l(x(e))}function F(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100,u=e[3]/100;return r=1-Math.min(1,a*(1-u)+u),t=1-Math.min(1,s*(1-u)+u),n=1-Math.min(1,i*(1-u)+u),[255*r,255*t,255*n]}function N(e){return a(F(e))}function z(e){return s(F(e))}function I(e){return i(F(e))}function O(e){return l(F(e))}function E(e){var r,t,n,a=e[0]/100,s=e[1]/100,i=e[2]/100;return r=3.2406*a+-1.5372*s+i*-.4986,t=a*-.9689+1.8758*s+.0415*i,n=.0557*a+s*-.204+1.057*i,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=12.92*r,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:t=12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n=12.92*n,r=Math.min(Math.max(0,r),1),t=Math.min(Math.max(0,t),1),n=Math.min(Math.max(0,n),1),[255*r,255*t,255*n]}function H(e){var r,t,n,a=e[0],s=e[1],i=e[2];return a/=95.047,s/=100,i/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,r=116*s-16,t=500*(a-s),n=200*(s-i),[r,t,n]}function U(e){return J(H(e))}function j(e){var r,t,n,a,s=e[0],i=e[1],u=e[2];return 8>=s?(t=100*s/903.3,a=7.787*(t/100)+16/116):(t=100*Math.pow((s+16)/116,3),a=Math.pow(t/100,1/3)),r=.008856>=r/95.047?r=95.047*(i/500+a-16/116)/7.787:95.047*Math.pow(i/500+a,3),n=.008859>=n/108.883?n=108.883*(a-u/200-16/116)/7.787:108.883*Math.pow(a-u/200,3),[r,t,n]}function J(e){var r,t,n,a=e[0],s=e[1],i=e[2];return r=Math.atan2(i,s),t=360*r/2/Math.PI,0>t&&(t+=360),n=Math.sqrt(s*s+i*i),[a,n,t]}function R(e){return E(j(e))}function $(e){var r,t,n,a=e[0],s=e[1],i=e[2];return n=i/360*2*Math.PI,r=s*Math.cos(n),t=s*Math.sin(n),[a,r,t]}function D(e){return j($(e))}function P(e){return R($(e))}function _(e){return W[e]}function L(e){return a(_(e))}function T(e){return s(_(e))}function B(e){return i(_(e))}function G(e){return u(_(e))}function K(e){return o(_(e))}function Q(e){return h(_(e))}t.exports={rgb2hsl:a,rgb2hsv:s,rgb2hwb:i,rgb2cmyk:u,rgb2keyword:l,rgb2xyz:h,rgb2lab:o,rgb2lch:c,hsl2rgb:v,hsl2hsv:f,hsl2hwb:d,hsl2cmyk:p,hsl2keyword:m,hsv2rgb:y,hsv2hsl:w,hsv2hwb:k,hsv2cmyk:M,hsv2keyword:S,hwb2rgb:x,hwb2hsl:V,hwb2hsv:q,hwb2cmyk:A,hwb2keyword:C,cmyk2rgb:F,cmyk2hsl:N,cmyk2hsv:z,cmyk2hwb:I,cmyk2keyword:O,keyword2rgb:_,keyword2hsl:L,keyword2hsv:T,keyword2hwb:B,keyword2cmyk:G,keyword2lab:K,keyword2xyz:Q,xyz2rgb:E,xyz2lab:H,xyz2lch:U,lab2xyz:j,lab2rgb:R,lab2lch:J,lch2lab:$,lch2xyz:D,lch2rgb:P};var W={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},X={};for(var Y in W)X[JSON.stringify(W[Y])]=Y},{}],3:[function(e,r,t){var n=e("./conversions"),a=function(){return new h};for(var s in n){a[s+"Raw"]=function(e){return function(r){return"number"==typeof r&&(r=Array.prototype.slice.call(arguments)),n[e](r)}}(s);var i=/(\w+)2(\w+)/.exec(s),u=i[1],l=i[2];a[u]=a[u]||{},a[u][l]=a[s]=function(e){return function(r){"number"==typeof r&&(r=Array.prototype.slice.call(arguments));var t=n[e](r);if("string"==typeof t||void 0===t)return t;for(var a=0;ar||e[3]&&e[3]<1?c(e,r):"rgb("+e[0]+", "+e[1]+", "+e[2]+")"}function c(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+r+")"}function g(e,r){if(1>r||e[3]&&e[3]<1)return v(e,r);var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgb("+t+"%, "+n+"%, "+a+"%)"}function v(e,r){var t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return"rgba("+t+"%, "+n+"%, "+a+"%, "+(r||e[3]||1)+")"}function f(e,r){return 1>r||e[3]&&e[3]<1?d(e,r):"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)"}function d(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+r+")"}function b(e,r){return void 0===r&&(r=void 0!==e[3]?e[3]:1),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+(void 0!==r&&1!==r?", "+r:"")+")"}function p(e){return k[e.slice(0,3)]}function m(e,r,t){return Math.min(Math.max(r,e),t)}function y(e){var r=e.toString(16).toUpperCase();return r.length<2?"0"+r:r}var w=e("color-name");r.exports={getRgba:n,getHsla:a,getRgb:i,getHsl:u,getHwb:s,getAlpha:l,hexString:h,rgbString:o,rgbaString:c,percentString:g,percentaString:v,hslString:f,hslaString:d,hwbString:b,keyword:p};var k={};for(var M in w)k[w[M]]=M},{"color-name":5}],5:[function(e,r,t){r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file diff --git a/Chart.min.js b/Chart.min.js index 6a07e3417dd..775d3692f47 100644 --- a/Chart.min.js +++ b/Chart.min.js @@ -7,9 +7,9 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendTemplate:'
      <% for (var i = 0; i < data.datasets.length; i++){%>
    • <%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    '}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";{var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):s[a][i]=t.type!==s[a][i].type?e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s[a]=s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?e.configMerge(s[a],t):t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return t?e.isArray(t)&&i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t)},l=e.min=function(t){return Math.min.apply(Math,t)},c=(e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.cap=function(t,e,i){if(r(e)){if(t>e)return e}else if(r(i)&&i>t)return i;return t},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?t[e+1]||t[0]:t[e+1]||t[t.length-1]},e.previousItem=function(t,e,i){return i?t[e-1]||t[t.length-1]:t[e-1]||t[0]},e.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),u=(e.calculateScaleRange=function(t,e,i,a,s){var o=2,n=Math.floor(e/(1.5*i)),r=o>=n,u=h(t),d=l(t);u===d&&(u+=.5,d>=.5&&!a?d-=.5:u+=.5);for(var g=Math.abs(u-d),m=c(g),p=Math.ceil(u/(1*Math.pow(10,m)))*Math.pow(10,m),f=a?0:Math.floor(d/(1*Math.pow(10,m)))*Math.pow(10,m),v=p-f,b=Math.pow(10,m),x=Math.round(v/b);(x>n||n>2*x)&&!r;)if(x>n)b*=2,x=Math.round(v/b),x%1!==0&&(r=!0);else if(s&&m>=0){if(b/2%1!==0)break;b/=2,x=Math.round(v/b)}else b/=2,x=Math.round(v/b);return r&&(x=o,b=v/x),{steps:x,stepValue:b,min:f,max:f+x*b}},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},e.template=function(t,e){function i(t,e){var i=/\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('');"):a[t]=a[t];return e?i(e):i}if(t instanceof Function)return t(e);var a={};return i(t,e)}),d=(e.generateLabels=function(t,e,a,s){var o=new Array(e);return t&&i(o,function(e,i){o[i]=u(t,{value:a+s*(i+1)})}),o},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-d.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*d.easeInBounce(2*t):.5*d.easeOutBounce(2*t-1)+.5}}),g=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),m=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},p=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},g(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){m(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-left"))+parseInt(p(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(p(e,"padding-bottom"))+parseInt(p(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else this._view[a]="number"==typeof i?i*t:i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames=this.dropFrames%1);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=(s-t)/this.frameDuration;this.dropFrames+=o,this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],p=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},f=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,p),i.each(r,p),i.each(h,f),i.each(l,f);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,D=o,_=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){D+=t.height}),i.each(l,function(t){_+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=D,t.bottom=D+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:D,right:w+b,bottom:D+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(){var t,e,a,r,h,l=[],c=[],u=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),u.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(u),a=i.max(u),r=i.min(c),e=i.max(c),{x:r>this._chart.width/2?r:e,y:(h+a)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id) -},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().xAxisID),n=this.getScaleForId(this.getDataset().yAxisID);s=n.getPixelForValue(n.min<0&&n.max<0?n.max:n.min>0&&n.max>0?n.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:n,_datasetIndex:this.index,_index:e,_model:{x:o.calculateBarX(this.chart.data.datasets.length,this.index,e),y:a?s:n.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:n.calculateBarBase(this.index,e),width:o.calculateBarWidth(this.chart.data.datasets.length),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,i){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.getDataset().backgroundColor.splice(t,0,i),this.updateElement(a,t,!0),this.getDataset().metaData.splice(t,0,a)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=i.min([this.chart.chart.width,this.chart.chart.height])/2-this.chart.options.elements.arc.borderWidth/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(t._model.startAngle=0===e?Math.PI*-.5:this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){{var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID)}e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u+this.paddingLeft&&this.labelRotation<=this.options.labels.maxRotation;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels);if(this.isHorizontal()?s.width=t:this.options.display&&(s.width=Math.min(n+6,t)),this.isHorizontal()&&this.options.display){var r=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(r,e) -}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation,n=!1;(this.options.labels.fontSize+4)*this.labels.length>this.width-(this.paddingLeft+this.paddingRight)&&(n=1+Math.floor((this.options.labels.fontSize+4)*this.labels.length/(this.width-(this.paddingLeft+this.paddingRight)))),i.each(this.labels,function(r,h){if(!(n>1&&h%n>0)){var l=this.getPixelForValue(r,h,null,!1),c=this.getPixelForValue(r,h,null,!0);this.options.gridLines.show&&(0===h?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,a),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(c,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())}},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,mirror:!1,padding:10,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;if(this.isHorizontal()){var a=this.width-(this.paddingLeft+this.paddingRight);e=this.left+a/i*(t-this.start),e+=this.paddingLeft}else{var s=this.height-(this.paddingTop+this.paddingBottom);e=this.bottom-s/i*(t-this.start),e+=this.paddingTop}return e},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t){var e=this.getRightValue(t);null===this.min?this.min=e:ethis.max&&(this.max=e)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}for(var n=0,r=t;rc?(s.width+=c,s.width+=3):s.width=t,this.paddingTop=this.options.labels.fontSize/2,this.paddingBottom=this.options.labels.fontSize/2}}return a&&(this.paddingLeft-=a.left,this.paddingTop-=a.top,this.paddingRight-=a.right,this.paddingBottom-=a.bottom,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingTop=Math.max(this.paddingTop,0),this.paddingRight=Math.max(this.paddingRight,0),this.paddingBottom=Math.max(this.paddingBottom,0)),this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?this.options.labels.mirror?(l=this.right+this.options.labels.padding,this.ctx.textAlign="left"):(l=this.right-this.options.labels.padding,this.ctx.textAlign="right"):this.options.labels.mirror?(l=this.left-this.options.labels.padding,this.ctx.textAlign="right"):(l=this.left+this.options.labels.padding,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;t.textAlign=0===e?"center":e===n?"center":n>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! +(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var a=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},s=this.width=a(t.canvas,"Width")||t.canvas.width,o=this.height=a(t.canvas,"Height")||t.canvas.height;return t.canvas.width=s,t.canvas.height=o,s=this.width=t.canvas.width,o=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendTemplate:'
      <% for (var i = 0; i < data.datasets.length; i++){%>
    • <%if(data.datasets[i].label){%><%=data.datasets[i].label%><%}%>
    • <%}%>
    '}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";{var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i,a){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var o;if(a)for(o=t.length-1;o>=0;o--)e.apply(i,[t[o],o].concat(s));else for(o=0;o=s[a].length||!s[a][i].type?s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):s[a][i]=t.type!==s[a][i].type?e.configMerge(s[a][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):e.configMerge(s[a][i],t)}):(s[a]=[],e.each(t,function(t){s[a].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):s[a]=s.hasOwnProperty(a)&&"object"==typeof s[a]&&null!==s[a]&&"object"==typeof t?e.configMerge(s[a],t):t)}),s},e.getValueAtIndexOrDefault=function(t,i,a){return void 0===t||null===t?a:e.isArray(t)?i=0;a--){var s=t[a];if(e(s))return s}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=i};return a.prototype=e.prototype,i.prototype=new a,i.extend=o,t&&s(i.prototype,t),i.__super__=e.prototype,i}),n=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=(e.max=function(t){return Math.max.apply(Math,t)},e.min=function(t){return Math.min.apply(Math,t)},e.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},e.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},e.getDecimalPlaces=function(t){if(t%1!==0&&r(t)){var e=t.toString();if(e.indexOf("e-")<0)return e.split(".")[1].length;if(e.indexOf(".")<0)return parseInt(e.split("e-")[1]);var i=e.split(".")[1].split("e-");return i[0].length+parseInt(i[1])}return 0},e.toRadians=function(t){return t*(Math.PI/180)},e.toDegrees=function(t){return t*(180/Math.PI)},e.getAngleFromPoint=function(t,e){var i=e.x-t.x,a=e.y-t.y,s=Math.sqrt(i*i+a*a),o=Math.atan2(a,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:s}},e.aliasPixel=function(t){return t%2===0?0:.5},e.splineCurve=function(t,e,i,a){var s=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),n=a*s/(s+o),r=a*o/(s+o);return{previous:{x:e.x-n*(i.x-t.x),y:e.y-n*(i.y-t.y)},next:{x:e.x+r*(i.x-t.x),y:e.y+r*(i.y-t.y)}}},e.nextItem=function(t,e,i){return i?e>=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},e.previousItem=function(t,e,i){return i?0>=e?t[t.length-1]:t[e-1]:0>=e?t[0]:t[e-1]},e.niceNum=function(t,i){var a,s=Math.floor(e.log10(t)),o=t/Math.pow(10,s);return a=i?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,a*Math.pow(10,s)},{}),l=(e.template=function(t,e){function i(t,e){var i;return h.hasOwnProperty(t)?i=h[t]:(i=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('');"),h[t]=i),e?i(e):i}return t instanceof Function?t(e):i(t,e)},e.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 e=1.70158,i=0,a=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i):a*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-e)*Math.PI/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-l.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*l.easeInBounce(2*t):.5*l.easeOutBounce(2*t-1)+.5}}),c=(e.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),e.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),e.getRelativePosition=function(t){var e,i,a=t.originalEvent||t,s=t.currentTarget||t.srcElement,o=s.getBoundingClientRect();return a.touches?(e=a.touches[0].clientX-o.left,i=a.touches[0].clientY-o.top):(e=a.clientX-o.left,i=a.clientY-o.top),{x:e,y:i}},e.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}),u=e.removeEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=n},d=(e.bindEvents=function(t,e,a){t.events||(t.events={}),i(e,function(e){t.events[e]=function(){a.apply(t,arguments)},c(t.chart.canvas,e,t.events[e])})},e.unbindEvents=function(t,e){i(e,function(e,i){u(t.chart.canvas,i,e)})},e.getMaximumWidth=function(t){var e=t.parentNode,i=parseInt(d(e,"padding-left"))+parseInt(d(e,"padding-right"));return e.clientWidth-i},e.getMaximumHeight=function(t){var e=t.parentNode,i=parseInt(d(e,"padding-bottom"))+parseInt(d(e,"padding-top"));return e.clientHeight-i},e.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)});e.getMaximumSize=e.getMaximumWidth,e.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,a=t.canvas.height;window.devicePixelRatio&&(e.canvas.style.width=i+"px",e.canvas.style.height=a+"px",e.canvas.height=a*window.devicePixelRatio,e.canvas.width=i*window.devicePixelRatio,e.scale(window.devicePixelRatio,window.devicePixelRatio))},e.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},e.fontString=function(t,e,i){return e+" "+t+"px "+i},e.longestText=function(t,e,a){t.font=e;var s=0;return i(a,function(e){var i=t.measureText(e).width;s=i>s?i:s}),s},e.drawRoundedRectangle=function(t,e,i,a,s,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+a-o,i),t.quadraticCurveTo(e+a,i,e+a,i+o),t.lineTo(e+a,i+s-o),t.quadraticCurveTo(e+a,i+s,e+a-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},e.color=function(t){return window.Color?window.Color(t):(console.log("Color.js not found!"),t)},e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.elements={},Chart.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(Chart.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=e.clone(this._model)),this._start=e.clone(this._view),this},transition:function(t){return this._view||(this._view=e.clone(this._model)),this._start||this.pivot(),e.each(this._model,function(i,a){if("_"!==a[0]&&this._model.hasOwnProperty(a))if(this._view[a])if(this._model[a]===this._view[a]);else if("string"==typeof i)try{var s=e.color(this._start[a]).mix(e.color(this._model[a]),t);this._view[a]=s.rgbString()}catch(o){this._view[a]=i}else if("number"==typeof i){var n=void 0!==this._start[a]?this._start[a]:0;this._view[a]=(this._model[a]-n)*t+n}else this._view[a]=i;else this._view[a]="number"==typeof i?i*t:i||null;else;},this),1===t&&delete this._start,this},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),Chart.Element.extend=e.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:function(){},onComplete:function(){}},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,a,s){s||(t.animating=!0);for(var o=0;o1&&(e=Math.floor(this.dropFrames),this.dropFrames=this.dropFrames%1);for(var a=0;athis.animations[a].animationObject.numSteps&&(this.animations[a].animationObject.currentStep=this.animations[a].animationObject.numSteps),this.animations[a].animationObject.render(this.animations[a].chartInstance,this.animations[a].animationObject),this.animations[a].animationObject.currentStep==this.animations[a].animationObject.numSteps&&(this.animations[a].chartInstance.animating=!1,this.animations.splice(a,1),a--);var s=Date.now(),o=(s-t)/this.frameDuration;this.dropFrames+=o,this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers);Chart.types={},Chart.instances={},Chart.controllers={},Chart.Controller=function(t){return this.chart=t,this.config=t.config,this.data=this.config.data,this.options=this.config.options=e.configMerge(Chart.defaults.global,Chart.defaults[this.config.type],this.config.options||{}),this.id=e.uid(),Chart.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},e.extend(Chart.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.resetElements(),this.initToolTip(),this.update(),this},clear:function(){return e.clear(this.chart),this},stop:function(){return Chart.animationService.cancelAnimation(this),this},addDataset:function(t,e){void 0!==e?this.data.datasets.splice(e,0,t):this.data.datasets.push(t),this.buildOrUpdateControllers(),t.controller.reset(),this.update()},removeDataset:function(t){this.data.datasets.splice(t,1),this.buildOrUpdateControllers(),this.update()},addData:function(t,e,i){if(e30?5:2,o=a>30?5:2;if(t){var n=i.where(t.scales,function(t){return"left"==t.options.position}),r=i.where(t.scales,function(t){return"right"==t.options.position}),h=i.where(t.scales,function(t){return"top"==t.options.position}),l=i.where(t.scales,function(t){return"bottom"==t.options.position}),c=e/2,u=a/2;c-=2*s,u-=2*o;var d=(e-c)/(n.length+r.length),g=(a-u)/(h.length+l.length),m=[],p=function(t){var e=t.fit(d,u);m.push({horizontal:!1,minSize:e,scale:t})},f=function(t){var e=t.fit(c,g);m.push({horizontal:!0,minSize:e,scale:t})};i.each(n,p),i.each(r,p),i.each(h,f),i.each(l,f);var v=a-2*o,b=e-2*s;i.each(m,function(t){t.horizontal?v-=t.minSize.height:b-=t.minSize.width});var x=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t});e&&t.fit(e.minSize.width,v)},y=function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:w,right:C,top:0,bottom:0};e&&t.fit(b,e.minSize.height,a)},w=s,C=s,D=o,_=o;i.each(n,x),i.each(r,x),i.each(n,function(t){w+=t.width}),i.each(r,function(t){C+=t.width}),i.each(h,y),i.each(l,y),i.each(h,function(t){D+=t.height}),i.each(l,function(t){_+=t.height}),i.each(n,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)}),i.each(r,function(t){var e=i.findNextWhere(m,function(e){return e.scale===t}),a={left:0,right:0,top:D,bottom:_};e&&t.fit(e.minSize.width,v,a)});var k=s,S=o,A=function(t){t.left=k,t.right=k+t.width,t.top=D,t.bottom=D+v,k=t.right},P=function(t){t.left=w,t.right=w+b,t.top=S,t.bottom=S+t.height,S=t.bottom};i.each(n,A),i.each(h,P),k+=b,S+=v,i.each(r,A),i.each(l,P),t.chartArea={left:w,top:D,right:w+b,bottom:D+v}}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.tooltips={enabled:!0,custom:null,backgroundColor:"rgba(0,0,0,0.8)",fontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",fontSize:10,fontStyle:"normal",fontColor:"#fff",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleFontColor:"#fff",yPadding:6,xPadding:6,caretSize:8,cornerRadius:6,xOffset:10,template:["<% if(label){ %>","<%=label %>: ","<% } %>","<%=value %>"].join(""),multiTemplate:["<%if (datasetLabel){ %>","<%=datasetLabel %>: ","<% } %>","<%=value %>"].join(""),multiKeyBackground:"#fff"},e.Tooltip=e.Element.extend({initialize:function(){var t=this._options;i.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,xOffset:t.tooltips.xOffset,textColor:t.tooltips.fontColor,_fontFamily:t.tooltips.fontFamily,_fontStyle:t.tooltips.fontStyle,fontSize:t.tooltips.fontSize,titleTextColor:t.tooltips.titleFontColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,caretHeight:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},update:function(){var t=this._chart.ctx;switch(this._options.hover.mode){case"single":i.extend(this._model,{text:i.template(this._options.tooltips.template,{element:this._active[0],value:this._data.datasets[this._active[0]._datasetIndex].data[this._active[0]._index],label:void 0!==this._active[0]._model.label?this._active[0]._model.label:this._data.labels?this._data.labels[this._active[0]._index]:""})});var e=this._active[0].tooltipPosition();i.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:e.padding});break;case"label":for(var a,s,o=[],n=[],r=this._data.datasets.length-1;r>=0&&(a=this._data.datasets[r].metaData,s=i.indexOf(a,this._active[0]),-1===s);r--);var h=function(){var t,e,a,r,h,l=[],c=[],u=[];return i.each(this._data.datasets,function(e){t=e.metaData,t[s]&&t[s].hasValue()&&l.push(t[s])},this),i.each(this._options.stacked?l.reverse():l,function(t){c.push(t._view.x),u.push(t._view.y),o.push(i.template(this._options.tooltips.multiTemplate,{element:t,datasetLabel:this._data.datasets[t._datasetIndex].label,value:this._data.datasets[t._datasetIndex].data[t._index]})),n.push({fill:t._view.backgroundColor,stroke:t._view.borderColor})},this),h=i.min(u),a=i.max(u),r=i.min(c),e=i.max(c),{x:r>this._chart.width/2?r:e,y:(h+a)/2}}.call(this,s);i.extend(this._model,{x:h.x,y:h.y,labels:o,title:this._data.labels&&this._data.labels.length?this._data.labels[this._active[0]._index]:"",legendColors:n,legendBackgroundColor:this._options.tooltips.multiKeyBackground}),this._model.height=o.length*this._model.fontSize+(o.length-1)*(this._model.fontSize/2)+2*this._model.yPadding+1.5*this._model.titleFontSize;var l=t.measureText(this._model.title).width,c=i.longestText(t,this.font,o)+this._model.fontSize+3,u=i.max([c,l]);this._model.width=u+2*this._model.xPadding;var d=this._model.height/2;this._model.y-d<0?this._model.y=d:this._model.y+d>this._chart.height&&(this._model.y=this._chart.height-d),this._model.x>this._chart.width/2?this._model.x-=this._model.xOffset+this._model.width:this._model.x+=this._model.xOffset}return this},draw:function(){var t=this._chart.ctx,e=this._view;switch(this._options.hover.mode){case"single":t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),e.xAlign="center",e.yAlign="above";var a=e.caretPadding||2,s=t.measureText(e.text).width+2*e.xPadding,o=e.fontSize+2*e.yPadding,n=o+e.caretHeight+a;e.x+s/2>this._chart.width?e.xAlign="left":e.x-s/2<0&&(e.xAlign="right"),e.y-n<0&&(e.yAlign="below");var r=e.x-s/2,h=e.y-n;if(t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;switch(e.yAlign){case"above":t.beginPath(),t.moveTo(e.x,e.y-a),t.lineTo(e.x+e.caretHeight,e.y-(a+e.caretHeight)),t.lineTo(e.x-e.caretHeight,e.y-(a+e.caretHeight)),t.closePath(),t.fill();break;case"below":h=e.y+a+e.caretHeight,t.beginPath(),t.moveTo(e.x,e.y+a),t.lineTo(e.x+e.caretHeight,e.y+a+e.caretHeight),t.lineTo(e.x-e.caretHeight,e.y+a+e.caretHeight),t.closePath(),t.fill()}switch(e.xAlign){case"left":r=e.x-s+(e.cornerRadius+e.caretHeight);break;case"right":r=e.x-(e.cornerRadius+e.caretHeight)}i.drawRoundedRectangle(t,r,h,s,o,e.cornerRadius),t.fill(),t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,r+s/2,h+o/2);break;case"label":if(this._options.tooltips.custom&&this._options.tooltips.custom(this),!this._options.tooltips.enabled)return;i.drawRoundedRectangle(t,e.x,e.y-e.height/2,e.width,e.height,e.cornerRadius),t.fillStyle=i.color(e.backgroundColor).alpha(e.opacity).rgbString(),t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=i.color(e.titleTextColor).alpha(e.opacity).rgbString(),t.font=i.fontString(e.fontSize,e._titleFontStyle,e._titleFontFamily),t.fillText(e.title,e.x+e.xPadding,this.getLineHeight(0)),t.font=i.fontString(e.fontSize,e._fontStyle,e._fontFamily),i.each(e.labels,function(a,s){t.fillStyle=i.color(e.textColor).alpha(e.opacity).rgbString(),t.fillText(a,e.x+e.xPadding+e.fontSize+3,this.getLineHeight(s+1)),t.fillStyle=i.color(e.legendColors[s].stroke).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding-1,this.getLineHeight(s+1)-e.fontSize/2-1,e.fontSize+2,e.fontSize+2),t.fillStyle=i.color(e.legendColors[s].fill).alpha(e.opacity).rgbString(),t.fillRect(e.x+e.xPadding,this.getLineHeight(s+1)-e.fontSize/2,e.fontSize,e.fontSize)},this)}},getLineHeight:function(t){var e=this._view.y-this._view.height/2+this._view.yPadding,i=t-1;return 0===t?e+this._view.titleFontSize/2:e+(1.5*this._view.fontSize*i+this._view.fontSize/2)+1.5*this._view.titleFontSize}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categorySpacing:10,spacing:1,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.bar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},getBarCount:function(){var t=0;return i.each(this.chart.data.datasets,function(e){"bar"===e.type?++t:void 0===e.type&&"bar"===this.chart.config.type&&++t},this),t},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i}) +},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t}),a=this.getBarCount();this.updateElement(i,t,!0,a),this.getDataset().metaData.splice(t,0,i)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e=this.getBarCount(),a=this.getDataset().data.length,s=this.getDataset().metaData.length;if(s>a)this.getDataset().metaData.splice(a,s-a);else if(a>s)for(var o=s;a>o;++o)this.addElementAndReset(o);i.each(this.getDataset().metaData,function(i,a){this.updateElement(i,a,t,e)},this)},updateElement:function(t,e,a,s){var o,n=this.getScaleForId(this.getDataset().xAxisID),r=this.getScaleForId(this.getDataset().yAxisID);o=r.getPixelForValue(r.min<0&&r.max<0?r.max:r.min>0&&r.max>0?r.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:r,_datasetIndex:this.index,_index:e,_model:{x:n.calculateBarX(s,this.index,e),y:a?o:r.calculateBarY(this.index,e),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:r.calculateBarBase(this.index,e),width:n.calculateBarWidth(s),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,a,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,a,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.hoverBorderWidth,a,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},cutoutPercentage:50},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.doughnut.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,a){this.getDataset().metaData=this.getDataset().metaData||[];var s=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});a&&i.isArray(this.getDataset().backgroundColor)&&this.getDataset().backgroundColor.splice(t,0,a),this.updateElement(s,t,!0),this.getDataset().metaData.splice(t,0,s)},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){this.chart.outerRadius=i.min([this.chart.chart.width,this.chart.chart.height])/2-this.chart.options.elements.arc.borderWidth/2,this.chart.innerRadius=this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.chart.data.datasets.length,this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength;var e=this.getDataset().data.length,a=this.getDataset().metaData.length;if(a>e)this.getDataset().metaData.splice(e,a-e);else if(e>a)for(var s=a;e>s;++s)this.addElementAndReset(s);i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,a){var s={x:this.chart.chart.width/2,y:this.chart.chart.height/2,startAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:a?s:{x:this.chart.chart.width/2,y:this.chart.chart.height/2,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),a||(t._model.startAngle=0===e?Math.PI*-.5:this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e0?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=this.getDataset().metaDataset,s=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID),n=(this.getScaleForId(this.getDataset().xAxisID),this.getDataset().data.length),r=this.getDataset().metaData.length;if(r>n)this.getDataset().metaData.splice(n,r-n);else if(n>r)for(var h=r;n>h;++h)this.addElementAndReset(h);e=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(a,{_scale:o,_datasetIndex:this.index,_children:s,_model:{tension:a.custom&&a.custom.tension?a.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:a.custom&&a.custom.backgroundColor?a.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:a.custom&&a.custom.borderWidth?a.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:a.custom&&a.custom.borderColor?a.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:a.custom&&a.custom.borderCapStyle?a.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:a.custom&&a.custom.borderDash?a.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:a.custom&&a.custom.borderDashOffset?a.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:a.custom&&a.custom.borderJoinStyle?a.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:a.custom&&a.custom.fill?a.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),a.pivot(),i.each(s,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);s=o.getPixelForValue(o.min<0&&o.max<0?o.max:o.min>0&&o.max>0?o.min:0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:n.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:a?s:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y0?2*Math.PI*(t/this.getDataset().total):0},updateScaleRange:function(){i.extend(this.chart.scale,{size:i.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.radar.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},removeElement:function(t){this.getDataset().metaData.splice(t,1)},reset:function(){this.update(!0)},update:function(t){var e,a=(this.getDataset().metaDataset,this.getDataset().metaData),s=this.chart.scale;s.setScaleSize(),s.calculateRange(),s.generateTicks(),s.buildYLabels(),e=s.min<0&&s.max<0?s.getPointPositionForValue(0,s.max):s.min>0&&s.max>0?s.getPointPositionForValue(0,s.min):s.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,a){var s=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_model:{x:a?this.chart.scale.xCenter:s.x,y:a?this.chart.scale.yCenter:s.y,tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.pointRadius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),skip:t.custom&&t.custom.skip?t.custom.skip:null===this.getDataset().data[e],hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}})},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var a=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=a.previous.x,t._model.controlPointNextX=a.next.x,t._model.controlPointNextY=a.next.y>this.chart.chartArea.bottom?this.chart.chartArea.bottom:a.next.ythis.chart.chartArea.bottom?this.chart.chartArea.bottom:a.previous.y",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},buildLabels:function(){this.labels=[],this.options.labels.userCallback?this.data.labels.forEach(function(t,e){this.labels.push(this.options.labels.userCallback(t,e))},this):this.labels=this.data.labels},getPixelForValue:function(t,e,i,a){if(this.isHorizontal()){var s=(this.labelRotation>0,this.width-(this.paddingLeft+this.paddingRight)),o=s/Math.max(this.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&a&&(n+=o/2),this.left+Math.round(n)}return this.top+e*(this.height/this.labels.length)},getPointPixelForValue:function(t,e,i){return this.getPixelForValue(t,e,i,!0)},calculateBaseWidth:function(){return this.getPixelForValue(null,1,0,!0)-this.getPixelForValue(null,0,0,!0)-2*this.options.categorySpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*this.options.spacing;return this.options.stacked?e:e/t},calculateBarX:function(t,e,i){var a=this.calculateBaseWidth(),s=this.getPixelForValue(null,i,e,!0)-a/2,o=this.calculateBarWidth(t);return this.options.stacked?s+o/2:s+o*e+e*this.options.spacing+o/2},calculateLabelRotation:function(t,e){var a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=a;var s,o,n=this.ctx.measureText(this.labels[0]).width,r=this.ctx.measureText(this.labels[this.labels.length-1]).width;if(this.paddingRight=r/2+3,this.paddingLeft=n/2+3,this.labelRotation=0,this.options.display){var h,l,c=i.longestText(this.ctx,a,this.labels);this.labelWidth=c;for(var u=Math.floor(this.getPixelForValue(0,1)-this.getPixelForValue(0,0))-6;this.labelWidth>u&&this.labelRotation<=this.options.labels.maxRotation;){if(h=Math.cos(i.toRadians(this.labelRotation)),l=Math.sin(i.toRadians(this.labelRotation)),s=h*n,o=h*r,s+this.options.labels.fontSize/2>this.yLabelWidth&&(this.paddingLeft=s+this.options.labels.fontSize/2),this.paddingRight=this.options.labels.fontSize/2,l*c>t){this.labelRotation--;break}this.labelRotation++,this.labelWidth=h*c}}else this.labelWidth=0,this.paddingRight=0,this.paddingLeft=0;e&&(this.paddingLeft-=e.left,this.paddingRight-=e.right,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingRight=Math.max(this.paddingRight,0))},fit:function(t,e,a){this.isHorizontal()?this.width=t:this.height=e,this.buildLabels(),this.calculateLabelRotation(e,a);var s={width:0,height:0},o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),n=i.longestText(this.ctx,o,this.labels);if(this.isHorizontal())s.width=t;else if(this.options.display){var r=this.options.labels.show?n+6:0; +s.width=Math.min(r,t)}if(this.isHorizontal()&&this.options.display){var h=Math.sin(i.toRadians(this.labelRotation))*n+1.5*this.options.labels.fontSize;s.height=Math.min(this.options.labels.show?h:0,e)}else this.options.display&&(s.height=e);return this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){e=!0;var a="bottom"==this.options.position?this.top:this.bottom-10,s="bottom"==this.options.position?this.top+10:this.bottom,o=0!==this.labelRotation,n=!1;(this.options.labels.fontSize+4)*this.labels.length>this.width-(this.paddingLeft+this.paddingRight)&&(n=1+Math.floor((this.options.labels.fontSize+4)*this.labels.length/(this.width-(this.paddingLeft+this.paddingRight)))),i.each(this.labels,function(r,h){if(!(n>1&&h%n>0||void 0===r||null===r)){var l=this.getPixelForValue(r,h,null,!1),c=this.getPixelForValue(r,h,null,!0);this.options.gridLines.show&&(0===h?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),l+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(l,a),this.ctx.lineTo(l,s)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(l,t.top),this.ctx.lineTo(l,t.bottom)),this.ctx.stroke()),this.options.labels.show&&(this.ctx.save(),this.ctx.translate(c,o?this.top+12:this.top+8),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=this.font,this.ctx.textAlign=o?"right":"center",this.ctx.textBaseline=o?"middle":"top",this.ctx.fillText(r,0,0),this.ctx.restore())}},this)}else this.options.gridLines.show,this.options.labels.show}}});e.scaleService.registerScaleType("category",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,position:"left",gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)"},reverse:!1,beginAtZero:!1,override:null,labels:{show:!0,mirror:!1,padding:10,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue"}},s=e.Element.extend({isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},generateTicks:function(t,e){if(this.ticks=[],this.options.override)for(var a=0;a<=this.options.override.steps;++a){var s=this.options.override.start+a*this.options.override.stepWidth;this.ticks.push(s)}else{var o;if(o=this.isHorizontal()?Math.min(11,Math.ceil(t/50)):Math.min(11,Math.ceil(e/(2*this.options.labels.fontSize))),o=Math.max(2,o),this.options.beginAtZero){var n=i.sign(this.min),r=i.sign(this.max);0>n&&0>r?this.max=0:n>0&&r>0&&(this.min=0)}for(var h=i.niceNum(this.max-this.min,!1),l=i.niceNum(h/(o-1),!0),c=Math.floor(this.min/l)*l,u=Math.ceil(this.max/l)*l,d=c;u>=d;d+=l)this.ticks.push(d)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max)},buildLabels:function(){this.labels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.labels.push(s?s:"")},this)},getRightValue:function(t){return"object"==typeof t&&null!==t?this.isHorizontal()?t.x:t.y:t},getPixelForValue:function(t){var e,i=this.end-this.start;if(this.isHorizontal()){var a=this.width-(this.paddingLeft+this.paddingRight);e=this.left+a/i*(t-this.start),e+=this.paddingLeft}else{var s=this.height-(this.paddingTop+this.paddingBottom);e=this.bottom-this.paddingBottom-s/i*(t-this.start)}return e},calculateRange:function(){this.min=null,this.max=null;var t=[],e=[];if(this.options.stacked){i.each(this.data.datasets,function(a){(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(i,a){var s=this.getRightValue(i);t[a]=t[a]||0,e[a]=e[a]||0,this.options.relativePoints?t[a]=100:0>s?e[a]+=s:t[a]+=s},this)},this);var a=t.concat(e);this.min=i.min(a),this.max=i.max(a)}else i.each(this.data.datasets,function(t){(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t){var e=this.getRightValue(t);null===this.min?this.min=e:ethis.max&&(this.max=e)},this)},this);this.min===this.max&&(this.min--,this.max++)},getPointPixelForValue:function(t,e,i){var a=this.getRightValue(t);if(this.options.stacked){for(var s=0,o=0,n=this.data.datasets.length-1;n>i;--n)this.data.datasets[n].data[e]<0?o+=this.data.datasets[n].data[e]:s+=this.data.datasets[n].data[e];return this.getPixelForValue(0>a?o+a:s+a)}return this.getPixelForValue(a)},calculateBarBase:function(t,e){var i=0;if(this.options.stacked){var a=this.data.datasets[t].data[e];if(0>a)for(var s=0;t>s;s++)this.data.datasets[s].yAxisID===this.id&&(i+=this.data.datasets[s].data[e]<0?this.data.datasets[s].data[e]:0);else for(var o=0;t>o;o++)this.data.datasets[o].yAxisID===this.id&&(i+=this.data.datasets[o].data[e]>0?this.data.datasets[o].data[e]:0);return this.getPixelForValue(i)}return i=this.getPixelForValue(this.min),this.beginAtZero||this.min<=0&&this.max>=0||this.min>=0&&this.max<=0?(i=this.getPixelForValue(0),i+=this.options.gridLines.lineWidth):this.min<0&&this.max<0&&(i=this.getPixelForValue(this.max)),i},calculateBarY:function(t,e){var i=this.data.datasets[t].data[e];if(this.options.stacked){for(var a=0,s=0,o=0;t>o;o++)this.data.datasets[o].data[e]<0?s+=this.data.datasets[o].data[e]||0:a+=this.data.datasets[o].data[e]||0;return this.getPixelForValue(0>i?s+i:a+i)}return this.getPixelForValue(i)},fit:function(t,e,a){this.calculateRange(),this.generateTicks(t,e),this.buildLabels();var s={width:0,height:0};if(s.width=this.isHorizontal()?t:this.options.gridLines.show&&this.options.display?10:0,s.height=this.isHorizontal()?this.options.gridLines.show&&this.options.display?10:0:e,this.paddingLeft=0,this.paddingRight=0,this.paddingTop=0,this.paddingBottom=0,this.options.labels.show&&this.options.display){var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.isHorizontal()){var n=(e-s.height,1.5*this.options.labels.fontSize);s.height=Math.min(e,s.height+n);var o=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.ctx.font=o;var r=this.ctx.measureText(this.labels[0]).width,h=this.ctx.measureText(this.labels[this.labels.length-1]).width;this.paddingLeft=r/2,this.paddingRight=h/2}else{var l=t-s.width,c=i.longestText(this.ctx,o,this.labels);l>c?(s.width+=c,s.width+=3):s.width=t,this.paddingTop=this.options.labels.fontSize/2,this.paddingBottom=this.options.labels.fontSize/2}}return a&&(this.paddingLeft-=a.left,this.paddingTop-=a.top,this.paddingRight-=a.right,this.paddingBottom-=a.bottom,this.paddingLeft=Math.max(this.paddingLeft,0),this.paddingTop=Math.max(this.paddingTop,0),this.paddingRight=Math.max(this.paddingRight,0),this.paddingBottom=Math.max(this.paddingBottom,0)),this.width=s.width,this.height=s.height,s},draw:function(t){if(this.options.display){var e,a;if(this.ctx.fillStyle=this.options.labels.fontColor,this.isHorizontal()){if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var s="bottom"==this.options.position?this.top:this.bottom-5,o="bottom"==this.options.position?this.top+5:this.bottom;i.each(this.ticks,function(n,r){var h=this.getPixelForValue(n);0===n||!a&&0===r?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),h+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(h,s),this.ctx.lineTo(h,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(h,t.top),this.ctx.lineTo(h,t.bottom)),this.ctx.stroke()},this)}if(this.options.labels.show){var n;"top"==this.options.position?(n=this.bottom-10,this.ctx.textBaseline="bottom"):(n=this.top+10,this.ctx.textBaseline="top"),this.ctx.textAlign="center",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,i,n)},this)}}else{if(this.options.gridLines.show){e=!0,a=void 0!==i.findNextWhere(this.ticks,function(t){return 0===t});var r="right"==this.options.position?this.left:this.right-5,h="right"==this.options.position?this.left+5:this.right;i.each(this.ticks,function(s,o){var n=this.getPixelForValue(s);0===s||!a&&0===o?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),n+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(r,n),this.ctx.lineTo(h,n)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,n),this.ctx.lineTo(t.right,n)),this.ctx.stroke()},this)}if(this.options.labels.show){var l;"left"==this.options.position?this.options.labels.mirror?(l=this.right+this.options.labels.padding,this.ctx.textAlign="left"):(l=this.right-this.options.labels.padding,this.ctx.textAlign="right"):this.options.labels.mirror?(l=this.left-this.options.labels.padding,this.ctx.textAlign="right"):(l=this.left+this.options.labels.padding,this.ctx.textAlign="left"),this.ctx.textBaseline="middle",this.ctx.font=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily),i.each(this.labels,function(t,e){var i=this.getPixelForValue(this.ticks[e]);this.ctx.fillText(t,l,i)},this)}}}}});e.scaleService.registerScaleType("linear",s,a)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={display:!0,animate:!0,lineArc:!1,gridLines:{show:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},angleLines:{show:!0,color:"rgba(0,0,0, 0.1)",lineWidth:1},beginAtZero:!0,labels:{show:!0,template:"<%=value.toLocaleString()%>",fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666"}},s=e.Element.extend({initialize:function(){this.height=this.chart.height,this.width=this.chart.width,this.xCenter=this.chart.width/2,this.yCenter=this.chart.height/2,this.size=i.min([this.height,this.width]),this.labels=this.data.labels,this.drawingArea=this.options.display?this.size/2-(this.options.labels.fontSize/2+this.options.labels.backdropPaddingY):this.size/2},getValueCount:function(){return this.data.labels.length},update:function(){this.options.lineArc?this.drawingArea=this.options.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},calculateRange:function(){this.min=null,this.max=null,i.each(this.data.datasets,function(t){i.each(t.data,function(t){null===this.min?this.min=t:tthis.max&&(this.max=t)},this)},this)},generateTicks:function(){if(this.ticks=[],this.options.override)for(var t=0;t<=this.options.override.steps;++t){var e=this.options.override.start+t*this.options.override.stepWidth;this.ticks.push(e)}else{var a=Math.min(11,Math.ceil(this.drawingArea/(2*this.options.labels.fontSize)));if(a=Math.max(2,a),this.options.beginAtZero){var s=i.sign(this.min),o=i.sign(this.max);0>s&&0>o?this.max=0:s>0&&o>0&&(this.min=0)}for(var n=i.niceNum(this.max-this.min,!1),r=i.niceNum(n/(a-1),!0),h=Math.floor(this.min/r)*r,l=Math.ceil(this.max/r)*r,c=h;l>=c;c+=r)this.ticks.push(c)}("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks)},buildYLabels:function(){this.yLabels=[],i.each(this.ticks,function(t,e,a){var s;this.options.labels.userCallback?s=this.options.labels.userCallback(t,e,a):this.options.labels.template&&(s=i.template(this.options.labels.template,{value:t})),this.yLabels.push(s?s:"")},this)},getCircumference:function(){return 2*Math.PI/this.getValueCount()},setScaleSize:function(){var t,e,a,s,o,n,r,h,l,c,u,d,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;em&&(m=t.x+s,o=e),t.x-sm&&(m=t.x+a,o=e):e>this.getValueCount()/2&&t.x-a0){var s=this.getDistanceFromCenterForValue(this.ticks[a]),o=this.yCenter-s;if(this.options.gridLines.show)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,s,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n=0;e--){if(this.options.angleLines.show){var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(a.x,a.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.labels.length,n=this.labels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;t.textAlign=0===e?"center":e===n?"center":n>e?"left":"right",t.textBaseline=l?"middle":h?"bottom":"top",t.fillText(this.labels[e],s.x,s.y)}}}}});e.scaleService.registerScaleType("radialLinear",s,a)}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -18,7 +18,7 @@ * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.elements.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?a.startAngle-2*Math.PI:a.startAngle,n=a.endAngle<-.5*Math.PI?a.endAngle+2*Math.PI:a.endAngle>1.5*Math.PI?a.endAngle-2*Math.PI:a.endAngle,r=s.angle>=o&&s.angle<=n,h=s.distance>=a.innerRadius&&s.distance<=a.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.elements.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)1.5*Math.PI?a.startAngle-2*Math.PI:a.startAngle,n=a.endAngle<-.5*Math.PI?a.endAngle+2*Math.PI:a.endAngle>1.5*Math.PI?a.endAngle-2*Math.PI:a.endAngle,r=s.angle>=o&&s.angle<=n,h=s.distance>=a.innerRadius&&s.distance<=a.outerRadius;return r&&h}return!1},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -27,7 +27,7 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,s=this._children[0],o=this._children[this._children.length-1];a.save(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(o._view.x,e._view.y),a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,o._view.y),a.lineTo(e._view.x,e._view.y)),void(o._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!s._view.skip?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineCap=t.borderCapStyle||e.defaults.global.elements.line.borderCapStyle,a.setLineDash(t.borderDash||e.defaults.global.elements.line.borderDash),a.lineDashOffset=t.borderDashOffset||e.defaults.global.elements.line.borderDashOffset,a.lineJoin=t.borderJoinStyle||e.defaults.global.elements.line.borderJoinStyle,a.lineWidth=t.borderWidth||e.defaults.global.defaultColor,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(o._view.x,e._view.y),void a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,o._view.y),void a.moveTo(e._view.x,e._view.y)):o._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!s._view.skip&&(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),a.stroke(),a.restore()}})}.call(this),/*! +function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,a=this._chart.ctx,s=this._children[0],o=this._children[this._children.length-1];a.save(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(a.lineTo(o._view.x,e._view.y),a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop&&(a.moveTo(e._view.x,o._view.y),a.lineTo(e._view.x,e._view.y)),void(o._view.skip&&t.skipNull?a.moveTo(e._view.x,e._view.y):t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!s._view.skip?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),this._children.length>0&&t.fill&&(a.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),a.lineTo(this._children[0]._view.x,t.scaleZero),a.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,a.closePath(),a.fill()),a.lineCap=t.borderCapStyle||e.defaults.global.elements.line.borderCapStyle,a.setLineDash&&a.setLineDash(t.borderDash||e.defaults.global.elements.line.borderDash),a.lineDashOffset=t.borderDashOffset||e.defaults.global.elements.line.borderDashOffset,a.lineJoin=t.borderJoinStyle||e.defaults.global.elements.line.borderJoinStyle,a.lineWidth=t.borderWidth||e.defaults.global.elements.line.borderWidth,a.strokeStyle=t.borderColor||e.defaults.global.defaultColor,a.beginPath(),i.each(this._children,function(e,s){var o=i.previousItem(this._children,s),n=i.nextItem(this._children,s);return 0===s?void a.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(a.moveTo(o._view.x,e._view.y),void a.moveTo(n._view.x,e._view.y)):o._view.skip&&t.skipNull&&!this._loop?(a.moveTo(e._view.x,o._view.y),void a.moveTo(e._view.x,e._view.y)):o._view.skip&&t.skipNull?void a.moveTo(e._view.x,e._view.y):void(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):a.lineTo(e._view.x,e._view.y))},this),this._loop&&!s._view.skip&&(t.tension>0?a.bezierCurveTo(o._view.controlPointNextX,o._view.controlPointNextY,s._view.controlPointPreviousX,s._view.controlPointPreviousY,s._view.x,s._view.y):a.lineTo(s._view.x,s._view.y)),a.stroke(),a.restore()}})}.call(this),/*! * Chart.js * http://chartjs.org/ * Version: 2.0.0-alpha @@ -36,4 +36,4 @@ function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.eleme * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ -function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<% for (var i = 0; i < data.datasets[0].data.length; i++){%>
  • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
  • <%}%>'};e.Doughnut=function(t,s){return s.options=i.configMerge(a,s.options),s.type="doughnut",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={legendTemplate:'
      <% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    '};e.PolarArea=function(t,s){return s.options=i.configMerge(a,s.options),s.type="polarArea",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Radar=function(t,i){return i.type="radar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function a(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],a=t[1],s=t[2],o=i(t)[0],n=1/255*Math.min(e,Math.min(a,s)),s=1-1/255*Math.max(e,Math.max(a,s));return[o,100*n,100*s]}function o(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function n(t){return Z[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function l(t){var e,i,a,s=h(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function c(t){return L(l(t))}function u(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function d(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return s(u(t))}function p(t){return o(u(t))}function f(t){return n(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function x(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function y(t){return s(v(t))}function w(t){return o(v(t))}function C(t){return n(v(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(D(t))}function k(t){return a(D(t))}function S(t){return o(D(t))}function A(t){return n(D(t))}function P(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return i(P(t))}function M(t){return a(P(t))}function R(t){return s(P(t))}function W(t){return n(P(t))}function V(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function O(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return L(O(t))}function F(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function L(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function B(t){return V(F(t))}function T(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function E(t){return F(T(t))}function N(t){return B(T(t))}function H(t){return U[t]}function q(t){return i(H(t))}function j(t){return a(H(t))}function Y(t){return s(H(t))}function X(t){return o(H(t))}function J(t){return l(H(t))}function Q(t){return h(H(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:u,hsl2hsv:d,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:v,hsv2hsl:x,hsv2hwb:y,hsv2cmyk:w,hsv2keyword:C,hwb2rgb:D,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:A,cmyk2rgb:P,cmyk2hsl:I,cmyk2hsv:M,cmyk2hwb:R,cmyk2keyword:W,keyword2rgb:H,keyword2hsl:q,keyword2hsv:j,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:J,keyword2xyz:Q,xyz2rgb:V,xyz2lab:O,xyz2lch:z,lab2xyz:F,lab2rgb:B,lab2lch:L,lch2lab:T,lch2xyz:E,lch2rgb:N};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in U)Z[JSON.stringify(U[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),a=function(){return new h};for(var s in i){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),n=o[1],r=o[2];a[n]=a[n]||{},a[n][r]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return d(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function d(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return y[t.slice(0,3)]}function v(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:a,getRgb:o,getHsl:n,getHwb:s,getAlpha:r,hexString:h,rgbString:l,rgbaString:c,percentString:u,percentaString:d,hslString:g,hslaString:m,hwbString:p,keyword:f};var y={};for(var w in x)y[x[w]]=w},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file +function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view;if(i){var a=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,a=e.x-i,s=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(a+=n,s-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(a,e.base),t.lineTo(a,o),t.lineTo(s,o),t.lineTo(s,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view,a=!1;return i&&(a=i.y=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y),a},inLabelRange:function(t){var e=this._view;return e?t>=e.x-e.width/2&&t<=e.x+e.width/2:!1},tooltipPosition:function(){var t=this._view;return t.y<% for (var i = 0; i < data.datasets[0].data.length; i++){%>
  • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
  • <%}%>'};e.Doughnut=function(t,s){return s.options=i.configMerge(a,s.options),s.type="doughnut",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={legendTemplate:'
      <% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • <%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    '};e.PolarArea=function(t,s){return s.options=i.configMerge(a,s.options),s.type="polarArea",new e(t,s)}}.call(this),function(){"use strict";{var t=this,e=t.Chart;e.helpers}e.Radar=function(t,i){return i.type="radar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,a={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{template:"(<%= value.x %>, <%= value.y %>)",multiTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)"}};e.Scatter=function(t,s){return s.options=i.configMerge(a,s.options),s.type="line",new e(t,s)}}.call(this),!function t(e,i,a){function s(n,r){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};e[n][0].call(c.exports,function(t){var i=e[n][1][t];return s(i?i:t)},c,c.exports,t,e,i,a)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n=a?a/12.92:Math.pow((a+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,a=this.alpha()-t.alpha(),s=((i*a==-1?i:(i+a)/(1+i*a))+1)/2,o=1-s,n=this.rgbArray(),r=t.rgbArray(),h=0;he&&(e+=360),a=(r+h)/2,i=h==r?0:.5>=a?l/(h+r):l/(2-h-r),[e,100*i,100*a]}function a(t){var e,i,a,s=t[0],o=t[1],n=t[2],r=Math.min(s,o,n),h=Math.max(s,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:s==h?e=(o-n)/l:o==h?e=2+(n-s)/l:n==h&&(e=4+(s-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),a=h/255*1e3/10,[e,i,a]}function s(t){var e=t[0],a=t[1],s=t[2],o=i(t)[0],n=1/255*Math.min(e,Math.min(a,s)),s=1-1/255*Math.max(e,Math.max(a,s));return[o,100*n,100*s]}function o(t){var e,i,a,s,o=t[0]/255,n=t[1]/255,r=t[2]/255;return s=Math.min(1-o,1-n,1-r),e=(1-o-s)/(1-s)||0,i=(1-n-s)/(1-s)||0,a=(1-r-s)/(1-s)||0,[100*e,100*i,100*a,100*s]}function n(t){return Z[JSON.stringify(t)]}function h(t){var e=t[0]/255,i=t[1]/255,a=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var s=.4124*e+.3576*i+.1805*a,o=.2126*e+.7152*i+.0722*a,n=.0193*e+.1192*i+.9505*a;return[100*s,100*o,100*n]}function l(t){var e,i,a,s=h(t),o=s[0],n=s[1],r=s[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),a=200*(n-r),[e,i,a]}function c(t){return L(l(t))}function u(t){var e,i,a,s,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,s=[0,0,0];for(var l=0;3>l;l++)a=n+1/3*-(l-1),0>a&&a++,a>1&&a--,o=1>6*a?e+6*(i-e)*a:1>2*a?i:2>3*a?e+(i-e)*(2/3-a)*6:e,s[l]=255*o;return s}function d(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return o*=2,s*=1>=o?o:2-o,i=(o+s)/2,e=2*s/(o+s),[a,100*e,100*i]}function m(t){return s(u(t))}function p(t){return o(u(t))}function f(t){return n(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,a=t[2]/100,s=Math.floor(e)%6,o=e-Math.floor(e),n=255*a*(1-i),r=255*a*(1-i*o),h=255*a*(1-i*(1-o)),a=255*a;switch(s){case 0:return[a,h,n];case 1:return[r,a,n];case 2:return[n,a,h];case 3:return[n,r,a];case 4:return[h,n,a];case 5:return[a,n,r]}}function x(t){var e,i,a=t[0],s=t[1]/100,o=t[2]/100;return i=(2-s)*o,e=s*o,e/=1>=i?i:2-i,e=e||0,i/=2,[a,100*e,100*i]}function y(t){return s(v(t))}function w(t){return o(v(t))}function C(t){return n(v(t))}function D(t){var e,i,a,s,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,a=6*o-e,0!=(1&e)&&(a=1-a),s=n+a*(i-n),e){default:case 6:case 0:r=i,g=s,b=n;break;case 1:r=s,g=i,b=n;break;case 2:r=n,g=i,b=s;break;case 3:r=n,g=s,b=i;break;case 4:r=s,g=n,b=i;break;case 5:r=i,g=n,b=s}return[255*r,255*g,255*b]}function _(t){return i(D(t))}function k(t){return a(D(t))}function S(t){return o(D(t))}function A(t){return n(D(t))}function P(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,s*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),a=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*a]}function I(t){return i(P(t))}function M(t){return a(P(t))}function R(t){return s(P(t))}function W(t){return n(P(t))}function V(t){var e,i,a,s=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*s+-1.5372*o+n*-.4986,i=s*-.9689+1.8758*o+.0415*n,a=.0557*s+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),[255*e,255*i,255*a]}function O(t){var e,i,a,s=t[0],o=t[1],n=t[2];return s/=95.047,o/=100,n/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(s-o),a=200*(o-n),[e,i,a]}function z(t){return L(O(t))}function F(t){var e,i,a,s,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,s=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),s=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+s-16/116)/7.787:95.047*Math.pow(n/500+s,3),a=.008859>=a/108.883?a=108.883*(s-r/200-16/116)/7.787:108.883*Math.pow(s-r/200,3),[e,i,a]}function L(t){var e,i,a,s=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),a=Math.sqrt(o*o+n*n),[s,a,i]}function B(t){return V(F(t))}function T(t){var e,i,a,s=t[0],o=t[1],n=t[2];return a=n/360*2*Math.PI,e=o*Math.cos(a),i=o*Math.sin(a),[s,e,i]}function E(t){return F(T(t))}function H(t){return B(T(t))}function N(t){return U[t]}function q(t){return i(N(t))}function j(t){return a(N(t))}function Y(t){return s(N(t))}function X(t){return o(N(t))}function J(t){return l(N(t))}function Q(t){return h(N(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:s,rgb2cmyk:o,rgb2keyword:n,rgb2xyz:h,rgb2lab:l,rgb2lch:c,hsl2rgb:u,hsl2hsv:d,hsl2hwb:m,hsl2cmyk:p,hsl2keyword:f,hsv2rgb:v,hsv2hsl:x,hsv2hwb:y,hsv2cmyk:w,hsv2keyword:C,hwb2rgb:D,hwb2hsl:_,hwb2hsv:k,hwb2cmyk:S,hwb2keyword:A,cmyk2rgb:P,cmyk2hsl:I,cmyk2hsv:M,cmyk2hwb:R,cmyk2keyword:W,keyword2rgb:N,keyword2hsl:q,keyword2hsv:j,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:J,keyword2xyz:Q,xyz2rgb:V,xyz2lab:O,xyz2lch:z,lab2xyz:F,lab2rgb:B,lab2lch:L,lch2lab:T,lch2xyz:E,lch2rgb:H};var U={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in U)Z[JSON.stringify(U[$])]=$},{}],3:[function(t,e){var i=t("./conversions"),a=function(){return new h};for(var s in i){a[s+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(s);var o=/(\w+)2(\w+)/.exec(s),n=o[1],r=o[2];a[n]=a[n]||{},a[n][r]=a[s]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var s=0;se||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return d(t,e);var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgb("+i+"%, "+a+"%, "+s+"%)"}function d(t,e){var i=Math.round(t[0]/255*100),a=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return"rgba("+i+"%, "+a+"%, "+s+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?m(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function f(t){return y[t.slice(0,3)]}function v(t,e,i){return Math.min(Math.max(e,t),i)}function b(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var x=t("color-name");e.exports={getRgba:i,getHsla:a,getRgb:o,getHsl:n,getHwb:s,getAlpha:r,hexString:h,rgbString:l,rgbaString:c,percentString:u,percentaString:d,hslString:g,hslaString:m,hwbString:p,keyword:f};var y={};for(var w in x)y[x[w]]=w},{"color-name":5}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]); \ No newline at end of file From ef539bf4a70534e178f16e317fac01a308373065 Mon Sep 17 00:00:00 2001 From: Jan Kalina Date: Wed, 2 Sep 2015 23:14:12 +0200 Subject: [PATCH 283/424] Reverse scale on radar/polar area --- samples/polar-area.html | 6 +++++- samples/radar.html | 6 ++++++ samples/scatter-multi-axis.html | 1 + src/scales/scale.radialLinear.js | 18 +++++++++++++----- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/samples/polar-area.html b/samples/polar-area.html index e7c992d8ea5..89915530bc9 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -58,7 +58,11 @@

    Legend

    ] }, options: { - responsive: true + responsive: true, + scale: { + beginAtZero: true, + reverse: false + } } }; diff --git a/samples/radar.html b/samples/radar.html index b84b8458369..80b544e0d12 100644 --- a/samples/radar.html +++ b/samples/radar.html @@ -50,6 +50,12 @@

    Legend

    pointHighlightStroke: "rgba(151,187,205,1)", data: [null, randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }] + }, + options: { + scale: { + beginAtZero: true, + reverse: false + } } }; diff --git a/samples/scatter-multi-axis.html b/samples/scatter-multi-axis.html index a25c5f1b12a..e8af68cd475 100644 --- a/samples/scatter-multi-axis.html +++ b/samples/scatter-multi-axis.html @@ -111,6 +111,7 @@ type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance display: true, position: "right", + reverse: true, id: "y-axis-2", // grid line settings diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 0e9c763b30d..5c24bd5c668 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -27,6 +27,7 @@ }, // scale numbers + reverse: false, beginAtZero: true, // label settings @@ -94,6 +95,8 @@ helpers.each(this.data.datasets, function(dataset) { helpers.each(dataset.data, function(value, index) { + if (value === null) return; + if (this.min === null) { this.min = value; } else if (value < this.min) { @@ -327,9 +330,14 @@ return index * angleMultiplier - (Math.PI / 2); }, getDistanceFromCenterForValue: function(value) { + if (value === null) return 0; // null always in center // Take into account half font size + the yPadding of the top value var scalingFactor = this.drawingArea / (this.max - this.min); - return (value - this.min) * scalingFactor; + if (this.options.reverse) { + return (this.max - value) * scalingFactor; + } else { + return (value - this.min) * scalingFactor; + } }, getPointPosition: function(index, distanceFromCenter) { var thisAngle = this.getIndexAngle(index); @@ -345,8 +353,8 @@ if (this.options.display) { var ctx = this.ctx; helpers.each(this.yLabels, function(label, index) { - // Don't draw a centre value - if (index > 0) { + // Don't draw a centre value (if it is minimum) + if (index > 0 || this.options.reverse) { var yCenterOffset = this.getDistanceFromCenterForValue(this.ticks[index]); var yHeight = this.yCenter - yCenterOffset; @@ -405,7 +413,7 @@ for (var i = this.getValueCount() - 1; i >= 0; i--) { if (this.options.angleLines.show) { - var outerPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max)); + var outerPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.options.reverse ? this.min : this.max)); ctx.beginPath(); ctx.moveTo(this.xCenter, this.yCenter); ctx.lineTo(outerPosition.x, outerPosition.y); @@ -413,7 +421,7 @@ ctx.closePath(); } // Extra 3px out for some label spacing - var pointLabelPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.max) + 5); + var pointLabelPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.options.reverse ? this.min : this.max) + 5); ctx.font = helpers.fontString(this.options.pointLabels.fontSize, this.options.pointLabels.fontStyle, this.options.pointLabels.fontFamily); ctx.fillStyle = this.options.pointLabels.fontColor; From 2f38a3894a271167fda0a59a80384853ca5fe0ed Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 4 Sep 2015 22:55:41 -0400 Subject: [PATCH 284/424] Get resize listener helper --- gulpfile.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 42fd09b092e..d55101d52ed 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,7 +33,8 @@ var srcFiles = [ './src/scales/**', './src/elements/**', './src/charts/**', - './node_modules/color/dist/color.min.js' + './node_modules/color/dist/color.min.js', + './node_modules/javascript-detect-element-resize/detect-element-resize.js' ]; diff --git a/package.json b/package.json index 0e7b319399b..8295f2bde0b 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "inquirer": "^0.5.1", "jasmine": "^2.3.2", "jasmine-core": "^2.3.4", + "javascript-detect-element-resize": "git://github.com/chartjs/javascript-detect-element-resize.git", "jquery": "^2.1.4", "karma": "^0.12.37", "karma-chrome-launcher": "^0.2.0", From 6b6c388a1a2f97122f481625fd827d6ff5699489 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 4 Sep 2015 22:55:57 -0400 Subject: [PATCH 285/424] Helper for resize listener --- src/core/core.helpers.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 46ad752d882..1a299079ccc 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -758,6 +758,15 @@ } return window.Color(color); }, + addResizeListener = helpers.addResizeListener = function(node, callback) { + if (window.addResizeListener) { + if (node) { + window.addResizeListener(node, callback); + } + } else { + console.log('Add resize listener not found') + } + }, isArray = helpers.isArray = function(obj) { if (!Array.isArray) { return Object.prototype.toString.call(arg) === '[object Array]'; From 3f75aabbc5dfbffe72bec8aaba26ddee5f1d387b Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 5 Sep 2015 13:27:06 -0400 Subject: [PATCH 286/424] Better scale fitting algorithm to handle when label rotation changes due to the application of margins on the scale --- src/core/core.scale.js | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index c738f1f5853..1159a905029 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -219,6 +219,54 @@ } }); + // Recalculate because the size of each scale might have changed slightly due to the margins (label rotation for instance) + totalLeftWidth = xPadding; + totalRightWidth = xPadding; + totalTopHeight = yPadding; + totalBottomHeight = yPadding; + + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); + + helpers.each(rightScales, function(scaleInstance) { + totalRightWidth += scaleInstance.width; + }); + + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; + }); + helpers.each(bottomScales, function(scaleInstance) { + totalBottomHeight += scaleInstance.height; + }); + + // Figure out if our chart area changed. This would occur if the dataset scale label rotation + // changed due to the application of the margins in step 6. Since we can only get bigger, this is safe to do + // without calling `fit` again + var newMaxChartHeight = height - totalTopHeight - totalBottomHeight; + var newMaxChartWidth = width - totalLeftWidth - totalRightWidth; + + if (newMaxChartWidth !== maxChartWidth || newMaxChartHeight !== maxChartHeight) { + helpers.each(leftScales, function(scale) { + scale.height = newMaxChartHeight; + }); + + helpers.each(rightScales, function(scale) { + scale.height = newMaxChartHeight; + }); + + helpers.each(topScales, function(scale) { + scale.width = newMaxChartWidth; + }); + + helpers.each(bottomScales, function(scale) { + scale.width = newMaxChartWidth; + }); + + maxChartHeight = newMaxChartHeight; + maxChartWidth = newMaxChartWidth; + } + // Step 7 // Position the scales var left = xPadding; From a36a3f8c09b5424dbf4e140d08a5ceb24d7a5ecb Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Wed, 9 Sep 2015 20:28:34 -0400 Subject: [PATCH 287/424] Commit built version of scale algo changes --- Chart.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Chart.js b/Chart.js index 35a27e8dbbe..9e0cef3205d 100644 --- a/Chart.js +++ b/Chart.js @@ -1841,6 +1841,54 @@ } }); + // Recalculate because the size of each scale might have changed slightly due to the margins (label rotation for instance) + totalLeftWidth = xPadding; + totalRightWidth = xPadding; + totalTopHeight = yPadding; + totalBottomHeight = yPadding; + + helpers.each(leftScales, function(scaleInstance) { + totalLeftWidth += scaleInstance.width; + }); + + helpers.each(rightScales, function(scaleInstance) { + totalRightWidth += scaleInstance.width; + }); + + helpers.each(topScales, function(scaleInstance) { + totalTopHeight += scaleInstance.height; + }); + helpers.each(bottomScales, function(scaleInstance) { + totalBottomHeight += scaleInstance.height; + }); + + // Figure out if our chart area changed. This would occur if the dataset scale label rotation + // changed due to the application of the margins in step 6. Since we can only get bigger, this is safe to do + // without calling `fit` again + var newMaxChartHeight = height - totalTopHeight - totalBottomHeight; + var newMaxChartWidth = width - totalLeftWidth - totalRightWidth; + + if (newMaxChartWidth !== maxChartWidth || newMaxChartHeight !== maxChartHeight) { + helpers.each(leftScales, function(scale) { + scale.height = newMaxChartHeight; + }); + + helpers.each(rightScales, function(scale) { + scale.height = newMaxChartHeight; + }); + + helpers.each(topScales, function(scale) { + scale.width = newMaxChartWidth; + }); + + helpers.each(bottomScales, function(scale) { + scale.width = newMaxChartWidth; + }); + + maxChartHeight = newMaxChartHeight; + maxChartWidth = newMaxChartWidth; + } + // Step 7 // Position the scales var left = xPadding; From 98eea76195402b0908c7462eb6d40d779fb81a44 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 10 Sep 2015 22:46:07 -0600 Subject: [PATCH 288/424] Do not test on gulp watch --- gulpfile.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 42fd09b092e..c430de205a6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -176,7 +176,10 @@ function moduleSizesTask() { } function watchTask() { - gulp.watch('./src/**', ['build', 'unittest', 'unittestWatch']); + if (util.env.test) { + return gulp.watch('./src/**', ['build', 'unittest', 'unittestWatch']); + } + return gulp.watch('./src/**', ['build']); } function serverTask() { From 8762ae2f2806d7784b1b716e273827544abc53eb Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 10 Sep 2015 22:46:51 -0600 Subject: [PATCH 289/424] Add moment.js as dependency --- gulpfile.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index c430de205a6..09ce81eff16 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,7 +33,8 @@ var srcFiles = [ './src/scales/**', './src/elements/**', './src/charts/**', - './node_modules/color/dist/color.min.js' + './node_modules/color/dist/color.min.js', + './node_modules/moment/min/moment.min.js' ]; diff --git a/package.json b/package.json index 0e7b319399b..8b83a5731be 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "karma-firefox-launcher": "^0.1.6", "karma-jasmine": "^0.3.6", "karma-jasmine-html-reporter": "^0.1.8", + "moment": "^2.10.6", "onecolor": "^2.5.0", "semver": "^3.0.1" }, From fe5ef1584b7e10b4d584e553ecb949d7c8ccc5ec Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 10 Sep 2015 22:48:20 -0600 Subject: [PATCH 290/424] Add Line chart with time scale sample --- samples/line-time-scale.html | 162 +++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 samples/line-time-scale.html diff --git a/samples/line-time-scale.html b/samples/line-time-scale.html new file mode 100644 index 00000000000..266981ffe01 --- /dev/null +++ b/samples/line-time-scale.html @@ -0,0 +1,162 @@ + + + + + Line Chart + + + + + + +
    + +
    +
    +
    + + + + + +
    +

    Legend

    +
    +
    +
    + + + + From c2a7e4c251ccc117a7cdfe0a0947eb86652350f8 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 10 Sep 2015 22:48:48 -0600 Subject: [PATCH 291/424] Time Scale Base --- src/scales/scale.time.js | 405 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 405 insertions(+) create mode 100644 src/scales/scale.time.js diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js new file mode 100644 index 00000000000..dc36742ac5e --- /dev/null +++ b/src/scales/scale.time.js @@ -0,0 +1,405 @@ +(function() { + "use strict"; + + var root = this, + Chart = root.Chart, + helpers = Chart.helpers; + + var defaultConfig = { + display: true, + position: "bottom", + + // grid line settings + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, // draw ticks extending towards the label + }, + + time: { + format: false, // http://momentjs.com/docs/#/parsing/string-format/ + unit: false, // week, month, year, etc. + aggregation: 'average', + display: false, //http://momentjs.com/docs/#/parsing/string-format/ + unitFormats: { + 'millisecond': 'h:mm:ss SSS', // 11:20:01 002 + 'second': 'h:mm:ss', // 11:20:01 + 'minute': 'h:mm:ss a', // 11:20:01 AM + 'hour': 'MMM D, hA', // Sept 4, 5PM + 'day': 'll', // Sep 4 2015 8:30 PM + 'week': '[W]WW - YYYY', // Week 46 + 'month': 'MMM YYYY', // Sept 2015 + 'quarter': '[Q]Q - YYYY', // Q3 + 'year': 'YYYY' // 2015 + } + }, + + // scale numbers + reverse: false, + override: null, + + // label settings + labels: { + show: true, + mirror: false, + padding: 10, + template: "<%=value.toLocaleString()%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue" + } + }; + + var TimeScale = Chart.Element.extend({ + isHorizontal: function() { + return this.options.position == "top" || this.options.position == "bottom"; + }, + parseTime: function(label) { + if (typeof this.options.time.format !== 'string' && this.options.time.format.call) { + return this.options.time.format(label); + } else { + return moment(label, this.options.time.format); + } + }, + buildLabels: function(index) { + // Actual labels on the grid + this.labels = []; + // A map of original labelIndex to time labelIndex + this.timeLabelIndexMap = {}; + + var definedMoments = []; + + // Format each point into a moment + this.data.labels.forEach(function(label, index) { + definedMoments.push(this.parseTime(label)); + }, this); + + + // Find or set the unit of time + if (!this.options.time.unit) { + + // Determine the smallest needed unit of the time + helpers.each([ + 'millisecond', + 'second', + 'minute', + 'hour', + 'day', + 'week', + 'month', + 'quarter', + 'year', + ], function(format) { + if (this.timeUnit) { + return; + } + var start; + helpers.each(definedMoments, function(mom) { + if (!start) { + start = mom[format](); + } + + if (mom[format]() !== start) { + this.timeUnit = format; + if (!this.displayFormat) { + this.displayFormat = this.options.time.unitFormats[format]; + } + } + }, this); + }, this); + } else { + this.timeUnit = this.options.time.unit; + } + + if (!this.timeUnit) { + this.timeUnit = 'day'; + this.displayFormat = this.options.time.unitFormats.day; + } + + + if (this.options.time.display) { + this.displayFormat = this.options.time.display; + } + + + // Find the first and last moments + this.firstMoment = moment.min.call(this, definedMoments); + this.lastMoment = moment.max.call(this, definedMoments); + + // Find the length of the timeframe in the desired unit + var momentRangeLength = this.lastMoment.diff(this.firstMoment, this.timeUnit); + + helpers.each(definedMoments, function(definedMoment, index) { + this.timeLabelIndexMap[index] = momentRangeLength - this.lastMoment.diff(definedMoment, this.timeUnit); + }, this); + + // For every unit in between the first and last moment, create a moment and add it to the labels tick + var i = 0; + if (this.options.labels.userCallback) { + for (; i <= momentRangeLength; i++) { + this.labels.push( + this.options.labels.userCallback(this.firstMoment + .add((!i ? 0 : 1), this.timeUnit) + .format(this.options.time.display ? this.options.time.display : this.displayFormat) + ) + ); + } + } else { + for (; i <= momentRangeLength; i++) { + this.labels.push(this.firstMoment + .add((!i ? 0 : 1), this.timeUnit) + .format(this.options.time.display ? this.options.time.display : this.displayFormat) + ); + } + } + + + }, + getPixelForValue: function(value, index, datasetIndex, includeOffset) { + // This must be called after fit has been run so that + // this.left, this.top, this.right, and this.bottom have been defined + if (this.isHorizontal()) { + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (valueWidth * index) + this.paddingLeft; + + if (this.options.gridLines.offsetGridLines && includeOffset) { + valueOffset += (valueWidth / 2); + } + + return this.left + Math.round(valueOffset); + } else { + return this.top + (index * (this.height / this.labels.length)); + } + }, + getPointPixelForValue: function(value, index, datasetIndex) { + // This function references the timeLaabelIndexMap to know which index in the timeLabels corresponds to the index of original labels + return this.getPixelForValue(value, this.timeLabelIndexMap[index], datasetIndex, true); + }, + + // Functions needed for bar charts + calculateBaseWidth: function() { + return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); + }, + calculateBarWidth: function(barDatasetCount) { + //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset + var baseWidth = this.calculateBaseWidth() - ((barDatasetCount - 1) * this.options.spacing); + + if (this.options.stacked) { + return baseWidth; + } + return (baseWidth / barDatasetCount); + }, + calculateBarX: function(barDatasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), + xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), + barWidth = this.calculateBarWidth(barDatasetCount); + + if (this.options.stacked) { + return xAbsolute + barWidth / 2; + } + + return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; + }, + + calculateLabelRotation: function(maxHeight, margins) { + //Get the width of each grid by calculating the difference + //between x offsets between 0 and 1. + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + this.ctx.font = labelFont; + + var firstWidth = this.ctx.measureText(this.labels[0]).width; + var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + var firstRotated; + var lastRotated; + + this.paddingRight = lastWidth / 2 + 3; + this.paddingLeft = firstWidth / 2 + 3; + + this.labelRotation = 0; + + if (this.options.display) { + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var cosRotation; + var sinRotation; + var firstRotatedWidth; + + this.labelWidth = originalLabelWidth; + + //Allow 3 pixels x2 padding either side for label readability + // only the index matters for a dataset scale, but we want a consistent interface between scales + + var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + + //Max label rotation can be set or default to 90 - also act as a loop counter + while (this.labelWidth > datasetWidth && this.labelRotation <= this.options.labels.maxRotation) { + cosRotation = Math.cos(helpers.toRadians(this.labelRotation)); + sinRotation = Math.sin(helpers.toRadians(this.labelRotation)); + + firstRotated = cosRotation * firstWidth; + lastRotated = cosRotation * lastWidth; + + // We're right aligning the text now. + if (firstRotated + this.options.labels.fontSize / 2 > this.yLabelWidth) { + this.paddingLeft = firstRotated + this.options.labels.fontSize / 2; + } + + this.paddingRight = this.options.labels.fontSize / 2; + + if (sinRotation * originalLabelWidth > maxHeight) { + // go back one step + this.labelRotation--; + break; + } + + this.labelRotation++; + this.labelWidth = cosRotation * originalLabelWidth; + + } + } else { + this.labelWidth = 0; + this.paddingRight = 0; + this.paddingLeft = 0; + } + + if (margins) { + this.paddingLeft -= margins.left; + this.paddingRight -= margins.right; + + this.paddingLeft = Math.max(this.paddingLeft, 0); + this.paddingRight = Math.max(this.paddingRight, 0); + } + + }, + // Fit this axis to the given size + // @param {number} maxWidth : the max width the axis can be + // @param {number} maxHeight: the max height the axis can be + // @return {object} minSize : the minimum size needed to draw the axis + fit: function(maxWidth, maxHeight, margins) { + // Set the unconstrained dimension before label rotation + if (this.isHorizontal()) { + this.width = maxWidth; + } else { + this.height = maxHeight; + } + + this.buildLabels(); + this.calculateLabelRotation(maxHeight, margins); + + var minSize = { + width: 0, + height: 0, + }; + + var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + + // Width + if (this.isHorizontal()) { + minSize.width = maxWidth; + } else if (this.options.display) { + var labelWidth = this.options.labels.show ? longestLabelWidth + 6 : 0; + minSize.width = Math.min(labelWidth, maxWidth); + } + + // Height + if (this.isHorizontal() && this.options.display) { + var labelHeight = (Math.sin(helpers.toRadians(this.labelRotation)) * longestLabelWidth) + 1.5 * this.options.labels.fontSize; + minSize.height = Math.min(this.options.labels.show ? labelHeight : 0, maxHeight); + } else if (this.options.display) { + minSize.height = maxHeight; + } + + this.width = minSize.width; + this.height = minSize.height; + return minSize; + }, + // Actualy draw the scale on the canvas + // @param {rectangle} chartArea : the area of the chart to draw full grid lines on + draw: function(chartArea) { + if (this.options.display) { + + var setContextLineSettings; + + // Make sure we draw text in the correct color + this.ctx.fillStyle = this.options.labels.fontColor; + + if (this.isHorizontal()) { + setContextLineSettings = true; + var yTickStart = this.options.position == "bottom" ? this.top : this.bottom - 10; + var yTickEnd = this.options.position == "bottom" ? this.top + 10 : this.bottom; + var isRotated = this.labelRotation !== 0; + var skipRatio = false; + + if ((this.options.labels.fontSize + 4) * this.labels.length > (this.width - (this.paddingLeft + this.paddingRight))) { + skipRatio = 1 + Math.floor(((this.options.labels.fontSize + 4) * this.labels.length) / (this.width - (this.paddingLeft + this.paddingRight))); + } + + helpers.each(this.labels, function(label, index) { + // Blank labels + if ((skipRatio > 1 && index % skipRatio > 0) || (label === undefined || label === null)) { + return; + } + var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) + + if (this.options.gridLines.show) { + if (index === 0) { + // Draw the first index specially + this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; + this.ctx.strokeStyle = this.options.gridLines.zeroLineColor; + setContextLineSettings = true; // reset next time + } else if (setContextLineSettings) { + this.ctx.lineWidth = this.options.gridLines.lineWidth; + this.ctx.strokeStyle = this.options.gridLines.color; + setContextLineSettings = false; + } + + xLineValue += helpers.aliasPixel(this.ctx.lineWidth); + + // Draw the label area + this.ctx.beginPath(); + + if (this.options.gridLines.drawTicks) { + this.ctx.moveTo(xLineValue, yTickStart); + this.ctx.lineTo(xLineValue, yTickEnd); + } + + // Draw the chart area + if (this.options.gridLines.drawOnChartArea) { + this.ctx.moveTo(xLineValue, chartArea.top); + this.ctx.lineTo(xLineValue, chartArea.bottom); + } + + // Need to stroke in the loop because we are potentially changing line widths & colours + this.ctx.stroke(); + } + + if (this.options.labels.show) { + this.ctx.save(); + this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.top + 8); + this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1); + this.ctx.font = this.font; + this.ctx.textAlign = (isRotated) ? "right" : "center"; + this.ctx.textBaseline = (isRotated) ? "middle" : "top"; + this.ctx.fillText(label, 0, 0); + this.ctx.restore(); + } + }, this); + } else { + // Vertical + if (this.options.gridLines.show) {} + + if (this.options.labels.show) { + // Draw the labels + } + } + } + } + }); + Chart.scaleService.registerScaleType("time", TimeScale, defaultConfig); + +}).call(this); From 88d30d8c935bdeddc589fe7bc736be1263863b68 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 11 Sep 2015 12:20:32 -0600 Subject: [PATCH 292/424] Let tooltips use time formatted labels if they exist --- src/core/core.tooltip.js | 6 +++++- src/scales/scale.time.js | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 3f4a892c41a..92e2b136463 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -164,7 +164,11 @@ x: medianPosition.x, y: medianPosition.y, labels: labels, - title: this._data.labels && this._data.labels.length ? this._data.labels[this._active[0]._index] : '', + title: (function() { + return this._data.timeLabels ? this._data.timeLabels[this._active[0]._index] : + (this._data.labels && this._data.labels.length) ? this._data.labels[this._active[0]._index] : + ''; + }).call(this), legendColors: colors, legendBackgroundColor: this._options.tooltips.multiKeyBackground, }); diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index dc36742ac5e..cbf6473ca6e 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -69,6 +69,8 @@ this.labels = []; // A map of original labelIndex to time labelIndex this.timeLabelIndexMap = {}; + // The time formatted versions of the labels for use by tooltips + this.data.timeLabels = []; var definedMoments = []; @@ -134,6 +136,10 @@ helpers.each(definedMoments, function(definedMoment, index) { this.timeLabelIndexMap[index] = momentRangeLength - this.lastMoment.diff(definedMoment, this.timeUnit); + this.data.timeLabels.push( + definedMoment + .format(this.options.time.display ? this.options.time.display : this.displayFormat) + ); }, this); // For every unit in between the first and last moment, create a moment and add it to the labels tick From e6220f474b8f6755592ea72860cb953db6197fa5 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 14 Sep 2015 18:50:52 -0400 Subject: [PATCH 293/424] Attempting to make resize better --- samples/bar.html | 21 +++++++++-- src/charts/Chart.Doughnut.js | 1 + src/charts/Chart.PolarArea.js | 1 + src/charts/Chart.Radar.js | 5 +++ src/core/core.controller.js | 22 ++++++------ src/core/core.helpers.js | 68 +++++++++++++++++++++++++++-------- src/core/core.js | 43 +++++++++++----------- src/core/core.responsive.js | 4 +-- 8 files changed, 115 insertions(+), 50 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index eb8796ac5cb..7f1d8e7eabf 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -5,10 +5,15 @@ Bar Chart + -
    + @@ -16,6 +21,7 @@ +

    Legend

    @@ -64,6 +70,13 @@

    Legend

    data: barChartData, options: { responsive: true, + scales: { + xAxes: [{ + // So that bars fill the entire width of the grid + categorySpacing: 0, + spacing: 0 + }] + } } }); @@ -100,7 +113,7 @@

    Legend

    $('#addData').click(function() { if (barChartData.datasets.length > 0) { - barChartData.labels.push('dataset #' + barChartData.labels.length); + barChartData.labels.push('data #' + barChartData.labels.length); for (var index = 0; index < barChartData.datasets.length; ++index) { window.myBar.addData(randomScalingFactor(), index); @@ -123,6 +136,10 @@

    Legend

    }); updateLegend(); }); + + $('#show').click(function() { + document.getElementById('container').style.display = ''; + }); diff --git a/src/charts/Chart.Doughnut.js b/src/charts/Chart.Doughnut.js index ccea714f31d..333a0bbebeb 100644 --- a/src/charts/Chart.Doughnut.js +++ b/src/charts/Chart.Doughnut.js @@ -6,6 +6,7 @@ var helpers = Chart.helpers; var defaultConfig = { + aspectRatio: 1, legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • \"><%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    ", }; diff --git a/src/charts/Chart.PolarArea.js b/src/charts/Chart.PolarArea.js index 7070a0d8f24..9dbdf1b39a1 100644 --- a/src/charts/Chart.PolarArea.js +++ b/src/charts/Chart.PolarArea.js @@ -6,6 +6,7 @@ var helpers = Chart.helpers; var defaultConfig = { + aspectRatio: 1, legendTemplate: "
      -legend\"><% for (var i = 0; i < data.datasets[0].data.length; i++){%>
    • \"><%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%>
    • <%}%>
    ", }; diff --git a/src/charts/Chart.Radar.js b/src/charts/Chart.Radar.js index f5580783d66..2f1f8260620 100644 --- a/src/charts/Chart.Radar.js +++ b/src/charts/Chart.Radar.js @@ -5,7 +5,12 @@ var Chart = root.Chart; var helpers = Chart.helpers; + var defaultConfig = { + aspectRatio: 1, + }; + Chart.Radar = function(context, config) { + config.options = helpers.configMerge(defaultConfig, config.options); config.type = 'radar'; return new Chart(context, config); diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 5b611e8ea4b..b621d6f1ece 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -123,9 +123,11 @@ resize: function resize(silent) { this.stop(); - var canvas = this.chart.canvas, - newWidth = helpers.getMaximumWidth(this.chart.canvas), - newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : helpers.getMaximumHeight(this.chart.canvas); + var canvas = this.chart.canvas; + var newWidth = helpers.getMaximumWidth(this.chart.canvas); + var newHeight = (this.options.maintainAspectRatio && isNaN(this.chart.aspectRatio) === false && isFinite(this.chart.aspectRatio) && this.chart.aspectRatio !== 0) + ? newWidth / this.chart.aspectRatio + : helpers.getMaximumHeight(this.chart.canvas); canvas.width = this.chart.width = newWidth; canvas.height = this.chart.height = newHeight; @@ -346,19 +348,15 @@ destroy: function destroy() { this.clear(); helpers.unbindEvents(this, this.events); - var canvas = this.chart.canvas; - // Reset canvas height/width attributes starts a fresh with the canvas context + // Reset canvas height/width attributes + var canvas = this.chart.canvas; 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'); + // if we scaled the canvas in response to a devicePixelRatio !== 1, we need to undo that transform here + if (this.chart.originalDevicePixelRatio !== undefined) { + canvas.scale(1 / this.chart.originalDevicePixelRatio, 1 / this.chart.originalDevicePixelRatio); } delete Chart.instances[this.id]; diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 1a299079ccc..b967b30b697 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -691,17 +691,54 @@ removeEvent(chartInstance.chart.canvas, eventName, handler); }); }, + getConstraintWidth = helpers.getConstraintWidth = function(domNode) { // returns Number or undefined if no constraint + var constrainedWidth; + var constrainedWNode = document.defaultView.getComputedStyle(domNode)['max-width']; + var constrainedWContainer = document.defaultView.getComputedStyle(domNode.parentNode)['max-width']; + var hasCWNode = constrainedWNode !== null && constrainedWNode !== "none"; + var hasCWContainer = constrainedWContainer !== null && constrainedWContainer !== "none"; + + if (hasCWNode || hasCWContainer) { + constrainedWidth = Math.min((hasCWNode ? parseInt(constrainedWNode, 10) : Number.POSITIVE_INFINITY), (hasCWContainer ? parseInt(constrainedWContainer, 10) : Number.POSITIVE_INFINITY)); + } + return constrainedWidth; + }, + getConstraintHeight = helpers.getConstraintHeight = function(domNode) { // returns Number or undefined if no constraint + + var constrainedHeight; + var constrainedHNode = document.defaultView.getComputedStyle(domNode)['max-height']; + var constrainedHContainer = document.defaultView.getComputedStyle(domNode.parentNode)['max-height']; + var hasCHNode = constrainedHNode !== null && constrainedHNode !== "none"; + var hasCHContainer = constrainedHContainer !== null && constrainedHContainer !== "none"; + + if (constrainedHNode || constrainedHContainer) { + constrainedHeight = Math.min((hasCHNode ? parseInt(constrainedHNode, 10) : Number.POSITIVE_INFINITY), (hasCHContainer ? parseInt(constrainedHContainer, 10) : Number.POSITIVE_INFINITY)); + } + return constrainedHeight; + }, getMaximumWidth = helpers.getMaximumWidth = function(domNode) { - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); - // TODO = check cross browser stuff with this. - return container.clientWidth - padding; + var container = domNode.parentNode; + var padding = parseInt(getStyle(container, 'padding-left')) + parseInt(getStyle(container, 'padding-right')); + + var w = container.clientWidth - padding; + var cw = getConstraintWidth(domNode); + if (cw !== undefined) { + w = Math.min(w, cw); + } + + return w; }, getMaximumHeight = helpers.getMaximumHeight = function(domNode) { - var container = domNode.parentNode, - padding = parseInt(getStyle(container, 'padding-bottom')) + parseInt(getStyle(container, 'padding-top')); - // TODO = check cross browser stuff with this. - return container.clientHeight - padding; + var container = domNode.parentNode; + var padding = parseInt(getStyle(container, 'padding-top')) + parseInt(getStyle(container, 'padding-bottom')); + + var h = container.clientHeight - padding; + var ch = getConstraintHeight(domNode); + if (ch !== undefined) { + h = Math.min(h, ch); + } + + return h; }, getStyle = helpers.getStyle = function(el, property) { return el.currentStyle ? @@ -710,16 +747,19 @@ }, getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support retinaScale = helpers.retinaScale = function(chart) { - var ctx = chart.ctx, - width = chart.canvas.width, - height = chart.canvas.height; + var ctx = chart.ctx; + var width = chart.canvas.width; + var height = chart.canvas.height; - if (window.devicePixelRatio) { - ctx.canvas.style.width = width + "px"; - ctx.canvas.style.height = height + "px"; + if (window.devicePixelRatio !== 1) { ctx.canvas.height = height * window.devicePixelRatio; ctx.canvas.width = width * window.devicePixelRatio; ctx.scale(window.devicePixelRatio, window.devicePixelRatio); + + // Store the device pixel ratio so that we can go backwards in `destroy`. + // The devicePixelRatio changes with zoom, so there are no guarantees that it is the same + // when destroy is called + chart.originalDevicePixelRatio = window.devicePixelRatio; } }, //-- Canvas methods diff --git a/src/core/core.js b/src/core/core.js index 42c214e1444..512b4f42e5e 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -19,7 +19,6 @@ //Occupy the global variable of Chart, and create a simple base class var Chart = function(context, config) { - var chart = this; this.config = config; // Support a jQuery'd canvas element @@ -32,32 +31,36 @@ context = context.getContext("2d"); } + this.ctx = context; this.canvas = context.canvas; - this.ctx = context; + // Figure out what the size of the chart will be. + // If the canvas has a specified width and height, we use those else + // we look to see if the canvas node has a CSS width and height. + // If there is still no height, fill the parent container + this.width = context.canvas.width || parseInt(Chart.helpers.getStyle(context.canvas, 'width')) || Chart.helpers.getMaximumWidth(context.canvas); + this.height = context.canvas.height || parseInt(Chart.helpers.getStyle(context.canvas, 'height')) || Chart.helpers.getMaximumHeight(context.canvas); - //Variables global to the chart - var computeDimension = function(element, dimension) { - if (element['offset' + dimension]) { - return element['offset' + dimension]; - } else { - return document.defaultView.getComputedStyle(element).getPropertyValue(dimension); - } - }; - - var width = this.width = computeDimension(context.canvas, 'Width') || context.canvas.width; - var height = this.height = computeDimension(context.canvas, 'Height') || context.canvas.height; + this.aspectRatio = this.width / this.height; - // Firefox requires this to work correctly - context.canvas.width = width; - context.canvas.height = height; + if (isNaN(this.aspectRatio) || isFinite(this.aspectRatio) === false) { + // If the canvas has no size, try and figure out what the aspect ratio will be. + // Some charts prefer square canvases (pie, radar, etc). If that is specified, use that + // else use the canvas default ratio of 2 + this.aspectRatio = config.aspectRatio !== undefined ? config.aspectRatio : 2; + } - width = this.width = context.canvas.width; - height = this.height = context.canvas.height; - this.aspectRatio = this.width / this.height; - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. + // High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. Chart.helpers.retinaScale(this); + // Always bind this so that if the responsive state changes we still work + var _this = this; + Chart.helpers.addResizeListener(context.canvas.parentNode, function() { + if (config.options.responsive) { + _this.controller.resize(); + } + }); + if (config) { this.controller = new Chart.Controller(this); return this.controller; diff --git a/src/core/core.responsive.js b/src/core/core.responsive.js index 7a2eb78c751..2bca2a21442 100644 --- a/src/core/core.responsive.js +++ b/src/core/core.responsive.js @@ -9,7 +9,7 @@ // Attach global event to resize each chart instance when the browser resizes - helpers.addEvent(window, "resize", (function() { + /*helpers.addEvent(window, "resize", (function() { // Basic debounce of resize function so it doesn't hurt performance when resizing browser. var timeout; return function() { @@ -24,6 +24,6 @@ }); }, 16); }; - })()); + })());*/ }).call(this); From b172a382f1f04b7c163d336364cdfcf1960a8a9d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 14 Sep 2015 19:45:13 -0400 Subject: [PATCH 294/424] Remove dead code in logarithmic scale. Fixed a padding bug that had previously been fixed in the linear scale --- src/scales/scale.logarithmic.js | 48 +-------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index 68897a9509d..7294cd522d4 100644 --- a/src/scales/scale.logarithmic.js +++ b/src/scales/scale.logarithmic.js @@ -75,9 +75,6 @@ var maxExponent = Math.ceil(helpers.log10(this.max)); for (var exponent = minExponent; exponent < maxExponent; ++exponent) { - /*this.ticks.push(1.0 * Math.pow(10, exponent)); - this.ticks.push(2.0 * Math.pow(10, exponent)); - this.ticks.push(5.0 * Math.pow(10, exponent));*/ for (var i = 1; i < 10; ++i) { if (i === 1 || i === 2 || i === 3 || i === 5 || i === 7) { this.ticks.push(i * Math.pow(10, exponent)); @@ -86,48 +83,6 @@ } this.ticks.push(1.0 * Math.pow(10, maxExponent)); - - /*var maxTicks; - - if (this.isHorizontal()) { - maxTicks = Math.min(11, Math.ceil(width / 50)); - } else { - // The factor of 2 used to scale the font size has been experimentally determined. - maxTicks = Math.min(11, Math.ceil(height / (2 * this.options.labels.fontSize))); - } - - // Make sure we always have at least 2 ticks - maxTicks = Math.max(2, maxTicks); - - // To get a "nice" value for the tick spacing, we will use the appropriately named - // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - // If we are forcing it to begin at 0, but 0 will already be rendered on the chart, - // do nothing since that would make the chart weird. If the user really wants a weird chart - // axis, they can manually override it - if (this.options.beginAtZero) { - var minSign = helpers.sign(this.min); - var maxSign = helpers.sign(this.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - this.max = 0; - } else if (minSign > 0 && maxSign > 0) { - // move the botttom down to 0 - this.min = 0; - } - } - - var niceRange = helpers.niceNum(this.max - this.min, false); - var spacing = helpers.niceNum(niceRange / (maxTicks - 1), true); - var niceMin = Math.floor(this.min / spacing) * spacing; - var niceMax = Math.ceil(this.max / spacing) * spacing; - - // Put the values into the ticks array - for (var j = niceMin; j <= niceMax; j += spacing) { - this.ticks.push(j); - }*/ } if (this.options.position == "left" || this.options.position == "right") { @@ -195,8 +150,7 @@ pixel = this.top + this.paddingTop; } else { var innerHeight = this.height - (this.paddingTop + this.paddingBottom); - pixel = this.bottom - (innerHeight / range * (helpers.log10(value) - helpers.log10(this.start))); - pixel += this.paddingTop; + pixel = (this.bottom - this.paddingBottom) - (innerHeight / range * (helpers.log10(value) - helpers.log10(this.start))); } } From e0cdfc6d2d3f512258da94ab5fd8b1360a43a138 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 14 Sep 2015 19:46:28 -0400 Subject: [PATCH 295/424] Update logarithmic sample. Created a new logarithmic sample using AC circuit simulation data of an RLC filter. --- samples/line-logarithmic.html | 2 +- samples/scatter-logX.html | 162 ++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 samples/scatter-logX.html diff --git a/samples/line-logarithmic.html b/samples/line-logarithmic.html index 1123c23002b..8a249ba9682 100644 --- a/samples/line-logarithmic.html +++ b/samples/line-logarithmic.html @@ -31,7 +31,7 @@

    Legend

    + + + + +
    +
    + +
    +
    + + + + From c1f0a39982e0595e2022df9365a68f39173fea20 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 14 Sep 2015 20:32:23 -0400 Subject: [PATCH 296/424] Fixes to show all lines but not all labels. Added a variable in the template function to make debugging nicer. --- samples/scatter-logX.html | 6 +++++- src/core/core.helpers.js | 7 +++---- src/scales/scale.logarithmic.js | 12 ++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/samples/scatter-logX.html b/samples/scatter-logX.html index 976684f5c31..d8d00c85c71 100644 --- a/samples/scatter-logX.html +++ b/samples/scatter-logX.html @@ -140,7 +140,11 @@ position: 'bottom', labels: { userCallback: function(tick) { - return tick.toString() + "Hz"; + var remain = tick / (Math.pow(10, Math.floor(Chart.helpers.log10(tick)))); + if (remain === 1 || remain === 2 || remain === 5) { + return tick.toString() + "Hz"; + } + return ''; } } }], diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 46ad752d882..ab58b0789dc 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -387,8 +387,7 @@ } else { // Generate a reusable function that will serve as a template // generator (and which will be cached). - fn = new Function("obj", - "var p=[],print=function(){p.push.apply(p,arguments);};" + + var functionCode = "var p=[],print=function(){p.push.apply(p,arguments);};" + // Introduce the data as local variables using with(){} "with(obj){p.push('" + @@ -402,8 +401,8 @@ .split("\t").join("');") .split("%>").join("p.push('") .split("\r").join("\\'") + - "');}return p.join('');" - ); + "');}return p.join('');"; + fn = new Function("obj", functionCode); // Cache the result templateStringCache[str] = fn; diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index 7294cd522d4..a8d9706b937 100644 --- a/src/scales/scale.logarithmic.js +++ b/src/scales/scale.logarithmic.js @@ -30,7 +30,7 @@ show: true, mirror: false, padding: 10, - template: "<%=value.toExponential()%>", + template: "<%var remain = value / (Math.pow(10, Math.floor(Chart.helpers.log10(value))));if (remain === 1 || remain === 2 || remain === 5) {%><%=value.toExponential()%><%} else {%><%= null %><%}%>", fontSize: 12, fontStyle: "normal", fontColor: "#666", @@ -76,9 +76,7 @@ for (var exponent = minExponent; exponent < maxExponent; ++exponent) { for (var i = 1; i < 10; ++i) { - if (i === 1 || i === 2 || i === 3 || i === 5 || i === 7) { - this.ticks.push(i * Math.pow(10, exponent)); - } + this.ticks.push(i * Math.pow(10, exponent)); } } @@ -123,7 +121,7 @@ }); } - this.labels.push(label ? label : ""); // empty string will not render so we're good + this.labels.push(label); // empty string will not render so we're good }, this); }, // Get the correct value. If the value type is object get the x or y based on whether we are horizontal or not @@ -506,7 +504,9 @@ helpers.each(this.labels, function(label, index) { var xValue = this.getPixelForValue(this.ticks[index]); - this.ctx.fillText(label, xValue, labelStartY); + if (label) { + this.ctx.fillText(label, xValue, labelStartY); + } }, this); } } else { From eb657bce36f470d632c95072f0a0bcdafb4933f8 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 14 Sep 2015 20:34:49 -0400 Subject: [PATCH 297/424] Hide labels when the user returns null from the userCallback. This is the same as the category scale --- src/scales/scale.logarithmic.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index a8d9706b937..7d0f181c99d 100644 --- a/src/scales/scale.logarithmic.js +++ b/src/scales/scale.logarithmic.js @@ -453,6 +453,11 @@ // Grid lines are vertical var xValue = this.getPixelForValue(tick); + if (this.labels[index] === null) { + // If the user specifically hid the label by returning null from the label function, do so + return; + } + if (tick === 0 || (!hasZero && index === 0)) { // Draw the 0 point specially or the left if there is no 0 this.ctx.lineWidth = this.options.gridLines.zeroLineWidth; From 2598446d54de0e15f832729843e1d2c9bc244e35 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 15 Sep 2015 11:40:01 -0600 Subject: [PATCH 298/424] Time Scale Rewrite --- samples/line-time-scale.html | 23 +++- src/scales/scale.time.js | 260 +++++++++++++++++++---------------- 2 files changed, 162 insertions(+), 121 deletions(-) diff --git a/samples/line-time-scale.html b/samples/line-time-scale.html index 266981ffe01..01df3a4e2d7 100644 --- a/samples/line-time-scale.html +++ b/samples/line-time-scale.html @@ -38,12 +38,21 @@

    Legend

    var randomColor = function(opacity) { return 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',' + (opacity || '.3') + ')'; }; + var newDate = function(days) { + var date = new Date(); + return date.setDate(date.getDate() + days); + }; + var newTimestamp = function(days) { + return Date.now() - days * 100000; + }; var config = { type: 'line', data: { - // labels: ["01/01/2015 20:00", "01/02/2015 21:00", "01/03/2015 22:00", "01/06/2015 23:00", "01/15/2015 03:00", "01/17/2015 10:00", "01/30/2015 11:00"], // Hours - labels: ["01/01/2015", "01/02/2015", "01/03/2015", "01/06/2015", "01/15/2015", "01/17/2015", "01/30/2015"], // Days + //labels: [newTimestamp(0), newTimestamp(1), newTimestamp(2), newTimestamp(3), newTimestamp(4), newTimestamp(5), newTimestamp(6)], // unix timestamps + // labels: [newDate(0), newDate(1), newDate(2), newDate(3), newDate(4), newDate(5), newDate(6)], // Date Objects + labels: ["01/01/2015 20:00", "01/02/2015 21:00", "01/03/2015 22:00", "01/05/2015 23:00", "01/07/2015 03:00", "01/08/2015 10:00", "02/1/2015"], // Hours + // labels: ["01/01/2015", "01/02/2015", "01/03/2015", "01/06/2015", "01/15/2015", "01/17/2015", "01/30/2015"], // Days // labels: ["12/25/2014", "01/08/2015", "01/15/2015", "01/22/2015", "01/29/2015", "02/05/2015", "02/12/2015"], // Weeks datasets: [{ label: "My First dataset", @@ -61,14 +70,20 @@

    Legend

    xAxes: [{ type: "time", display: true, - time: { + tick: { format: 'MM/DD/YYYY HH:mm', + // round: 'day' } }, ], yAxes: [{ display: true }] - } + }, + elements: { + line: { + tension: 0 + } + }, } }; diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index cbf6473ca6e..18df1a6ac8f 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -5,6 +5,58 @@ Chart = root.Chart, helpers = Chart.helpers; + var time = { + units: [ + 'millisecond', + 'second', + 'minute', + 'hour', + 'day', + 'week', + 'month', + 'quarter', + 'year', + ], + unit: { + 'millisecond': { + display: 'SSS [ms]', // 002 ms + maxStep: 1000, + }, + 'second': { + display: 'h:mm:ss a', // 11:20:01 AM + maxStep: 60, + }, + 'minute': { + display: 'h:mm:ss a', // 11:20:01 AM + maxStep: 60, + }, + 'hour': { + display: 'MMM D, hA', // Sept 4, 5PM + maxStep: 24, + }, + 'day': { + display: 'll', // Sep 4 2015 + maxStep: 7, + }, + 'week': { + display: 'll', // Week 46, or maybe "[W]WW - YYYY" ? + maxStep: 4.3333, + }, + 'month': { + display: 'MMM YYYY', // Sept 2015 + maxStep: 12, + }, + 'quarter': { + display: '[Q]Q - YYYY', // Q3 + maxStep: 4, + }, + 'year': { + display: 'YYYY', // 2015 + maxStep: false, + }, + } + }; + var defaultConfig = { display: true, position: "bottom", @@ -18,22 +70,11 @@ drawTicks: true, // draw ticks extending towards the label }, - time: { - format: false, // http://momentjs.com/docs/#/parsing/string-format/ - unit: false, // week, month, year, etc. - aggregation: 'average', - display: false, //http://momentjs.com/docs/#/parsing/string-format/ - unitFormats: { - 'millisecond': 'h:mm:ss SSS', // 11:20:01 002 - 'second': 'h:mm:ss', // 11:20:01 - 'minute': 'h:mm:ss a', // 11:20:01 AM - 'hour': 'MMM D, hA', // Sept 4, 5PM - 'day': 'll', // Sep 4 2015 8:30 PM - 'week': '[W]WW - YYYY', // Week 46 - 'month': 'MMM YYYY', // Sept 2015 - 'quarter': '[Q]Q - YYYY', // Q3 - 'year': 'YYYY' // 2015 - } + tick: { + format: false, // false == date objects or use pattern string from http://momentjs.com/docs/#/parsing/string-format/ + unit: false, // false == automatic or override with week, month, year, etc. + round: false, // none, or override with week, month, year, etc. + displayFormat: false, // defaults to unit's corresponding unitFormat below or override using pattern string from http://momentjs.com/docs/#/displaying/format/ }, // scale numbers @@ -49,7 +90,8 @@ fontSize: 12, fontStyle: "normal", fontColor: "#666", - fontFamily: "Helvetica Neue" + fontFamily: "Helvetica Neue", + maxRotation: 45, } }; @@ -58,119 +100,100 @@ return this.options.position == "top" || this.options.position == "bottom"; }, parseTime: function(label) { - if (typeof this.options.time.format !== 'string' && this.options.time.format.call) { - return this.options.time.format(label); - } else { - return moment(label, this.options.time.format); + // Date objects + if (typeof label.getMonth === 'function' || typeof label == 'number') { + return moment(label); + } + // Moment support + if (label.isValid && label.isValid()) { + return label; } + // Custom parsing (return an instance of moment) + if (typeof this.options.tick.format !== 'string' && this.options.tick.format.call) { + return this.options.tick.format(label); + } + // Moment format parsing + return moment(label, this.options.tick.format); }, - buildLabels: function(index) { - // Actual labels on the grid - this.labels = []; - // A map of original labelIndex to time labelIndex - this.timeLabelIndexMap = {}; - // The time formatted versions of the labels for use by tooltips - this.data.timeLabels = []; + generateTicks: function(index) { - var definedMoments = []; + this.ticks = []; + this.labelMoments = []; - // Format each point into a moment + // Parse each label into a moment this.data.labels.forEach(function(label, index) { - definedMoments.push(this.parseTime(label)); + var labelMoment = this.parseTime(label); + if (this.options.tick.round) { + labelMoment.startOf(this.options.tick.round); + } + this.labelMoments.push(labelMoment); }, this); + // Find the first and last moments, and range + this.firstTick = moment.min.call(this, this.labelMoments).clone(); + this.lastTick = moment.max.call(this, this.labelMoments).clone(); - // Find or set the unit of time - if (!this.options.time.unit) { - + // Set unit override if applicable + if (this.options.tick.unit) { + this.tickUnit = this.options.tick.unit || 'day'; + this.displayFormat = time.unit.day.display; + this.tickRange = Math.ceil(this.lastTick.diff(this.firstTick, this.tickUnit, true)); + } else { // Determine the smallest needed unit of the time - helpers.each([ - 'millisecond', - 'second', - 'minute', - 'hour', - 'day', - 'week', - 'month', - 'quarter', - 'year', - ], function(format) { - if (this.timeUnit) { + var innerWidth = this.width - (this.paddingLeft + this.paddingRight); + var labelCapacity = innerWidth / this.options.labels.fontSize + 4; + var buffer = this.options.tick.round ? 0 : 2; + + this.tickRange = Math.ceil(this.lastTick.diff(this.firstTick, true) + buffer); + var done; + + helpers.each(time.units, function(format) { + if (this.tickRange <= labelCapacity) { return; } - var start; - helpers.each(definedMoments, function(mom) { - if (!start) { - start = mom[format](); - } + this.tickUnit = format; + this.tickRange = Math.ceil(this.lastTick.diff(this.firstTick, this.tickUnit) + buffer); + this.displayFormat = time.unit[format].display; - if (mom[format]() !== start) { - this.timeUnit = format; - if (!this.displayFormat) { - this.displayFormat = this.options.time.unitFormats[format]; - } - } - }, this); }, this); - } else { - this.timeUnit = this.options.time.unit; } - if (!this.timeUnit) { - this.timeUnit = 'day'; - this.displayFormat = this.options.time.unitFormats.day; - } + this.firstTick.startOf(this.tickUnit); + this.lastTick.endOf(this.tickUnit); - if (this.options.time.display) { - this.displayFormat = this.options.time.display; + // Tick displayFormat override + if (this.options.tick.displayFormat) { + this.displayFormat = this.options.tick.displayFormat; } - - // Find the first and last moments - this.firstMoment = moment.min.call(this, definedMoments); - this.lastMoment = moment.max.call(this, definedMoments); - - // Find the length of the timeframe in the desired unit - var momentRangeLength = this.lastMoment.diff(this.firstMoment, this.timeUnit); - - helpers.each(definedMoments, function(definedMoment, index) { - this.timeLabelIndexMap[index] = momentRangeLength - this.lastMoment.diff(definedMoment, this.timeUnit); - this.data.timeLabels.push( - definedMoment - .format(this.options.time.display ? this.options.time.display : this.displayFormat) - ); - }, this); - // For every unit in between the first and last moment, create a moment and add it to the labels tick var i = 0; if (this.options.labels.userCallback) { - for (; i <= momentRangeLength; i++) { - this.labels.push( - this.options.labels.userCallback(this.firstMoment - .add((!i ? 0 : 1), this.timeUnit) - .format(this.options.time.display ? this.options.time.display : this.displayFormat) + for (; i <= this.tickRange; i++) { + this.ticks.push( + this.options.labels.userCallback(this.firstTick.clone() + .add(i, this.tickUnit) + .format(this.options.tick.displayFormat ? this.options.tick.displayFormat : time.unit[this.tickUnit].display) ) ); } } else { - for (; i <= momentRangeLength; i++) { - this.labels.push(this.firstMoment - .add((!i ? 0 : 1), this.timeUnit) - .format(this.options.time.display ? this.options.time.display : this.displayFormat) + for (; i <= this.tickRange; i++) { + this.ticks.push(this.firstTick.clone() + .add(i, this.tickUnit) + .format(this.options.tick.displayFormat ? this.options.tick.displayFormat : time.unit[this.tickUnit].display) ); } } - - }, - getPixelForValue: function(value, index, datasetIndex, includeOffset) { + getPixelForValue: function(value, decimal, datasetIndex, includeOffset) { // This must be called after fit has been run so that // this.left, this.top, this.right, and this.bottom have been defined if (this.isHorizontal()) { var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.labels.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); - var valueOffset = (valueWidth * index) + this.paddingLeft; + var valueWidth = innerWidth / Math.max((this.ticks.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueOffset = (innerWidth * decimal) + this.paddingLeft; if (this.options.gridLines.offsetGridLines && includeOffset) { valueOffset += (valueWidth / 2); @@ -178,17 +201,18 @@ return this.left + Math.round(valueOffset); } else { - return this.top + (index * (this.height / this.labels.length)); + return this.top + (decimal * (this.height / this.ticks.length)); } }, getPointPixelForValue: function(value, index, datasetIndex) { - // This function references the timeLaabelIndexMap to know which index in the timeLabels corresponds to the index of original labels - return this.getPixelForValue(value, this.timeLabelIndexMap[index], datasetIndex, true); + + var offset = this.labelMoments[index].diff(this.firstTick, this.tickUnit, true); + return this.getPixelForValue(value, offset / this.tickRange, datasetIndex); }, // Functions needed for bar charts calculateBaseWidth: function() { - return (this.getPixelForValue(null, 1, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); + return (this.getPixelForValue(null, this.ticks.length / 100, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); }, calculateBarWidth: function(barDatasetCount) { //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset @@ -200,6 +224,7 @@ return (baseWidth / barDatasetCount); }, calculateBarX: function(barDatasetCount, datasetIndex, elementIndex) { + var xWidth = this.calculateBaseWidth(), xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), barWidth = this.calculateBarWidth(barDatasetCount); @@ -211,14 +236,14 @@ return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * this.options.spacing) + barWidth / 2; }, - calculateLabelRotation: function(maxHeight, margins) { + calculateTickRotation: function(maxHeight, margins) { //Get the width of each grid by calculating the difference //between x offsets between 0 and 1. var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); this.ctx.font = labelFont; - var firstWidth = this.ctx.measureText(this.labels[0]).width; - var lastWidth = this.ctx.measureText(this.labels[this.labels.length - 1]).width; + var firstWidth = this.ctx.measureText(this.ticks[0]).width; + var lastWidth = this.ctx.measureText(this.ticks[this.ticks.length - 1]).width; var firstRotated; var lastRotated; @@ -228,7 +253,7 @@ this.labelRotation = 0; if (this.options.display) { - var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var originalLabelWidth = helpers.longestText(this.ctx, labelFont, this.ticks); var cosRotation; var sinRotation; var firstRotatedWidth; @@ -238,7 +263,7 @@ //Allow 3 pixels x2 padding either side for label readability // only the index matters for a dataset scale, but we want a consistent interface between scales - var datasetWidth = Math.floor(this.getPixelForValue(0, 1) - this.getPixelForValue(0, 0)) - 6; + var datasetWidth = Math.floor(this.getPixelForValue(null, 1 / this.ticks.length) - this.getPixelForValue(null, 0)) - 6; //Max label rotation can be set or default to 90 - also act as a loop counter while (this.labelWidth > datasetWidth && this.labelRotation <= this.options.labels.maxRotation) { @@ -264,6 +289,7 @@ this.labelRotation++; this.labelWidth = cosRotation * originalLabelWidth; + } } else { this.labelWidth = 0; @@ -292,8 +318,8 @@ this.height = maxHeight; } - this.buildLabels(); - this.calculateLabelRotation(maxHeight, margins); + this.generateTicks(); + this.calculateTickRotation(maxHeight, margins); var minSize = { width: 0, @@ -301,7 +327,7 @@ }; var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily); - var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.labels); + var longestLabelWidth = helpers.longestText(this.ctx, labelFont, this.ticks); // Width if (this.isHorizontal()) { @@ -340,17 +366,17 @@ var isRotated = this.labelRotation !== 0; var skipRatio = false; - if ((this.options.labels.fontSize + 4) * this.labels.length > (this.width - (this.paddingLeft + this.paddingRight))) { - skipRatio = 1 + Math.floor(((this.options.labels.fontSize + 4) * this.labels.length) / (this.width - (this.paddingLeft + this.paddingRight))); + if ((this.options.labels.fontSize + 4) * this.ticks.length > (this.width - (this.paddingLeft + this.paddingRight))) { + skipRatio = 1 + Math.floor(((this.options.labels.fontSize + 4) * this.ticks.length) / (this.width - (this.paddingLeft + this.paddingRight))); } - helpers.each(this.labels, function(label, index) { - // Blank labels - if ((skipRatio > 1 && index % skipRatio > 0) || (label === undefined || label === null)) { + helpers.each(this.ticks, function(tick, index) { + // Blank ticks + if ((skipRatio > 1 && index % skipRatio > 0) || (tick === undefined || tick === null)) { return; } - var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines - var xLabelValue = this.getPixelForValue(label, index, null, true); // x values for labels (need to consider offsetLabel option) + var xLineValue = this.getPixelForValue(null, (1 / (this.ticks.length - 1)) * index, null, false); // xvalues for grid lines + var xLabelValue = this.getPixelForValue(null, (1 / (this.ticks.length - 1)) * index, null, true); // x values for ticks (need to consider offsetLabel option) if (this.options.gridLines.show) { if (index === 0) { @@ -366,7 +392,7 @@ xLineValue += helpers.aliasPixel(this.ctx.lineWidth); - // Draw the label area + // Draw the tick area this.ctx.beginPath(); if (this.options.gridLines.drawTicks) { @@ -391,7 +417,7 @@ this.ctx.font = this.font; this.ctx.textAlign = (isRotated) ? "right" : "center"; this.ctx.textBaseline = (isRotated) ? "middle" : "top"; - this.ctx.fillText(label, 0, 0); + this.ctx.fillText(tick, 0, 0); this.ctx.restore(); } }, this); From 5ff2b530b9927b48c68965e8ac568ab2719cf5db Mon Sep 17 00:00:00 2001 From: Menno Dekker Date: Thu, 17 Sep 2015 09:43:02 +0200 Subject: [PATCH 299/424] Hover on dataset now works just like hover on label Fixed some errors in de hover on dataset mode, only tested on bar charts --- src/core/core.controller.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 5b611e8ea4b..3833cd153c0 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -328,10 +328,12 @@ var eventPosition = helpers.getRelativePosition(e); var elementsArray = []; - for (var datasetIndex = 0; datasetIndex < this.chart.data.datasets.length; datasetIndex++) { - for (elementIndex = 0; elementIndex < this.chart.data.datasets[datasetIndex].metaData.length; elementIndex++) { - if (this.chart.data.datasets[datasetIndex].metaData[elementIndex].inLabelRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.chart.data.datasets, datasetIterator); + for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { + for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { + if (this.data.datasets[datasetIndex].metaData[elementIndex].inLabelRange(eventPosition.x, eventPosition.y)) { + helpers.each(this.data.datasets[datasetIndex].metaData, function(element, index) { + elementsArray.push(this.data.datasets[datasetIndex].metaData); + }, this); } } } @@ -422,12 +424,11 @@ this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index); break; case 'label': + case 'dataset': for (var i = 0; i < this.lastActive.length; i++) { this.data.datasets[this.lastActive[i]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index); } break; - case 'dataset': - break; default: // Don't change anything } @@ -440,12 +441,11 @@ this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[0]); break; case 'label': + case 'dataset': for (var i = 0; i < this.active.length; i++) { this.data.datasets[this.active[i]._datasetIndex].controller.setHoverStyle(this.active[i]); } break; - case 'dataset': - break; default: // Don't change anything } From 5047678799796f6aeb07a19777d66e054e7e14f4 Mon Sep 17 00:00:00 2001 From: Menno Dekker Date: Thu, 17 Sep 2015 10:08:42 +0200 Subject: [PATCH 300/424] Tabs to spaces + fixed error --- src/core/core.controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 3833cd153c0..806248485a9 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -331,9 +331,9 @@ for (var datasetIndex = 0; datasetIndex < this.data.datasets.length; datasetIndex++) { for (var elementIndex = 0; elementIndex < this.data.datasets[datasetIndex].metaData.length; elementIndex++) { if (this.data.datasets[datasetIndex].metaData[elementIndex].inLabelRange(eventPosition.x, eventPosition.y)) { - helpers.each(this.data.datasets[datasetIndex].metaData, function(element, index) { - elementsArray.push(this.data.datasets[datasetIndex].metaData); - }, this); + helpers.each(this.data.datasets[datasetIndex].metaData, function(element, index) { + elementsArray.push(element); + }, this); } } } From 723c85320ff2d3045e33a518eca5ba3ae45e7b72 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 17 Sep 2015 20:29:41 -0400 Subject: [PATCH 301/424] Unit tests for logarithmic scale. Fixed some issues in stacked mode since it's not possible for a 0 crossing to occur with a log scale. --- src/scales/scale.logarithmic.js | 45 +- test/scale.logarithmic.tests.js | 1561 +++++++++++++++++++++++++++++++ 2 files changed, 1577 insertions(+), 29 deletions(-) create mode 100644 test/scale.logarithmic.tests.js diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index 7d0f181c99d..20545846eba 100644 --- a/src/scales/scale.logarithmic.js +++ b/src/scales/scale.logarithmic.js @@ -22,7 +22,6 @@ // scale numbers reverse: false, - beginAtZero: false, override: null, // label settings @@ -160,8 +159,7 @@ this.min = null; this.max = null; - var positiveValues = []; - var negativeValues = []; + var values = []; if (this.options.stacked) { helpers.each(this.data.datasets, function(dataset) { @@ -170,23 +168,18 @@ var value = this.getRightValue(rawValue); - positiveValues[index] = positiveValues[index] || 0; - negativeValues[index] = negativeValues[index] || 0; + values[index] = values[index] || 0; if (this.options.relativePoints) { - positiveValues[index] = 100; + values[index] = 100; } else { - if (value < 0) { - negativeValues[index] += value; - } else { - positiveValues[index] += value; - } + // Don't need to split positive and negative since the log scale can't handle a 0 crossing + values[index] += value; } }, this); } }, this); - var values = positiveValues.concat(negativeValues); this.min = helpers.min(values); this.max = helpers.max(values); @@ -213,8 +206,13 @@ } if (this.min === this.max) { - this.min--; - this.max++; + if (this.min !== 0 && this.min !== null) { + this.min = Math.pow(10, Math.floor(helpers.log10(this.min)) - 1); + this.max = Math.pow(10, Math.floor(helpers.log10(this.max)) + 1); + } else { + this.min = 1; + this.max = 10; + } } }, @@ -251,17 +249,9 @@ var value = this.data.datasets[datasetIndex].data[index]; - if (value < 0) { - for (var i = 0; i < datasetIndex; i++) { - if (this.data.datasets[i].yAxisID === this.id) { - base += this.data.datasets[i].data[index] < 0 ? this.data.datasets[i].data[index] : 0; - } - } - } else { - for (var j = 0; j < datasetIndex; j++) { - if (this.data.datasets[j].yAxisID === this.id) { - base += this.data.datasets[j].data[index] > 0 ? this.data.datasets[j].data[index] : 0; - } + for (var j = 0; j < datasetIndex; j++) { + if (this.data.datasets[j].yAxisID === this.id) { + base += this.data.datasets[j].data[index]; } } @@ -270,10 +260,7 @@ base = this.getPixelForValue(this.min); - if (this.beginAtZero || ((this.min <= 0 && this.max >= 0) || (this.min >= 0 && this.max <= 0))) { - base = this.getPixelForValue(0); - base += this.options.gridLines.lineWidth; - } else if (this.min < 0 && this.max < 0) { + if (this.min < 0 && this.max < 0) { // All values are negative. Use the top as the base base = this.getPixelForValue(this.max); } diff --git a/test/scale.logarithmic.tests.js b/test/scale.logarithmic.tests.js new file mode 100644 index 00000000000..7a472d88c1b --- /dev/null +++ b/test/scale.logarithmic.tests.js @@ -0,0 +1,1561 @@ +describe('Logarithmic Scale tests', function() { + + it('Should register the constructor with the scale service', function() { + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + expect(Constructor).not.toBe(undefined); + expect(typeof Constructor).toBe('function'); + }); + + it('Should have the correct default config', function() { + var defaultConfig = Chart.scaleService.getScaleDefaults('logarithmic'); + expect(defaultConfig).toEqual({ + display: true, + position: "left", + gridLines: { + show: true, + color: "rgba(0, 0, 0, 0.1)", + lineWidth: 1, + drawOnChartArea: true, + drawTicks: true, + zeroLineWidth: 1, + zeroLineColor: "rgba(0,0,0,0.25)", + }, + reverse: false, + override: null, + labels: { + show: true, + mirror: false, + padding: 10, + template: "<%var remain = value / (Math.pow(10, Math.floor(Chart.helpers.log10(value))));if (remain === 1 || remain === 2 || remain === 5) {%><%=value.toExponential()%><%} else {%><%= null %><%}%>", + fontSize: 12, + fontStyle: "normal", + fontColor: "#666", + fontFamily: "Helvetica Neue" + } + }); + }); + + it('Should correctly determine the max & min data values', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 5000, 78, 450] + }, { + yAxisID: 'second scale', + data: [1, 1000, 10, 100], + }, { + yAxisID: scaleID, + data: [150] + }] + }; + + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: Chart.scaleService.getScaleDefaults('logarithmic'), // use default config for scale + data: mockData, + id: scaleID + }); + + expect(scale).not.toEqual(undefined); // must construct + expect(scale.min).toBe(undefined); // not yet set + expect(scale.max).toBe(undefined); + + scale.calculateRange(); + expect(scale.min).toBe(5); + expect(scale.max).toBe(5000); + }); + + it('Should correctly determine the max & min for scatter data', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [{ + x: 10, + y: 100 + }, { + x: 2, + y: 6 + }, { + x: 65, + y: 121 + }, { + x: 99, + y: 7 + }] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var verticalScale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + verticalScale.calculateRange(); + expect(verticalScale.min).toBe(6); + expect(verticalScale.max).toBe(121); + + var horizontalConfig = Chart.helpers.clone(config); + horizontalConfig.position = 'bottom'; + var horizontalScale = new Constructor({ + ctx: {}, + options: horizontalConfig, + data: mockData, + id: scaleID, + }); + + horizontalScale.calculateRange(); + expect(horizontalScale.min).toBe(2); + expect(horizontalScale.max).toBe(99); + }); + + it('Should correctly determine the min and max data values when stacked mode is turned on', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 1, 5, 78, 100] + }, { + yAxisID: 'second scale', + data: [-1000, 1000], + }, { + yAxisID: scaleID, + data: [150, 10, 10, 100, 10, 9] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + config.stacked = true; // enable scale stacked mode + + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + expect(scale.min).toBe(11); + expect(scale.max).toBe(160); + }); + + it('Should ensure that the scale has a max and min that are not equal', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + expect(scale.min).toBe(1); + expect(scale.max).toBe(10); + + mockData.datasets = [{ + yAxisID: scaleID, + data: [0.15, 0.15] + }]; + + scale.calculateRange(); + expect(scale.min).toBe(0.01); + expect(scale.max).toBe(1); + }); + + it('Should generate tick marks', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }, ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + expect(scale.ticks).toBe(undefined); // not set + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Counts down because the lines are drawn top to bottom + expect(scale.ticks).toEqual([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); + expect(scale.start).toBe(1); + expect(scale.end).toBe(100); + }); + + it('Should generate tick marks in the correct order in reversed mode', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }, ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + config.reverse = true; + + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + expect(scale.ticks).toBe(undefined); // not set + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Counts down because the lines are drawn top to bottom + expect(scale.ticks).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]); + expect(scale.start).toBe(100); + expect(scale.end).toBe(1); + }); + + it('Should generate tick marks using the user supplied options', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 0, 25, 78] + }, ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + config.override = { + steps: 9, + start: 1, + stepWidth: 1 + }; + + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + expect(scale.ticks).toEqual([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); + expect(scale.start).toBe(1); + expect(scale.end).toBe(10); + }); + + it('Should build labels using the default template', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }, ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Generate labels + scale.buildLabels(); + + expect(scale.labels).toEqual(['1e+2', '', '', '', '', '5e+1', '', '', '2e+1', '1e+1', '', '', '', '', '5e+0', '', '', '2e+0', '1e+0']); + }); + + it('Should build labels using the user supplied callback', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }, ] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + config.labels.userCallback = function(value, index) { + return index.toString(); + }; + + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var scale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + scale.calculateRange(); + + // Large enough to be unimportant + var maxWidth = 400; + var maxHeight = 400; + scale.generateTicks(maxWidth, maxHeight); + + // Generate labels + scale.buildLabels(); + + // Just the index + expect(scale.labels).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18']); + }); + + it('Should get the correct pixel value for a point', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var verticalScale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + verticalScale.calculateRange(); + verticalScale.generateTicks(50, 100); + + // Fake out positioning of the scale service + verticalScale.left = 0; + verticalScale.top = 0; + verticalScale.right = 50; + verticalScale.bottom = 110; + verticalScale.paddingTop = 5; + verticalScale.paddingBottom = 5; + verticalScale.width = 50; + verticalScale.height = 110; + + expect(verticalScale.getPointPixelForValue(100, 0, 0)).toBe(5); // top + paddingTop + expect(verticalScale.getPointPixelForValue(1, 0, 0)).toBe(105); // bottom - paddingBottom + expect(verticalScale.getPointPixelForValue(10, 0, 0)).toBe(55); // halfway + + var horizontalConfig = Chart.helpers.clone(config); + horizontalConfig.position = 'bottom'; + var horizontalScale = new Constructor({ + ctx: {}, + options: horizontalConfig, + data: mockData, + id: scaleID, + }); + + horizontalScale.calculateRange(); + horizontalScale.generateTicks(100, 50); + + // Fake out positioning of the scale service + horizontalScale.left = 0; + horizontalScale.top = 0; + horizontalScale.right = 110; + horizontalScale.bottom = 50; + horizontalScale.paddingLeft = 5; + horizontalScale.paddingRight = 5; + horizontalScale.width = 110; + horizontalScale.height = 50; + + // Range expands to [-2, 2] due to nicenum algorithm + expect(horizontalScale.getPointPixelForValue(100, 0, 0)).toBe(105); // right - paddingRight + expect(horizontalScale.getPointPixelForValue(1, 0, 0)).toBe(5); // left + paddingLeft + expect(horizontalScale.getPointPixelForValue(10, 0, 0)).toBe(55); // halfway + }); + + it('should get the correct pixel value for a bar', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }] + }; + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var verticalScale = new Constructor({ + ctx: {}, + options: config, + data: mockData, + id: scaleID + }); + + verticalScale.calculateRange(); + verticalScale.generateTicks(50, 100); + + // Fake out positioning of the scale service + verticalScale.left = 0; + verticalScale.top = 0; + verticalScale.right = 50; + verticalScale.bottom = 110; + verticalScale.paddingTop = 5; + verticalScale.paddingBottom = 5; + verticalScale.width = 50; + verticalScale.height = 110; + + expect(verticalScale.calculateBarBase()).toBe(105); // bottom + expect(verticalScale.calculateBarY(0, 3)).toBe(35.10299956639811); // bottom + }); + + it('should fit correctly', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var verticalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = verticalScale.fit(100, 300); + expect(minSize).toEqual({ + width: 53, + height: 300, + }); + expect(verticalScale.width).toBe(53); + expect(verticalScale.height).toBe(300); + expect(verticalScale.paddingTop).toBe(6); + expect(verticalScale.paddingBottom).toBe(6); + expect(verticalScale.paddingLeft).toBe(0); + expect(verticalScale.paddingRight).toBe(0); + + // Refit with margins to see the padding go away + minSize = verticalScale.fit(53, 300, { + left: 0, + right: 0, + top: 15, + bottom: 3 + }); + expect(minSize).toEqual({ + width: 53, + height: 300, + }); + expect(verticalScale.paddingTop).toBe(0); + expect(verticalScale.paddingBottom).toBe(3); + expect(verticalScale.paddingLeft).toBe(0); + expect(verticalScale.paddingRight).toBe(0); + }); + + it('should fit correctly when horizontal', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + config.position = "bottom"; + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var verticalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = verticalScale.fit(100, 300); + expect(minSize).toEqual({ + width: 100, + height: 28, + }); + expect(verticalScale.width).toBe(100); + expect(verticalScale.height).toBe(28); + expect(verticalScale.paddingTop).toBe(0); + expect(verticalScale.paddingBottom).toBe(0); + expect(verticalScale.paddingLeft).toBe(20); + expect(verticalScale.paddingRight).toBe(20); + + // Refit with margins to see the padding go away + minSize = verticalScale.fit(100, 28, { + left: 10, + right: 6, + top: 15, + bottom: 3 + }); + expect(minSize).toEqual({ + width: 100, + height: 28, + }); + expect(verticalScale.paddingTop).toBe(0); + expect(verticalScale.paddingBottom).toBe(0); + expect(verticalScale.paddingLeft).toBe(10); + expect(verticalScale.paddingRight).toBe(14); + }); + + it('should draw correctly horizontally', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [10, 5, 1, 25, 78] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + config.position = "bottom"; + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var horizontalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = horizontalScale.fit(100, 300); + minSize = horizontalScale.fit(100, 28, { + left: 10, + right: 6, + top: 15, + bottom: 3 + }); + + horizontalScale.left = 0; + horizontalScale.right = minSize.width; + horizontalScale.top = 0; + horizontalScale.bottom = minSize.height; + + var chartArea = { + top: 100, + bottom: 0, + left: 0, + right: minSize.width + }; + horizontalScale.draw(chartArea); + + expect(mockContext.getCalls()).toEqual([{ + "name": "measureText", + "args": ["1e+0"] + }, { + "name": "measureText", + "args": ["1e+2"] + }, { + "name": "measureText", + "args": ["1e+0"] + }, { + "name": "measureText", + "args": ["1e+2"] + }, { + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [10.5, 0] + }, { + "name": "lineTo", + "args": [10.5, 5] + }, { + "name": "moveTo", + "args": [10.5, 100] + }, { + "name": "lineTo", + "args": [10.5, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [21.939139835231288, 0] + }, { + "name": "lineTo", + "args": [21.939139835231288, 5] + }, { + "name": "moveTo", + "args": [21.939139835231288, 100] + }, { + "name": "lineTo", + "args": [21.939139835231288, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28.63060767934717, 0] + }, { + "name": "lineTo", + "args": [28.63060767934717, 5] + }, { + "name": "moveTo", + "args": [28.63060767934717, 100] + }, { + "name": "lineTo", + "args": [28.63060767934717, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [33.378279670462575, 0] + }, { + "name": "lineTo", + "args": [33.378279670462575, 5] + }, { + "name": "moveTo", + "args": [33.378279670462575, 100] + }, { + "name": "lineTo", + "args": [33.378279670462575, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [37.06086016476871, 0] + }, { + "name": "lineTo", + "args": [37.06086016476871, 5] + }, { + "name": "moveTo", + "args": [37.06086016476871, 100] + }, { + "name": "lineTo", + "args": [37.06086016476871, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [40.06974751457846, 0] + }, { + "name": "lineTo", + "args": [40.06974751457846, 5] + }, { + "name": "moveTo", + "args": [40.06974751457846, 100] + }, { + "name": "lineTo", + "args": [40.06974751457846, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [42.613725520541756, 0] + }, { + "name": "lineTo", + "args": [42.613725520541756, 5] + }, { + "name": "moveTo", + "args": [42.613725520541756, 100] + }, { + "name": "lineTo", + "args": [42.613725520541756, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [44.817419505693856, 0] + }, { + "name": "lineTo", + "args": [44.817419505693856, 5] + }, { + "name": "moveTo", + "args": [44.817419505693856, 100] + }, { + "name": "lineTo", + "args": [44.817419505693856, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [46.76121535869434, 0] + }, { + "name": "lineTo", + "args": [46.76121535869434, 5] + }, { + "name": "moveTo", + "args": [46.76121535869434, 100] + }, { + "name": "lineTo", + "args": [46.76121535869434, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [48.5, 0] + }, { + "name": "lineTo", + "args": [48.5, 5] + }, { + "name": "moveTo", + "args": [48.5, 100] + }, { + "name": "lineTo", + "args": [48.5, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [59.93913983523129, 0] + }, { + "name": "lineTo", + "args": [59.93913983523129, 5] + }, { + "name": "moveTo", + "args": [59.93913983523129, 100] + }, { + "name": "lineTo", + "args": [59.93913983523129, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [66.63060767934718, 0] + }, { + "name": "lineTo", + "args": [66.63060767934718, 5] + }, { + "name": "moveTo", + "args": [66.63060767934718, 100] + }, { + "name": "lineTo", + "args": [66.63060767934718, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [71.37827967046258, 0] + }, { + "name": "lineTo", + "args": [71.37827967046258, 5] + }, { + "name": "moveTo", + "args": [71.37827967046258, 100] + }, { + "name": "lineTo", + "args": [71.37827967046258, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [75.06086016476871, 0] + }, { + "name": "lineTo", + "args": [75.06086016476871, 5] + }, { + "name": "moveTo", + "args": [75.06086016476871, 100] + }, { + "name": "lineTo", + "args": [75.06086016476871, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [78.06974751457845, 0] + }, { + "name": "lineTo", + "args": [78.06974751457845, 5] + }, { + "name": "moveTo", + "args": [78.06974751457845, 100] + }, { + "name": "lineTo", + "args": [78.06974751457845, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [80.61372552054176, 0] + }, { + "name": "lineTo", + "args": [80.61372552054176, 5] + }, { + "name": "moveTo", + "args": [80.61372552054176, 100] + }, { + "name": "lineTo", + "args": [80.61372552054176, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [82.81741950569385, 0] + }, { + "name": "lineTo", + "args": [82.81741950569385, 5] + }, { + "name": "moveTo", + "args": [82.81741950569385, 100] + }, { + "name": "lineTo", + "args": [82.81741950569385, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [84.76121535869434, 0] + }, { + "name": "lineTo", + "args": [84.76121535869434, 5] + }, { + "name": "moveTo", + "args": [84.76121535869434, 100] + }, { + "name": "lineTo", + "args": [84.76121535869434, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [86.5, 0] + }, { + "name": "lineTo", + "args": [86.5, 5] + }, { + "name": "moveTo", + "args": [86.5, 100] + }, { + "name": "lineTo", + "args": [86.5, 0] + }, { + "name": "stroke", + "args": [] + }, { + "name": "fillText", + "args": ["1e+0", 10, 10] + }, { + "name": "fillText", + "args": ["2e+0", 21.439139835231288, 10] + }, { + "name": "fillText", + "args": ["5e+0", 36.56086016476871, 10] + }, { + "name": "fillText", + "args": ["1e+1", 48, 10] + }, { + "name": "fillText", + "args": ["2e+1", 59.43913983523129, 10] + }, { + "name": "fillText", + "args": ["5e+1", 74.56086016476871, 10] + }, { + "name": "fillText", + "args": ["1e+2", 86, 10] + }]); + + // Turn off some drawing + config.gridLines.drawTicks = false; + config.gridLines.drawOnChartArea = false; + config.labels.show = false; + + mockContext.resetCalls(); + + horizontalScale.draw(); + expect(mockContext.getCalls()).toEqual([{ + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }]); + + // Turn off display + + mockContext.resetCalls(); + config.display = false; + horizontalScale.draw(); + expect(mockContext.getCalls()).toEqual([]); + }); + + it('should draw correctly vertically', function() { + var scaleID = 'myScale'; + + var mockData = { + datasets: [{ + xAxisID: scaleID, // for the horizontal scale + yAxisID: scaleID, + data: [10, 5, 1, 2.5, 7.8] + }] + }; + var mockContext = window.createMockContext(); + + var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('logarithmic')); + var Constructor = Chart.scaleService.getScaleConstructor('logarithmic'); + var verticalScale = new Constructor({ + ctx: mockContext, + options: config, + data: mockData, + id: scaleID + }); + + var minSize = verticalScale.fit(100, 300); + minSize = verticalScale.fit(33, 300, { + left: 0, + right: 0, + top: 15, + bottom: 3 + }); + expect(minSize).toEqual({ + width: 33, + height: 300, + }); + + verticalScale.left = 0; + verticalScale.right = minSize.width; + verticalScale.top = 0; + verticalScale.bottom = minSize.height; + + var chartArea = { + top: 0, + bottom: minSize.height, + left: minSize.width, + right: minSize.width + 100 + }; + verticalScale.draw(chartArea); + + var expected = [{ + "name": "measureText", + "args": ["1e+1"] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": ["5e+0"] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": ["2e+0"] + }, { + "name": "measureText", + "args": ["1e+0"] + }, { + "name": "measureText", + "args": ["1e+1"] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": ["5e+0"] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": [""] + }, { + "name": "measureText", + "args": ["2e+0"] + }, { + "name": "measureText", + "args": ["1e+0"] + }, { + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 0.5] + }, { + "name": "lineTo", + "args": [33, 0.5] + }, { + "name": "moveTo", + "args": [33, 0.5] + }, { + "name": "lineTo", + "args": [133, 0.5] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 14.089974696520528] + }, { + "name": "lineTo", + "args": [33, 14.089974696520528] + }, { + "name": "moveTo", + "args": [33, 14.089974696520528] + }, { + "name": "lineTo", + "args": [133, 14.089974696520528] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 29.28227386339279] + }, { + "name": "lineTo", + "args": [33, 29.28227386339279] + }, { + "name": "moveTo", + "args": [33, 29.28227386339279] + }, { + "name": "lineTo", + "args": [133, 29.28227386339279] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 46.50588211576573] + }, { + "name": "lineTo", + "args": [33, 46.50588211576573] + }, { + "name": "moveTo", + "args": [33, 46.50588211576573] + }, { + "name": "lineTo", + "args": [133, 46.50588211576573] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 66.38907863605783] + }, { + "name": "lineTo", + "args": [33, 66.38907863605783] + }, { + "name": "moveTo", + "args": [33, 66.38907863605783] + }, { + "name": "lineTo", + "args": [133, 66.38907863605783] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 89.9059087122024] + }, { + "name": "lineTo", + "args": [33, 89.9059087122024] + }, { + "name": "moveTo", + "args": [33, 89.9059087122024] + }, { + "name": "lineTo", + "args": [133, 89.9059087122024] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 118.68818257559516] + }, { + "name": "lineTo", + "args": [33, 118.68818257559516] + }, { + "name": "moveTo", + "args": [33, 118.68818257559516] + }, { + "name": "lineTo", + "args": [133, 118.68818257559516] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 155.79498734826026] + }, { + "name": "lineTo", + "args": [33, 155.79498734826026] + }, { + "name": "moveTo", + "args": [33, 155.79498734826026] + }, { + "name": "lineTo", + "args": [133, 155.79498734826026] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 208.0940912877976] + }, { + "name": "lineTo", + "args": [33, 208.0940912877976] + }, { + "name": "moveTo", + "args": [33, 208.0940912877976] + }, { + "name": "lineTo", + "args": [133, 208.0940912877976] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "moveTo", + "args": [28, 297.5] + }, { + "name": "lineTo", + "args": [33, 297.5] + }, { + "name": "moveTo", + "args": [33, 297.5] + }, { + "name": "lineTo", + "args": [133, 297.5] + }, { + "name": "stroke", + "args": [] + }, { + "name": "fillText", + "args": ["1e+1", 23, 0] + }, { + "name": "fillText", + "args": ["", 23, 13.589974696520528] + }, { + "name": "fillText", + "args": ["", 23, 28.78227386339279] + }, { + "name": "fillText", + "args": ["", 23, 46.00588211576573] + }, { + "name": "fillText", + "args": ["", 23, 65.88907863605783] + }, { + "name": "fillText", + "args": ["5e+0", 23, 89.4059087122024] + }, { + "name": "fillText", + "args": ["", 23, 118.18818257559516] + }, { + "name": "fillText", + "args": ["", 23, 155.29498734826026] + }, { + "name": "fillText", + "args": ["2e+0", 23, 207.5940912877976] + }, { + "name": "fillText", + "args": ["1e+0", 23, 297] + }]; + expect(mockContext.getCalls()).toEqual(expected); + + // Turn off some drawing + config.gridLines.drawTicks = false; + config.gridLines.drawOnChartArea = false; + config.labels.show = false; + + mockContext.resetCalls(); + + verticalScale.draw(); + expect(mockContext.getCalls()).toEqual([{ + "name": "setFillStyle", + "args": ["#666"] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0,0,0,0.25)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "setLineWidth", + "args": [1] + }, { + "name": "setStrokeStyle", + "args": ["rgba(0, 0, 0, 0.1)"] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }, { + "name": "beginPath", + "args": [] + }, { + "name": "stroke", + "args": [] + }]); + }); +}); \ No newline at end of file From 677c249b613bf1a4ebccb1bebda9f04f7346b866 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 18 Sep 2015 11:31:25 -0600 Subject: [PATCH 302/424] Bar and combo support for time scale --- samples/combo-time-scale.html | 186 ++++++++++++++++++++++++++++++ samples/line-time-scale.html | 10 +- src/elements/element.rectangle.js | 2 +- src/scales/scale.time.js | 19 +-- 4 files changed, 203 insertions(+), 14 deletions(-) create mode 100644 samples/combo-time-scale.html diff --git a/samples/combo-time-scale.html b/samples/combo-time-scale.html new file mode 100644 index 00000000000..61acfa6c104 --- /dev/null +++ b/samples/combo-time-scale.html @@ -0,0 +1,186 @@ + + + + + Line Chart + + + + + + +
    + +
    +
    +
    + + + + + +
    +

    Legend

    +
    +
    +
    + + + + diff --git a/samples/line-time-scale.html b/samples/line-time-scale.html index 01df3a4e2d7..b4b0f7edda8 100644 --- a/samples/line-time-scale.html +++ b/samples/line-time-scale.html @@ -51,7 +51,7 @@

    Legend

    data: { //labels: [newTimestamp(0), newTimestamp(1), newTimestamp(2), newTimestamp(3), newTimestamp(4), newTimestamp(5), newTimestamp(6)], // unix timestamps // labels: [newDate(0), newDate(1), newDate(2), newDate(3), newDate(4), newDate(5), newDate(6)], // Date Objects - labels: ["01/01/2015 20:00", "01/02/2015 21:00", "01/03/2015 22:00", "01/05/2015 23:00", "01/07/2015 03:00", "01/08/2015 10:00", "02/1/2015"], // Hours + labels: ["01/01/2015 20:00", "01/02/2015 21:00", "01/03/2015 22:00", "01/05/2015 23:00", "01/07/2015 03:00", "01/08/2015 10:00", "01/10/2015"], // Hours // labels: ["01/01/2015", "01/02/2015", "01/03/2015", "01/06/2015", "01/15/2015", "01/17/2015", "01/30/2015"], // Days // labels: ["12/25/2014", "01/08/2015", "01/15/2015", "01/22/2015", "01/29/2015", "02/05/2015", "02/12/2015"], // Weeks datasets: [{ @@ -143,10 +143,10 @@

    Legend

    $('#addData').click(function() { if (config.data.datasets.length > 0) { config.data.labels.push( - moment( - config.data.labels[config.data.labels.length - 1], config.options.scales.xAxes[0].time.format - ).add(1, 'day') - .format('MM/DD/YYYY') + myLine.scales['x-axis-0'].labelMoments[myLine.scales['x-axis-0'].labelMoments.length - 1] + .clone() + .add(1, 'day') + .format('MM/DD/YYYY HH:mm') ); for (var index = 0; index < config.data.datasets.length; ++index) { diff --git a/src/elements/element.rectangle.js b/src/elements/element.rectangle.js index 3d9539eb9f2..0e361cba691 100644 --- a/src/elements/element.rectangle.js +++ b/src/elements/element.rectangle.js @@ -63,7 +63,7 @@ } else { inRange = (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y); } - } + } return inRange; }, diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 18df1a6ac8f..140ff72299e 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -160,6 +160,13 @@ this.firstTick.startOf(this.tickUnit); this.lastTick.endOf(this.tickUnit); + this.smallestLabelSeparation = this.width; + + var i = 0; + + for (i = 1; i < this.labelMoments.length; i++) { + this.smallestLabelSeparation = Math.min(this.smallestLabelSeparation, this.labelMoments[i].diff(this.labelMoments[i - 1], this.tickUnit, true)); + } // Tick displayFormat override @@ -168,7 +175,6 @@ } // For every unit in between the first and last moment, create a moment and add it to the labels tick - var i = 0; if (this.options.labels.userCallback) { for (; i <= this.tickRange; i++) { this.ticks.push( @@ -192,13 +198,9 @@ // this.left, this.top, this.right, and this.bottom have been defined if (this.isHorizontal()) { var innerWidth = this.width - (this.paddingLeft + this.paddingRight); - var valueWidth = innerWidth / Math.max((this.ticks.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1); + var valueWidth = innerWidth / Math.max(this.ticks.length - 1, 1); var valueOffset = (innerWidth * decimal) + this.paddingLeft; - if (this.options.gridLines.offsetGridLines && includeOffset) { - valueOffset += (valueWidth / 2); - } - return this.left + Math.round(valueOffset); } else { return this.top + (decimal * (this.height / this.ticks.length)); @@ -212,7 +214,7 @@ // Functions needed for bar charts calculateBaseWidth: function() { - return (this.getPixelForValue(null, this.ticks.length / 100, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); + return (this.getPixelForValue(null, this.smallestLabelSeparation / this.tickRange, 0, true) - this.getPixelForValue(null, 0, 0, true)) - (2 * this.options.categorySpacing); }, calculateBarWidth: function(barDatasetCount) { //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset @@ -226,7 +228,8 @@ calculateBarX: function(barDatasetCount, datasetIndex, elementIndex) { var xWidth = this.calculateBaseWidth(), - xAbsolute = this.getPixelForValue(null, elementIndex, datasetIndex, true) - (xWidth / 2), + offset = this.labelMoments[elementIndex].diff(this.firstTick, this.tickUnit, true), + xAbsolute = this.getPixelForValue(null, offset / this.tickRange, datasetIndex, true) - (xWidth / 2), barWidth = this.calculateBarWidth(barDatasetCount); if (this.options.stacked) { From 52c1c09e16f489dcea774ac14729e4af513e8836 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 18 Sep 2015 18:41:45 -0400 Subject: [PATCH 303/424] Revert "Commit built version of scale algo changes" This reverts commit a36a3f8c09b5424dbf4e140d08a5ceb24d7a5ecb. --- Chart.js | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/Chart.js b/Chart.js index 9e0cef3205d..35a27e8dbbe 100644 --- a/Chart.js +++ b/Chart.js @@ -1841,54 +1841,6 @@ } }); - // Recalculate because the size of each scale might have changed slightly due to the margins (label rotation for instance) - totalLeftWidth = xPadding; - totalRightWidth = xPadding; - totalTopHeight = yPadding; - totalBottomHeight = yPadding; - - helpers.each(leftScales, function(scaleInstance) { - totalLeftWidth += scaleInstance.width; - }); - - helpers.each(rightScales, function(scaleInstance) { - totalRightWidth += scaleInstance.width; - }); - - helpers.each(topScales, function(scaleInstance) { - totalTopHeight += scaleInstance.height; - }); - helpers.each(bottomScales, function(scaleInstance) { - totalBottomHeight += scaleInstance.height; - }); - - // Figure out if our chart area changed. This would occur if the dataset scale label rotation - // changed due to the application of the margins in step 6. Since we can only get bigger, this is safe to do - // without calling `fit` again - var newMaxChartHeight = height - totalTopHeight - totalBottomHeight; - var newMaxChartWidth = width - totalLeftWidth - totalRightWidth; - - if (newMaxChartWidth !== maxChartWidth || newMaxChartHeight !== maxChartHeight) { - helpers.each(leftScales, function(scale) { - scale.height = newMaxChartHeight; - }); - - helpers.each(rightScales, function(scale) { - scale.height = newMaxChartHeight; - }); - - helpers.each(topScales, function(scale) { - scale.width = newMaxChartWidth; - }); - - helpers.each(bottomScales, function(scale) { - scale.width = newMaxChartWidth; - }); - - maxChartHeight = newMaxChartHeight; - maxChartWidth = newMaxChartWidth; - } - // Step 7 // Position the scales var left = xPadding; From db5066cd23e13e3c34b9db310d4003d5164b17e9 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 18 Sep 2015 18:44:00 -0400 Subject: [PATCH 304/424] Remove core.responsive file. Responsiveness is added during initialization --- src/core/core.responsive.js | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/core/core.responsive.js diff --git a/src/core/core.responsive.js b/src/core/core.responsive.js deleted file mode 100644 index 2bca2a21442..00000000000 --- a/src/core/core.responsive.js +++ /dev/null @@ -1,29 +0,0 @@ -(function() { - - "use strict"; - - //Declare root variable - window in the browser, global on the server - var root = this, - previous = root.Chart, - helpers = Chart.helpers; - - - // Attach global event to resize each chart instance when the browser resizes - /*helpers.addEvent(window, "resize", (function() { - // Basic debounce of resize function so it doesn't hurt performance when resizing browser. - var timeout; - return function() { - clearTimeout(timeout); - timeout = setTimeout(function() { - helpers.each(Chart.instances, function(instance) { - // If the responsive flag is set in the chart instance config - // Cascade the resize event down to the chart. - if (instance.options.responsive) { - instance.resize(); - } - }); - }, 16); - }; - })());*/ - -}).call(this); From 8d476934486182e0f4bd4829997b6927409de8a9 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 18 Sep 2015 18:59:55 -0400 Subject: [PATCH 305/424] Make sure that doughnut and polar area inner & outer radius is >= 0 --- src/controllers/controller.doughnut.js | 4 ++-- src/controllers/controller.polarArea.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 2513a068985..d4586b4fca6 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -86,8 +86,8 @@ update: function(reset) { - this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) / 2) - this.chart.options.elements.arc.borderWidth / 2; - this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; + this.chart.outerRadius = Math.max((helpers.min([this.chart.chart.width, this.chart.chart.height]) / 2) - this.chart.options.elements.arc.borderWidth / 2, 0); + this.chart.innerRadius = Math.max(this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1, 0); this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; this.getDataset().total = 0; diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 4de24af6d25..d832f09d18e 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -87,8 +87,8 @@ this.chart.scale.generateTicks(); this.chart.scale.buildYLabels(); - this.chart.outerRadius = (helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2; - this.chart.innerRadius = this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1; + this.chart.outerRadius = Math.max((helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2, 0); + this.chart.innerRadius = Math.max(this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1, 0); this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.data.datasets.length; this.getDataset().total = 0; From 97cec8604a9c3091acd0007d8244113c05398412 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 18 Sep 2015 19:22:54 -0400 Subject: [PATCH 306/424] Only store the original device context ratio once --- src/core/core.helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 8d6790bf9ce..02ee89aef5a 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -758,7 +758,7 @@ // Store the device pixel ratio so that we can go backwards in `destroy`. // The devicePixelRatio changes with zoom, so there are no guarantees that it is the same // when destroy is called - chart.originalDevicePixelRatio = window.devicePixelRatio; + chart.originalDevicePixelRatio = chart.originalDevicePixelRatio || window.devicePixelRatio; } }, //-- Canvas methods From 9474d72491a24b2b614a0ea0be36b736642777b8 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 19 Sep 2015 17:52:58 -0400 Subject: [PATCH 307/424] Revert "Fix resize problems when charts are initially hidden" --- gulpfile.js | 1 - package.json | 1 - samples/bar.html | 21 +------ src/charts/Chart.Doughnut.js | 1 - src/charts/Chart.PolarArea.js | 1 - src/charts/Chart.Radar.js | 5 -- src/controllers/controller.doughnut.js | 4 +- src/controllers/controller.polarArea.js | 4 +- src/core/core.controller.js | 22 +++---- src/core/core.helpers.js | 77 +++++-------------------- src/core/core.js | 43 +++++++------- src/core/core.responsive.js | 29 ++++++++++ src/core/core.scale.js | 48 --------------- 13 files changed, 81 insertions(+), 176 deletions(-) create mode 100644 src/core/core.responsive.js diff --git a/gulpfile.js b/gulpfile.js index 4115ab8a347..09ce81eff16 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -34,7 +34,6 @@ var srcFiles = [ './src/elements/**', './src/charts/**', './node_modules/color/dist/color.min.js', - './node_modules/javascript-detect-element-resize/detect-element-resize.js', './node_modules/moment/min/moment.min.js' ]; diff --git a/package.json b/package.json index 698bca3bf62..8b83a5731be 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "inquirer": "^0.5.1", "jasmine": "^2.3.2", "jasmine-core": "^2.3.4", - "javascript-detect-element-resize": "git://github.com/chartjs/javascript-detect-element-resize.git", "jquery": "^2.1.4", "karma": "^0.12.37", "karma-chrome-launcher": "^0.2.0", diff --git a/samples/bar.html b/samples/bar.html index 7f1d8e7eabf..eb8796ac5cb 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -5,15 +5,10 @@ Bar Chart - -